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;
......
......@@ -19,18 +19,18 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* Should you need to contact me, the author, you can do so either by
* e-mail - mail your message to <jsimmons@infradead.org>.
*/
......@@ -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