Re: [PATCH] Linux joydev joystick disconnect patch 2.6.11-rc2

From: Vojtech Pavlik
Date: Mon Feb 07 2005 - 07:21:17 EST


On Sun, Feb 06, 2005 at 08:21:13PM -0500, Dmitry Torokhov wrote:
> > > Opening braces should go on the same line as the statement (if (...) {).
> >  
> > How about this patch?
>
> Looks fine now. Hmm, wait a sec... Don't we also need kill_fasync calls in
> disconnect routines as well?

This should do it:


ChangeSet@xxxxxx, 2005-02-07 13:19:59+01:00, vojtech@xxxxxxx
input: Do a kill_fasync() in input handlers on device disconnect
to notify a client using poll() that the device is gone.

Signed-off-by: Vojtech Pavlik <vojtech@xxxxxxx>


evdev.c | 3 +++
joydev.c | 3 +++
mousedev.c | 3 +++
tsdev.c | 3 +++
4 files changed, 12 insertions(+)


diff -Nru a/drivers/input/evdev.c b/drivers/input/evdev.c
--- a/drivers/input/evdev.c 2005-02-07 13:20:15 +01:00
+++ b/drivers/input/evdev.c 2005-02-07 13:20:15 +01:00
@@ -440,6 +440,7 @@
static void evdev_disconnect(struct input_handle *handle)
{
struct evdev *evdev = handle->private;
+ struct evdev_list *list;

class_simple_device_remove(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
devfs_remove("input/event%d", evdev->minor);
@@ -448,6 +449,8 @@
if (evdev->open) {
input_close_device(handle);
wake_up_interruptible(&evdev->wait);
+ list_for_each_entry(list, &evdev->list, node)
+ kill_fasync(&list->fasync, SIGIO, POLLHUP | POLLERR);
} else
evdev_free(evdev);
}
diff -Nru a/drivers/input/joydev.c b/drivers/input/joydev.c
--- a/drivers/input/joydev.c 2005-02-07 13:20:15 +01:00
+++ b/drivers/input/joydev.c 2005-02-07 13:20:15 +01:00
@@ -462,6 +462,7 @@
static void joydev_disconnect(struct input_handle *handle)
{
struct joydev *joydev = handle->private;
+ struct joydev_list *list;

class_simple_device_remove(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
devfs_remove("input/js%d", joydev->minor);
@@ -470,6 +471,8 @@
if (joydev->open) {
input_close_device(handle);
wake_up_interruptible(&joydev->wait);
+ list_for_each_entry(list, &joydev->list, node)
+ kill_fasync(&list->fasync, SIGIO, POLLHUP | POLLERR);
} else
joydev_free(joydev);
}
diff -Nru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
--- a/drivers/input/mousedev.c 2005-02-07 13:20:15 +01:00
+++ b/drivers/input/mousedev.c 2005-02-07 13:20:15 +01:00
@@ -652,6 +652,7 @@
static void mousedev_disconnect(struct input_handle *handle)
{
struct mousedev *mousedev = handle->private;
+ struct mousedev_list *list;

class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
devfs_remove("input/mouse%d", mousedev->minor);
@@ -660,6 +661,8 @@
if (mousedev->open) {
input_close_device(handle);
wake_up_interruptible(&mousedev->wait);
+ list_for_each_entry(list, &mousedev->list, node)
+ kill_fasync(&list->fasync, SIGIO, POLLHUP | POLLERR);
} else {
if (mousedev_mix.open)
input_close_device(handle);
diff -Nru a/drivers/input/tsdev.c b/drivers/input/tsdev.c
--- a/drivers/input/tsdev.c 2005-02-07 13:20:15 +01:00
+++ b/drivers/input/tsdev.c 2005-02-07 13:20:15 +01:00
@@ -424,6 +424,7 @@
static void tsdev_disconnect(struct input_handle *handle)
{
struct tsdev *tsdev = handle->private;
+ struct tsdev_list *list;

class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
devfs_remove("input/ts%d", tsdev->minor);
@@ -433,6 +434,8 @@
if (tsdev->open) {
input_close_device(handle);
wake_up_interruptible(&tsdev->wait);
+ list_for_each_entry(list, &tsdev->list, node)
+ kill_fasync(&list->fasync, SIGIO, POLLHUP | POLLERR);
} else
tsdev_free(tsdev);
}

--
Vojtech Pavlik
SuSE Labs, SuSE CR
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/