2 * Linux CAN-bus device driver.
3 * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
4 * Rewritten for new CAN queues by Pavel Pisa - OCERA team member
5 * email:pisa@cmp.felk.cvut.cz
6 * This software is released under the GPL-License.
7 * Version lincan-0.3 17 Jun 2004
10 #include "../include/can.h"
11 #include "../include/can_sysdep.h"
12 #include "../include/main.h"
13 #include "../include/close.h"
14 #include "../include/i82527.h"
15 #include "../include/setup.h"
16 #include "../include/fasync.h"
18 #define __NO_VERSION__
19 #include <linux/module.h>
21 int can_close(struct inode *inode, struct file *file)
23 struct canuser_t *canuser = (struct canuser_t*)(file->private_data);
24 struct canque_ends_t *qends;
26 can_spin_irqflags_t iflags;
28 if(!canuser || (canuser->magic != CAN_USER_MAGIC)){
29 CANMSG("can_close: bad canuser magic\n");
33 obj = canuser->msgobj;
34 qends = canuser->qends;
36 #ifdef CAN_ENABLE_KERN_FASYNC
38 can_fasync(-1, file, 0);
40 #endif /*CAN_ENABLE_KERN_FASYNC*/
42 can_spin_lock_irqsave(&canuser_manipulation_lock, iflags);
43 list_del(&canuser->peers);
44 can_spin_unlock_irqrestore(&canuser_manipulation_lock, iflags);
45 canuser->qends = NULL;
46 canqueue_ends_dispose_kern(qends, file->f_flags & O_SYNC);
50 can_spin_lock_irqsave(&canuser_manipulation_lock, iflags);
51 if(atomic_dec_and_test(&obj->obj_used)){
52 can_msgobj_clear_fl(obj,OPENED);
54 can_spin_unlock_irqrestore(&canuser_manipulation_lock, iflags);
56 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,50))