Thread (1 message) 1 message, 1 author, 2008-06-27

Re: [rft]power management for usbtouch

From: Ville Syrjälä <hidden>
Date: 2008-06-27 20:51:47

On Fri, Jun 27, 2008 at 10:41:20PM +0200, Oliver Neukum wrote:
Am Freitag 27 Juni 2008 22:20:27 schrieb Ville Syrjälä:
quoted
On Fri, Jun 27, 2008 at 09:07:13PM +0200, Oliver Neukum wrote:
quoted
Am Freitag 27 Juni 2008 18:10:36 schrieb Ville Syrjälä:
quoted
On Fri, Jun 27, 2008 at 10:50:00AM +0200, Oliver Neukum wrote:
quoted
@@ -820,20 +824,34 @@ exit:
 static int usbtouch_open(struct input_dev *input)
 {
 	struct usbtouch_usb *usbtouch = input_get_drvdata(input);
+	int rv;
 
+	rv = usb_autopm_get_interface(usbtouch->intf);
+	if (rv < 0)
+		goto bail;
+	mutex_lock(&usbtouch->lock);
 	usbtouch->irq->dev = usbtouch->udev;
 
-	if (usb_submit_urb(usbtouch->irq, GFP_KERNEL))
-		return -EIO;
-
-	return 0;
+	if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) {
+		rv = -EIO;
+		usb_autopm_put_interface(usbtouch->intf);
+	} else {
+		usbtouch->open = 1;
+	}
+	mutex_unlock(&usbtouch->lock);
+bail:
+	return rv;
 }
What if the device is already suspended when open() is called?
It cannot be. usb_autopm_get_interface() is called, which will resume
the device.
Ah, so it resumes the device even if it was not autosuspended but
suspended for another reason?
The other reason is either system wide, in which case nobody can call open,
or it is forcibly suspended via sysfs, causing usb_submit_urb() to fail later
on.
Which will also fail the open() itself. Isn't that bad? That is, you can
suspend an already open device without the users the device noticing
but you can't open it if you happen to suspend it at just the right time.
That doesn't strike me as good behaviour for a driver.

-- 
Ville Syrjälä
syrjala-ORSVBvAovxo@public.gmane.org
http://www.sci.fi/~syrjala/
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help