From patchwork Wed Nov 25 21:55:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 63010 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAPLpJP8024916 for ; Wed, 25 Nov 2009 21:55:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932108AbZKYVzI (ORCPT ); Wed, 25 Nov 2009 16:55:08 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756136AbZKYVzI (ORCPT ); Wed, 25 Nov 2009 16:55:08 -0500 Received: from smtp-out003.kontent.com ([81.88.40.217]:45454 "EHLO smtp-out003.kontent.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755953AbZKYVzH (ORCPT ); Wed, 25 Nov 2009 16:55:07 -0500 Received: from vanamonde.localnet (p549A1FC7.dip0.t-ipconnect.de [84.154.31.199]) (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 7EFA64000265; Wed, 25 Nov 2009 22:55:13 +0100 (CET) From: Oliver Neukum To: daniel.ritz@gmx.ch, Ondrej Zary , linux-input@vger.kernel.org, "linux-usb@vger.kernel.org" Subject: [rft]basic power management methods for usbtouch Date: Wed, 25 Nov 2009 22:55:13 +0100 User-Agent: KMail/1.12.2 (Linux/2.6.32-rc6-0.1-default; KDE/4.3.1; x86_64; ; ) MIME-Version: 1.0 Message-Id: <200911252255.13060.oliver@neukum.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 68ece58..28e30af 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -946,6 +946,52 @@ static void usbtouch_close(struct input_dev *input) 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); + struct input_dev *input = usbtouch->input; + int result = 0; + + mutex_lock(&input->mutex); + if (input->users) + result = usb_submit_urb(usbtouch->irq, GFP_NOIO); + mutex_unlock(&input->mutex); + return result; +} + +static int usbtouch_reset_resume(struct usb_interface *intf) +{ + struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); + struct input_dev *input = usbtouch->input; + int err = 0; + + /* reinit the device */ + if (usbtouch->type->init) { + err = usbtouch->type->init(usbtouch); + if (err) { + dbg("%s - type->init() failed, err: %d", + __func__, err); + return err; + } + } + + /* restart IO if needed */ + mutex_lock(&input->mutex); + if (input->users) + err = usb_submit_urb(usbtouch->irq, GFP_NOIO); + mutex_unlock(&input->mutex); + + return err; +} static void usbtouch_free_buffers(struct usb_device *udev, struct usbtouch_usb *usbtouch) @@ -1100,6 +1146,9 @@ static struct usb_driver usbtouch_driver = { .name = "usbtouchscreen", .probe = usbtouch_probe, .disconnect = usbtouch_disconnect, + .suspend = usbtouch_suspend, + .resume = usbtouch_resume, + .reset_resume = usbtouch_reset_resume, .id_table = usbtouch_devices, };