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
12 #include "../include/can.h"
13 #include "../include/can_sysdep.h"
14 #include "../include/main.h"
16 #include <rtl_malloc.h>
17 #include <rtl_posixio.h>
18 #include "../include/can_iortl.h"
20 #define __NO_VERSION__
21 #include <linux/module.h>
24 int can_release_rtl_common(struct canuser_t *canuser, int file_flags)
26 struct canque_ends_t *qends;
28 can_spin_irqflags_t iflags;
30 obj = canuser->msgobj;
31 qends = canuser->qends;
33 can_spin_lock_irqsave(&canuser_manipulation_lock, iflags);
34 list_del(&canuser->peers);
35 can_spin_unlock_irqrestore(&canuser_manipulation_lock, iflags);
36 canuser->qends = NULL;
37 canqueue_ends_dispose_rtl(qends, file_flags & O_SYNC);
39 can_spin_lock_irqsave(&canuser_manipulation_lock, iflags);
40 if(atomic_dec_and_test(&obj->obj_used)){
41 can_msgobj_clear_fl(obj,OPENED);
43 can_spin_unlock_irqrestore(&canuser_manipulation_lock, iflags);
45 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,50))
53 int can_release_rtl_posix(struct rtl_file *fptr)
55 struct canuser_t *canuser =
56 (struct canuser_t *)can_get_rtl_file_private_data(fptr);
59 if(!canuser || (canuser->magic != CAN_USER_MAGIC)){
60 CANMSG("can_release_rtl_posix: bad canuser magic\n");
64 ret=can_release_rtl_common(canuser, fptr->f_flags);
71 #endif /*CAN_WITH_RTL*/