Commit e144c08e authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: fix reader wakeup conditions in mousedev, joydev and tsdev

       (we want readers to wake up when underlying device is gone
        so they would get -ENODEV and close the device).
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 41b701f9
......@@ -232,8 +232,10 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo
&& list->head == list->tail && (file->f_flags & O_NONBLOCK))
return -EAGAIN;
retval = wait_event_interruptible(list->joydev->wait, list->joydev->exist
&& (list->startup < joydev->nabs + joydev->nkey || list->head != list->tail));
retval = wait_event_interruptible(list->joydev->wait,
!list->joydev->exist ||
list->startup < joydev->nabs + joydev->nkey ||
list->head != list->tail);
if (retval)
return retval;
......
......@@ -524,11 +524,15 @@ static ssize_t mousedev_read(struct file * file, char __user * buffer, size_t co
if (!list->ready && !list->buffer && (file->f_flags & O_NONBLOCK))
return -EAGAIN;
retval = wait_event_interruptible(list->mousedev->wait, list->ready || list->buffer);
retval = wait_event_interruptible(list->mousedev->wait,
!list->mousedev->exist || list->ready || list->buffer);
if (retval)
return retval;
if (!list->mousedev->exist)
return -ENODEV;
if (!list->buffer && list->ready) {
mousedev_packet(list, list->ps2);
list->buffer = list->bufsiz;
......
......@@ -210,7 +210,7 @@ static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count,
return -EAGAIN;
retval = wait_event_interruptible(list->tsdev->wait,
(list->head != list->tail) && list->tsdev->exist);
list->head != list->tail || !list->tsdev->exist);
if (retval)
return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment