--- /dev/null
+/* select.c
+ * Header file for the Linux CAN-bus driver.
+ * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
+ * This software is released under the GPL-License.
+ * Version 0.7.1-pi2 15 Nov 2002
+ *
+ * added by Pavel Pisa pisa@cmp.felk.cvut.cz
+ */
+
+#include <linux/autoconf.h>
+#if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
+#define MODVERSIONS
+#endif
+
+#if defined (MODVERSIONS)
+#include <linux/modversions.h>
+#endif
+
+#include <linux/version.h>
+#include <linux/poll.h>
+
+#include "../include/main.h"
+#include "../include/select.h"
+
+unsigned int can_poll(struct file *file, poll_table *wait)
+{
+ unsigned int mask = 0;
+ struct msgobj_t *obj;
+ struct canfifo_t *fifo;
+
+ /* Initialize hardware pointers */
+ if ( (obj = objects_p[MINOR_NR]) == NULL) {
+ CANMSG("Could not assign buffer structure\n");
+ return 0;
+ }
+ if ( (fifo = obj->fifo) == NULL) {
+ CANMSG("Could not assign buffer memory.\n");
+ return 0;
+ }
+
+ if (file->f_mode & FMODE_WRITE) {
+ poll_wait(file, &fifo->writeq, wait);
+ }
+ if (file->f_mode & FMODE_READ) {
+ poll_wait(file, &fifo->readq, wait);
+ }
+ if ((file->f_mode & FMODE_READ)&&
+ (fifo->rx_readp != fifo->rx_writep)) {
+ mask |= POLLIN | POLLRDNORM;
+ }
+ if ((file->f_mode & FMODE_WRITE)&&
+ (fifo->tx_readp == fifo->tx_writep)) {
+ mask |= POLLOUT | POLLWRNORM;
+ }
+ return mask;
+}