From patchwork Fri Mar 12 14:43:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 85291 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 o2CEhgWf013834 for ; Fri, 12 Mar 2010 14:43:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758196Ab0CLOnl (ORCPT ); Fri, 12 Mar 2010 09:43:41 -0500 Received: from smtp-out003.kontent.com ([81.88.40.217]:34022 "EHLO smtp-out003.kontent.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756632Ab0CLOnk convert rfc822-to-8bit (ORCPT ); Fri, 12 Mar 2010 09:43:40 -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-out003.kontent.com) by smtp-out003.kontent.com (Postfix) with ESMTPSA id 880BE4000205; Fri, 12 Mar 2010 15:43:39 +0100 (CET) To: Daniel Ritz Subject: [RFC/RFT 4/5] USB: usbtouch: Autosuspend for the USB touchscreen driver Cc: linux-input@vger.kernel.org, USB list From: Oliver Neukum Date: Fri, 12 Mar 2010 15:43:35 +0100 MIME-Version: 1.0 Message-Id: <201003121543.35853.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:43:42 +0000 (UTC) diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index f15aa2e..cc0eb7c 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -1269,16 +1269,26 @@ exit: static int usbtouch_open(struct input_dev *input) { struct usbtouch_usb *usbtouch = input_get_drvdata(input); + int r; usbtouch->irq->dev = interface_to_usbdev(usbtouch->interface); + + r = usb_autopm_get_interface(usbtouch->interface); + if (r < 0) + goto err_out; if (!usbtouch->type->irq_always) { if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) - return -EIO; + goto err_out_revert; usbtouch->submitted = true; } return 0; + +err_out_revert: + usb_autopm_put_interface(usbtouch->interface); +err_out: + return -EIO; } static void usbtouch_close(struct input_dev *input) @@ -1288,6 +1298,7 @@ static void usbtouch_close(struct input_dev *input) usbtouch->submitted = false; if (!usbtouch->type->irq_always) usb_kill_urb(usbtouch->irq); + usb_autopm_put_interface(usbtouch->interface); } static int usbtouch_suspend(struct usb_interface *intf, pm_message_t message) @@ -1475,6 +1486,14 @@ static int usbtouch_probe(struct usb_interface *intf, } } + /* + * if the interrupt URB must be kept running + * we assume the device asserts remote wakeup + * if it has data to be retrieved through + * the interrupt endpoint + */ + intf->needs_remote_wakeup = usbtouch->type->irq_always; + return 0; out_unregister_input: @@ -1523,6 +1542,7 @@ static struct usb_driver usbtouch_driver = { .resume = usbtouch_resume, .reset_resume = usbtouch_reset_resume, .id_table = usbtouch_devices, + .supports_autosuspend = 1, }; static int __init usbtouch_init(void)