From patchwork Mon Jun 7 13:13:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 104770 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 o57DDIQ8021888 for ; Mon, 7 Jun 2010 13:13:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754388Ab0FGNNY (ORCPT ); Mon, 7 Jun 2010 09:13:24 -0400 Received: from cantor.suse.de ([195.135.220.2]:40337 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752729Ab0FGNNX convert rfc822-to-8bit (ORCPT ); Mon, 7 Jun 2010 09:13:23 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id E9ADD93987; Mon, 7 Jun 2010 15:13:22 +0200 (CEST) From: Oliver Neukum Organization: SUSE To: linux-input@vger.kernel.org Subject: [PATCH 2/3] usbtouchscreen: Implement runtime power management Date: Mon, 7 Jun 2010 15:13:42 +0200 User-Agent: KMail/1.12.4 (Linux/2.6.34-rc6-0.1-default; KDE/4.3.5; x86_64; ; ) Cc: linux-usb@vger.kernel.org, Daniel Ritz MIME-Version: 1.0 Message-Id: <201006071513.42714.oneukum@suse.de> 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]); Mon, 07 Jun 2010 13:13:25 +0000 (UTC) diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 6d23c0e..0c2d7c1 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -1263,6 +1263,7 @@ static void usbtouch_irq(struct urb *urb) usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length); exit: + usb_mark_last_busy(interface_to_usbdev(usbtouch->interface)); retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) err("%s - usb_submit_urb failed with result: %d", @@ -1272,23 +1273,39 @@ 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) ? -EIO : 0; + if (r < 0) + goto out; + if (!usbtouch->type->irq_always) { - if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) - return -EIO; + if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) { + r = -EIO; + goto out_put; + } } - return 0; + usbtouch->interface->needs_remote_wakeup = 1; +out_put: + usb_autopm_put_interface(usbtouch->interface); +out: + return r; } static void usbtouch_close(struct input_dev *input) { struct usbtouch_usb *usbtouch = input_get_drvdata(input); + int r; if (!usbtouch->type->irq_always) usb_kill_urb(usbtouch->irq); + r = usb_autopm_get_interface(usbtouch->interface); + usbtouch->interface->needs_remote_wakeup = 0; + if (!r) + usb_autopm_put_interface(usbtouch->interface); } static int usbtouch_suspend @@ -1505,6 +1522,7 @@ static struct usb_driver usbtouch_driver = { .suspend = usbtouch_suspend, .resume = usbtouch_resume, .id_table = usbtouch_devices, + .supports_autosuspend = 1, }; static int __init usbtouch_init(void)