]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/src/devcommon.c
9cd29d00e2a398b101e278a430a4d4356ce868c6
[lincan.git] / lincan / src / devcommon.c
1 /* devcommon.c - common device code
2  * Linux CAN-bus device driver.
3  * New CAN queues by Pavel Pisa - OCERA team member
4  * email:pisa@cmp.felk.cvut.cz
5  * This software is released under the GPL-License.
6  * Version lincan-0.2  9 Jul 2003
7  */
8
9 #define __NO_VERSION__
10 #include <linux/module.h>
11 #include <linux/version.h>
12 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
13 #include <linux/malloc.h>
14 #else
15 #include <linux/slab.h>
16 #endif
17 #include <linux/wait.h>
18 #include "../include/can.h"
19 #include "../include/can_queue.h"
20 #include "../include/main.h"
21 #include "../include/devcommon.h"
22
23 void canqueue_notify_chip(struct canque_ends_t *qends, struct canque_edge_t *qedge, int what)
24 {
25         struct chip_t *chip=qends->endinfo.chipinfo.chip;
26         struct msgobj_t *obj=qends->endinfo.chipinfo.msgobj;
27
28         DEBUGMSG("canqueue_notify_chip for edge %d and event %d\n",qedge->edge_num,what);
29         switch(what){
30                 /*case CANQUEUE_NOTIFY_EMPTY:*/
31                 /*case CANQUEUE_NOTIFY_SPACE:*/
32                 /*case CANQUEUE_NOTIFY_NOUSR:
33                         wake_up_interruptible(&qends->endinfo.chipinfo.daemonq);
34                         break;*/
35                 case CANQUEUE_NOTIFY_PROC:
36                         /*wake_up_interruptible(&qends->endinfo.chipinfo.daemonq);*/
37                         chip->chipspecops->wakeup_tx(chip, obj);
38                         break;
39                 case CANQUEUE_NOTIFY_DEAD:
40                         if(atomic_read(&qedge->edge_used)>0)
41                                 atomic_dec(&qedge->edge_used);
42                         break;
43                 case CANQUEUE_NOTIFY_ATACH:
44                         atomic_inc(&qedge->edge_used);
45                         break;
46         }
47 }
48
49
50 int canqueue_ends_init_chip(struct canque_ends_t *qends, struct chip_t *chip, struct msgobj_t *obj)
51 {
52         int ret;
53         ret=canqueue_ends_init_gen(qends);
54         if(ret<0) return ret;
55         
56         qends->context=NULL;
57         init_waitqueue_head(&qends->endinfo.chipinfo.daemonq);
58         qends->endinfo.chipinfo.chip=chip;
59         qends->endinfo.chipinfo.msgobj=obj;
60         qends->notify=canqueue_notify_chip;
61
62         DEBUGMSG("canqueue_ends_init_chip\n");
63         return 0;
64 }
65
66