X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/f419961de4a8e818c602b0642492ce76dd5bf979..3c47a7cd435662f7e2daa006596722271f5dd090:/lincan/src/ioctl_remote.c diff --git a/lincan/src/ioctl_remote.c b/lincan/src/ioctl_remote.c index cabc2fc..8c3dd77 100644 --- a/lincan/src/ioctl_remote.c +++ b/lincan/src/ioctl_remote.c @@ -46,8 +46,9 @@ int can_ioctl_remote_read(struct canuser_t *canuser, struct canmsg_t *rtr_msg, struct rtr_id *rtr_current, *new_rtr_entry; struct msgobj_t *obj; struct canchip_t *chip; + int err; /*struct canque_ends_t *qends;*/ - + DEBUGMSG("Remote transmission request\n"); /*qends = canuser->qends;*/ @@ -69,7 +70,7 @@ int can_ioctl_remote_read(struct canuser_t *canuser, struct canmsg_t *rtr_msg, if (hardware_p->rtr_queue == NULL) { //No remote messages pending new_rtr_entry=(struct rtr_id *)kmalloc(sizeof(struct rtr_id),GFP_ATOMIC); if (new_rtr_entry == NULL) { - can_spin_unlock_irqrestore(&hardware_p->rtr_lock, + can_spin_unlock_irqrestore(&hardware_p->rtr_lock, flags); return -ENOMEM; } @@ -84,6 +85,7 @@ int can_ioctl_remote_read(struct canuser_t *canuser, struct canmsg_t *rtr_msg, } init_waitqueue_head(&new_rtr_entry->rtr_wq); new_rtr_entry->id = rtr_id; + new_rtr_entry->ready_fl = 0; new_rtr_entry->rtr_message = rtr_msg; new_rtr_entry->next=NULL; @@ -92,11 +94,12 @@ int can_ioctl_remote_read(struct canuser_t *canuser, struct canmsg_t *rtr_msg, /* Send remote transmission request */ chip->chipspecops->remote_request(chip,obj); obj->ret = 0; - interruptible_sleep_on(&new_rtr_entry->rtr_wq); + + err = wait_event_interruptible(new_rtr_entry->rtr_wq, new_rtr_entry->ready_fl); can_spin_lock_irqsave(&hardware_p->rtr_lock, flags); if (hardware_p->rtr_queue == new_rtr_entry) { - if (new_rtr_entry->next != NULL) + if (new_rtr_entry->next != NULL) hardware_p->rtr_queue=new_rtr_entry->next; else hardware_p->rtr_queue=NULL; @@ -113,6 +116,9 @@ int can_ioctl_remote_read(struct canuser_t *canuser, struct canmsg_t *rtr_msg, can_spin_unlock_irqrestore(&hardware_p->rtr_lock, flags); kfree(new_rtr_entry); + if (err) + return -EINTR; + return obj->ret; }