From patchwork Fri Mar 12 14:41:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 85287 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2CEfc9v013169 for ; Fri, 12 Mar 2010 14:41:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757741Ab0CLOlh (ORCPT ); Fri, 12 Mar 2010 09:41:37 -0500 Received: from smtp-out002.kontent.com ([81.88.40.216]:48147 "EHLO smtp-out002.kontent.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756373Ab0CLOlh convert rfc822-to-8bit (ORCPT ); Fri, 12 Mar 2010 09:41:37 -0500 Received: from vanamonde.localnet (p549A1C46.dip0.t-ipconnect.de [84.154.28.70]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: neukum_org@smtp-out002.kontent.com) by smtp-out002.kontent.com (Postfix) with ESMTPSA id 4FF2A5802D59; Fri, 12 Mar 2010 15:41:36 +0100 (CET) To: Daniel Ritz Subject: [RFC/RFT 1/5] USB: usbtouch: implement suspend/resume Cc: linux-input@vger.kernel.org, USB list From: Oliver Neukum Date: Fri, 12 Mar 2010 15:41:31 +0100 MIME-Version: 1.0 Message-Id: <201003121541.31876.oliver@neukum.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 12 Mar 2010 14:41:38 +0000 (UTC) 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, };