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.2 9 Jul 2003
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;
27 if(!canuser || (canuser->magic != CAN_USER_MAGIC)){
28 CANMSG("can_close: bad canuser magic\n");
32 obj = canuser->msgobj;
33 qends = canuser->qends;
35 #ifdef CAN_ENABLE_KERN_FASYNC
37 can_fasync(-1, file, 0);
39 #endif /*CAN_ENABLE_KERN_FASYNC*/
41 list_del(&canuser->peers);
42 canuser->qends = NULL;
43 canqueue_ends_dispose_kern(qends, file->f_flags & O_SYNC);
47 if(atomic_dec_and_test(&obj->obj_used)){
48 can_msgobj_clear_fl(obj,OPENED);
49 /* FIXME: what about clearing chip HW status, stopping sending messages etc? */
52 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,50))