All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oliver@neukum.org>
To: Daniel Ritz <daniel.ritz@gmx.ch>
Cc: linux-input@vger.kernel.org, USB list <linux-usb@vger.kernel.org>
Subject: [RFC/RFT 4/5] USB: usbtouch: Autosuspend for the USB touchscreen driver
Date: Fri, 12 Mar 2010 15:43:35 +0100	[thread overview]
Message-ID: <201003121543.35853.oliver@neukum.org> (raw)

>From 0cbb098d3b43787f6f559faaa9d8b93a0ae2123e Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oliver@neukum.org>
Date: Thu, 11 Mar 2010 15:25:26 +0100
Subject: [PATCH 4/5] USB: usbtouch: Autosuspend for the USB touchscreen driver

A primitive resume on open/ suspend on close implementation
of USB autosuspend. Enable remote wakeup for devices that
must be constantly polled.

Signed-off-by: Oliver Neukum <neukum@b1-systems.de>
---
 drivers/input/touchscreen/usbtouchscreen.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

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)
-- 
1.6.4.2


                 reply	other threads:[~2010-03-12 14:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201003121543.35853.oliver@neukum.org \
    --to=oliver@neukum.org \
    --cc=daniel.ritz@gmx.ch \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.