Skip to content

Commit

Permalink
USB: address FIXME in usbnet w.r.t drivers claiming multiple interfaces
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed May 23, 2007
1 parent 741ec4e commit 3643312
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
25 changes: 15 additions & 10 deletions drivers/net/usb/usbnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,20 +1252,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);
Expand All @@ -1274,8 +1277,10 @@ int usbnet_resume (struct usb_interface *intf)
{
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);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/usb/usbnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct usbnet {
const char *driver_name;
wait_queue_head_t *wait;
struct mutex phy_mutex;
unsigned char suspend_count;

/* i/o info: pipes etc */
unsigned in, out;
Expand Down

0 comments on commit 3643312

Please sign in to comment.