* Version 0.7 6 Aug 2001
*/
+#define __NO_VERSION__
+#include <linux/module.h>
+
#include <linux/autoconf.h>
#if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
#define MODVERSIONS
#include <linux/modversions.h>
#endif
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#include <linux/malloc.h>
+#else
+#include <linux/slab.h>
+#endif
#include <linux/version.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
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;
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;
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);