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.3 17 Jun 2004
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;
23 struct canque_edge_t *edge;
27 if(!canuser || (canuser->magic != CAN_USER_MAGIC)){
28 CANMSG("can_close: bad canuser magic\n");
32 obj = canuser->msgobj;
33 qends = canuser->qends;
35 if (file->f_mode & FMODE_READ) {
36 poll_wait(file, &qends->endinfo.fileinfo.readq, wait);
37 for(i=CANQUEUE_PRIO_NR;--i>=0;) {
38 if(!list_empty(&qends->active[i]))
39 mask |= POLLIN | POLLRDNORM;
43 if ((file->f_mode & FMODE_WRITE) && !(file->f_flags & O_SYNC)) {
44 poll_wait(file, &qends->endinfo.fileinfo.writeq, wait);
46 canque_for_each_inedge(qends, edge) {
47 if(canque_fifo_test_fl(&edge->fifo,FULL))
52 mask |= POLLOUT | POLLWRNORM;
55 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_SYNC)) {
56 poll_wait(file, &qends->endinfo.fileinfo.emptyq, wait);
58 canque_for_each_inedge(qends, edge) {
59 if(!canque_fifo_test_fl(&edge->fifo,EMPTY))
64 mask |= POLLOUT | POLLWRNORM;