X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/4cf24de229090b1ab6279570a564d224e13dd706..786c7d54e8d820e89997e507c29ea716c0d55fd9:/lincan/src/read.c diff --git a/lincan/src/read.c b/lincan/src/read.c index 4e02801..1111401 100644 --- a/lincan/src/read.c +++ b/lincan/src/read.c @@ -5,6 +5,9 @@ * Version 0.7 6 Aug 2001 */ +#define __NO_VERSION__ +#include + #include #if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS) #define MODVERSIONS @@ -14,7 +17,12 @@ #include #endif +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) #include +#else +#include +#endif #include #include #include @@ -45,8 +53,8 @@ inline ssize_t can_std_read(struct file *file, struct canfifo_t *fifo, return -EINTR; } if (!can_timeout) { - DEBUGMSG("Rx timeout\n"); - return -EIO; + DEBUGMSG("no data received\n"); + return 0; } if (obj->ret < 0) return obj->ret; @@ -62,14 +70,24 @@ inline ssize_t can_std_read(struct file *file, struct canfifo_t *fifo, bytes_to_copy = (length < bytes_avail) ? length : bytes_avail; ret = bytes_to_copy; + /* printk(KERN_CRIT "can RxFIFO b:%x e:%x bs:%x msg:%x rp:%x wp:%x btc:%x\n", + fifo->buf_rx_entry, fifo->buf_rx_entry+MAX_BUF_LENGTH, + fifo->rx_size, sizeof(struct canmsg_t), + fifo->rx_readp, fifo->rx_writep, bytes_to_copy); */ + + /* Copy the data to user space */ while (bytes_to_copy > 0) { + + copy_to_user(buffer, fifo->rx_readp, sizeof(struct canmsg_t)); buffer += sizeof(struct canmsg_t); bytes_to_copy -= sizeof(struct canmsg_t); fifo->rx_readp++; if (fifo->rx_readp >= fifo->buf_rx_entry + MAX_BUF_LENGTH) fifo->rx_readp = fifo->buf_rx_entry; + + /* printk(KERN_CRIT "can RxFIFO rp%x\n",fifo->rx_readp); */ } return ret; @@ -101,7 +119,7 @@ inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj, new_rtr_entry=(struct rtr_id *)kmalloc(sizeof(struct rtr_id),GFP_ATOMIC); rtr_current->next=new_rtr_entry; } -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19)) +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0)) init_waitqueue(&new_rtr_entry->rtr_wq); #else init_waitqueue_head(&new_rtr_entry->rtr_wq);