>From fd33bdb2357c439c8e4b1435bfd8c7dc77ac4da8 Mon Sep 17 00:00:00 2001 From: Oliver Neukum <oliver@xxxxxxxxxx> Date: Thu, 11 Mar 2010 14:45:18 +0100 Subject: [PATCH 1/5] USB: usbtouch: implement suspend/resume A standard implementation of suspend/resume. Cease IO on suspend(). Restart on resume() if necessary. Signed-off-by: Oliver Neukum <neukum@xxxxxxxxxxxxx> --- drivers/input/touchscreen/usbtouchscreen.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 99330bb..6db0a03 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -115,6 +115,7 @@ struct usbtouch_usb { int x, y; int touch, press; + bool submitted; }; @@ -1274,6 +1275,7 @@ static int usbtouch_open(struct input_dev *input) if (!usbtouch->type->irq_always) { if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) return -EIO; + usbtouch->submitted = true; } return 0; @@ -1283,10 +1285,30 @@ static void usbtouch_close(struct input_dev *input) { struct usbtouch_usb *usbtouch = input_get_drvdata(input); + usbtouch->submitted = false; if (!usbtouch->type->irq_always) usb_kill_urb(usbtouch->irq); } +static int usbtouch_suspend(struct usb_interface *intf, pm_message_t message) +{ + struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); + + usb_kill_urb(usbtouch->irq); + + return 0; +} + +static int usbtouch_resume(struct usb_interface *intf) +{ + struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); + int rv = 0; + + if (usbtouch->submitted || usbtouch->type->irq_always) + rv = usb_submit_urb(usbtouch->irq, GFP_NOIO); + + return rv; +} static void usbtouch_free_buffers(struct usb_device *udev, struct usbtouch_usb *usbtouch) @@ -1477,6 +1499,8 @@ static struct usb_driver usbtouch_driver = { .name = "usbtouchscreen", .probe = usbtouch_probe, .disconnect = usbtouch_disconnect, + .suspend = usbtouch_suspend, + .resume = usbtouch_resume, .id_table = usbtouch_devices, }; -- 1.6.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html