Re: [patch]address FIXME in usbnet w.r.t drivers claiming multiple interfaces

Oliver Neukum <[email protected]>
Newsgroups gmane.linux.usb.devel
Organization Novell
Message-ID <[email protected]>
Am Donnerstag, 26. April 2007 20:40 schrieb David Brownell:
> On Thursday 26 April 2007, Oliver Neukum wrote:
> > Hi,
> > 
> > this fixes the issue of drivers claiming multiple interfaces. Operations
> > are stopped as soon as an interface is suspend and resumed only as
> > all interfaces have been resumed. This patch is relative to the last one
> > I sent you yesterday.
> 
> You know, if the two patches were ordered the other way around I could
> sign off on this one right away ...

As you like it. This is the patch to handle suspend for minidrivers that claim
more than one interface against the vanilla kernel.

	Regards
		Oliver
Signed-off-by: Oliver Neukum <[email protected]>
-- 

--- a/drivers/usb/net/usbnet.h	2007-04-27 10:01:25.000000000 +0200
+++ b/drivers/usb/net/usbnet.h	2007-04-27 10:02:04.000000000 +0200
@@ -31,6 +31,7 @@ struct usbnet {
 	struct driver_info	*driver_info;
 	wait_queue_head_t	*wait;
 	struct mutex		phy_mutex;
+	unsigned char		suspend_count;
 
 	/* i/o info: pipes etc */
 	unsigned		in, out;
--- a/drivers/usb/net/usbnet.c	2007-04-27 10:01:18.000000000 +0200
+++ b/drivers/usb/net/usbnet.c	2007-04-27 10:03:28.000000000 +0200
@@ -1251,20 +1251,23 @@ EXPORT_SYMBOL_GPL(usbnet_probe);
 
 /*-------------------------------------------------------------------------*/
 
-/* FIXME these suspend/resume methods assume non-CDC style
- * devices, with only one interface.
+/* 
+ * suspend the whole driver as soon as the first interface is suspended
+ * resume only when the last interface is resumed
  */
 
 int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
 {
 	struct usbnet		*dev = usb_get_intfdata(intf);
 
-	/* accelerate emptying of the rx and queues, to avoid
-	 * having everything error out.
-	 */
-	netif_device_detach (dev->net);
-	(void) unlink_urbs (dev, &dev->rxq);
-	(void) unlink_urbs (dev, &dev->txq);
+	if (!dev->suspend_count++) {
+		/* accelerate emptying of the rx and queues, to avoid
+		 * having everything error out.
+		 */
+		netif_device_detach (dev->net);
+		(void) unlink_urbs (dev, &dev->rxq);
+		(void) unlink_urbs (dev, &dev->txq);
+	}
 	return 0;
 }
 EXPORT_SYMBOL_GPL(usbnet_suspend);
@@ -1273,8 +1276,10 @@ int usbnet_resume (struct usb_interface 
 {
 	struct usbnet		*dev = usb_get_intfdata(intf);
 
-	netif_device_attach (dev->net);
-	tasklet_schedule (&dev->bh);
+	if (!--dev->suspend_count) {
+		netif_device_attach (dev->net);
+		tasklet_schedule (&dev->bh);
+	}
 	return 0;
 }
 EXPORT_SYMBOL_GPL(usbnet_resume);


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.