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
9 #include "../include/can.h"
10 #include "../include/can_sysdep.h"
11 #include "../include/can_queue.h"
12 #include "../include/main.h"
13 #include "../include/devcommon.h"
15 void canqueue_notify_chip(struct canque_ends_t *qends, struct canque_edge_t *qedge, int what)
17 struct chip_t *chip=qends->endinfo.chipinfo.chip;
18 struct msgobj_t *obj=qends->endinfo.chipinfo.msgobj;
20 DEBUGMSG("canqueue_notify_chip for edge %d and event %d\n",qedge->edge_num,what);
22 /*case CANQUEUE_NOTIFY_EMPTY:*/
23 /*case CANQUEUE_NOTIFY_SPACE:*/
24 /*case CANQUEUE_NOTIFY_NOUSR:
25 wake_up(&qends->endinfo.chipinfo.daemonq);
27 case CANQUEUE_NOTIFY_PROC:
29 /*wake_up(&qends->endinfo.chipinfo.daemonq);*/
30 chip->chipspecops->wakeup_tx(chip, obj);
31 #else /*CAN_WITH_RTL*/
32 can_msgobj_set_fl(obj,TX_REQUEST);
33 if(qends->endinfo.chipinfo.worker_thread){
34 can_msgobj_set_fl(obj,WORKER_WAKE);
35 pthread_kill(qends->endinfo.chipinfo.worker_thread,RTL_SIGNAL_WAKEUP);
38 set_bit(MSGOBJ_TX_REQUEST_b,&chip->pend_flags);
40 if(chip->worker_thread) {
41 set_bit(MSGOBJ_WORKER_WAKE_b,&chip->pend_flags);
42 pthread_kill(chip->worker_thread,RTL_SIGNAL_WAKEUP);
46 #endif /*CAN_WITH_RTL*/
48 case CANQUEUE_NOTIFY_DEAD_WANTED:
49 case CANQUEUE_NOTIFY_DEAD:
50 if(canque_fifo_test_and_clear_fl(&qedge->fifo, READY))
51 canque_edge_decref(qedge);
53 case CANQUEUE_NOTIFY_ATTACH:
59 int canqueue_ends_init_chip(struct canque_ends_t *qends, struct chip_t *chip, struct msgobj_t *obj)
62 ret=canqueue_ends_init_gen(qends);
67 init_waitqueue_head(&qends->endinfo.chipinfo.daemonq);
68 #endif /*CAN_WITH_RTL*/
69 qends->endinfo.chipinfo.chip=chip;
70 qends->endinfo.chipinfo.msgobj=obj;
71 qends->notify=canqueue_notify_chip;
73 DEBUGMSG("canqueue_ends_init_chip\n");
78 int canqueue_ends_done_chip(struct canque_ends_t *qends)
82 /* Finish or kill all outgoing edges listed in inends */
83 delayed=canqueue_ends_kill_inlist(qends, 1);
84 /* Kill all incoming edges listed in outends */
85 delayed|=canqueue_ends_kill_outlist(qends);