- /* Calculate available bytes in the buffer */
- cli();
- bytes_avail = ((int)fifo->rx_readp < (int)fifo->rx_writep) ?
- ((int)fifo->rx_writep - (int)fifo->rx_readp) :
- ((int)fifo->rx_writep - (int)fifo->rx_readp +
- (int)fifo->rx_size);
- sti();
-
- 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 */
+
+ copy_to_user(buffer, &slot->msg, sizeof(struct canmsg_t));
+ canque_free_outslot(qends, qedge, slot);
+ buffer += sizeof(struct canmsg_t);
+ bytes_to_copy = length-sizeof(struct canmsg_t);
+