]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/src/close.c
The first enhanced version of Linux CAN-bus driver for OCERA project
[lincan.git] / lincan / src / close.c
1 /* close.c
2  * Linux CAN-bus device driver.
3  * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
4  * This software is released under the GPL-License.
5  * Version 0.7  6 Aug 2001
6  */
7
8 #define __NO_VERSION__
9 #include <linux/module.h> 
10
11 #include <linux/autoconf.h>
12 #if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
13 #define MODVERSIONS
14 #endif
15
16 #if defined (MODVERSIONS)
17 #include <linux/modversions.h>
18 #endif
19
20 #include <linux/fs.h>
21
22 #include "../include/main.h"
23 #include "../include/close.h"
24 #include "../include/i82527.h"
25 #include "../include/setup.h"
26
27 int can_close(struct inode *inode, struct file *file)
28 {
29         objects_p[MINOR_NR]->flags &= ~BUFFERS_ALLOCATED;
30         /* Give up message buffer memory */
31         if (objects_p[MINOR_NR]->fifo->buf_tx_entry)
32                 del_mem_from_list(objects_p[MINOR_NR]->fifo->buf_tx_entry);
33         else
34                 CANMSG("objects_p[MINOR_NR]->fifo->buf_tx_entry is NULL\n");
35         if (objects_p[MINOR_NR]->fifo->buf_rx_entry)
36                 del_mem_from_list(objects_p[MINOR_NR]->fifo->buf_rx_entry);
37         else
38                 CANMSG("objects_p[MINOR_NR]->fifo->buf_rx_entry is NULL\n");
39
40 /* FIXME: what about clearing chip HW status, stopping sending messages etc? */
41         
42         objects_p[MINOR_NR]->flags &= ~OPENED;
43 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,50))
44         MOD_DEC_USE_COUNT;
45 #endif
46         return 0;
47 }