2 * Header file for the Linux CAN-bus driver.
3 * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
4 * Added 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"
14 #include <linux/poll.h>
15 #include "../include/select.h"
17 unsigned int can_poll(struct file *file, poll_table *wait)
19 struct canuser_t *canuser = (struct canuser_t*)(file->private_data);
20 struct canque_ends_t *qends;
22 unsigned int mask = 0;
24 struct canque_edge_t *edge;
25 struct list_head *entry;
29 if(!canuser || (canuser->magic != CAN_USER_MAGIC)){
30 CANMSG("can_close: bad canuser magic\n");
34 obj = canuser->msgobj;
35 qends = canuser->qends;
37 if (file->f_mode & FMODE_READ) {
38 poll_wait(file, &qends->endinfo.fileinfo.readq, wait);
39 for(i=CANQUEUE_PRIO_NR;--i>=0;) {
40 if(!list_empty(&qends->active[i]))
41 mask |= POLLIN | POLLRDNORM;
45 if ((file->f_mode & FMODE_WRITE) && !(file->f_flags & O_SYNC)) {
46 poll_wait(file, &qends->endinfo.fileinfo.writeq, wait);
48 spin_lock_irqsave(&qends->ends_lock, flags);
49 list_for_each(entry,&qends->inlist){
50 edge=list_entry(entry,struct canque_edge_t,inpeers);
51 if(canque_fifo_test_fl(&edge->fifo,FULL))
54 spin_unlock_irqrestore(&qends->ends_lock, flags);
57 mask |= POLLOUT | POLLWRNORM;
60 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_SYNC)) {
61 poll_wait(file, &qends->endinfo.fileinfo.emptyq, wait);
63 spin_lock_irqsave(&qends->ends_lock, flags);
64 list_for_each(entry,&qends->inlist){
65 edge=list_entry(entry,struct canque_edge_t,inpeers);
66 if(!canque_fifo_test_fl(&edge->fifo,EMPTY))
69 spin_unlock_irqrestore(&qends->ends_lock, flags);
72 mask |= POLLOUT | POLLWRNORM;