From e9496746cc0954c43720de0c88fef95a9d229baa Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Tue, 23 Aug 2011 22:57:00 -0700 Subject: Input: wacom_w8001 - implement open and close Implement open() and close() methods for the input device so that we do not start the device unless there are users listening to the events. Acked-by: Chris Bagwell Tested-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/wacom_w8001.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'drivers/input/touchscreen/wacom_w8001.c') diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index c14412ef4648..5ece6c1f3296 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c @@ -367,6 +367,20 @@ static int w8001_command(struct w8001 *w8001, unsigned char command, return rc; } +static int w8001_open(struct input_dev *dev) +{ + struct w8001 *w8001 = input_get_drvdata(dev); + + return w8001_command(w8001, W8001_CMD_START, false); +} + +static void w8001_close(struct input_dev *dev) +{ + struct w8001 *w8001 = input_get_drvdata(dev); + + w8001_command(w8001, W8001_CMD_STOP, false); +} + static int w8001_setup(struct w8001 *w8001) { struct input_dev *dev = w8001->dev; @@ -474,7 +488,7 @@ static int w8001_setup(struct w8001 *w8001) strlcat(w8001->name, " Touchscreen", sizeof(w8001->name)); - return w8001_command(w8001, W8001_CMD_START, false); + return 0; } /* @@ -534,6 +548,11 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv) input_dev->id.version = 0x0100; input_dev->dev.parent = &serio->dev; + input_dev->open = w8001_open; + input_dev->close = w8001_close; + + input_set_drvdata(input_dev, w8001); + err = input_register_device(w8001->dev); if (err) goto fail3; -- cgit v1.2.3 From 66fd9385ee9c582ee88031ba5028748cb38c986d Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Tue, 23 Aug 2011 22:57:00 -0700 Subject: Input: wacom_w8001 - simplify w8001_remove Since touchscreen driver does not handle any events to be sent to the device we can close serio port first and then unregister the input device. Tested-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/wacom_w8001.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/input/touchscreen/wacom_w8001.c') diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index 5ece6c1f3296..1f42d91f755b 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c @@ -499,12 +499,12 @@ static void w8001_disconnect(struct serio *serio) { struct w8001 *w8001 = serio_get_drvdata(serio); - input_get_device(w8001->dev); - input_unregister_device(w8001->dev); serio_close(serio); - serio_set_drvdata(serio, NULL); - input_put_device(w8001->dev); + + input_unregister_device(w8001->dev); kfree(w8001); + + serio_set_drvdata(serio, NULL); } /* -- cgit v1.2.3