]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
Some problems fixup in RTR read mode in read system-call.
authorppisa <ppisa>
Thu, 1 Jul 2004 01:45:42 +0000 (01:45 +0000)
committerppisa <ppisa>
Thu, 1 Jul 2004 01:45:42 +0000 (01:45 +0000)
This mode is there for compatibility reasons with old driver
version and should be moved to its own IOCTL.

lincan/src/read.c

index fa98bfee8cf43c104dfa0690d99e378101a18db0..efc36418ff1c591595d9b16eae0d7850d93d2ddb 100644 (file)
@@ -68,6 +68,9 @@ inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj,
        struct canmsg_t read_msg;
        
        DEBUGMSG("Remote transmission request\n");
+
+       copy_from_user(&read_msg, buffer, sizeof(struct canmsg_t));
+
        can_spin_lock_irqsave(&hardware_p->rtr_lock, flags);
        if (hardware_p->rtr_queue == NULL) { //No remote messages pending
                new_rtr_entry=(struct rtr_id *)kmalloc(sizeof(struct rtr_id),GFP_ATOMIC);
@@ -98,7 +101,6 @@ inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj,
        interruptible_sleep_on(&new_rtr_entry->rtr_wq);
 
        can_spin_lock_irqsave(&hardware_p->rtr_lock, flags);
-       copy_to_user(buffer, &read_msg, sizeof(struct canmsg_t));
        if (hardware_p->rtr_queue == new_rtr_entry) {
                if (new_rtr_entry->next != NULL) 
                        hardware_p->rtr_queue=new_rtr_entry->next;
@@ -117,6 +119,8 @@ inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj,
        can_spin_unlock_irqrestore(&hardware_p->rtr_lock, flags);
        kfree(new_rtr_entry);
 
+       copy_to_user(buffer, &read_msg, sizeof(struct canmsg_t));
+
        return obj->ret;
 }
 
@@ -154,6 +158,7 @@ ssize_t can_read(struct file *file, char *buffer, size_t length, loff_t *offset)
 
        copy_from_user(&read_msg, buffer, sizeof(struct canmsg_t));
        if (read_msg.flags & MSG_RTR)
+               /* FIXME: RTR processing should go to its own IOCTLs */
                ret = can_rtr_read(chip, obj, buffer);
        else
                ret = can_std_read(file, qends, obj, buffer, length);