diff mbox

[RFC/RFT,1/5] USB: usbtouch: implement suspend/resume

Message ID 201003121541.31876.oliver@neukum.org
State New, archived
Headers show

Commit Message

Oliver Neukum March 12, 2010, 2:41 p.m. UTC
None
diff mbox

Patch

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,
 };