- /* 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;
-
- /* 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);
+