Re: autosuspend for asix driver

David Brownell <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Wednesday 01 August 2007, Oliver Neukum wrote:
> Am Dienstag 31 Juli 2007 schrieb Alan Stern:
> > You assign dev->intf in both the usbnet framework driver and the
> > subdriver.  Could the subdriver's assignment be removed?
> 
> Here we go again.
> 
> 	Regards
> 		Oliver
> Signed-off-by: Oliver Neukum <[email protected]>

You know that drivers/net/usb patches go to the netdev list, right?
They merge through the network queue, not the USB queue.

This looks plausible to me, except

	/* multi-line comments
	 * in the code
	 * should not end like this: */

	/* do it like this, with
	 * nice clean line endings:
	 */


> ---
> 
> --- a/drivers/net/usb/asix.c	2007-07-30 14:18:38.000000000 +0200
> +++ b/drivers/net/usb/asix.c	2007-08-01 09:48:10.000000000 +0200
> @@ -1474,6 +1474,7 @@ static struct usb_driver asix_driver = {
>  	.suspend =	usbnet_suspend,
>  	.resume =	usbnet_resume,
>  	.disconnect =	usbnet_disconnect,
> +	.supports_autosuspend = 1,
>  };
>  
>  static int __init asix_init(void)
> --- a/drivers/net/usb/usbnet.h	2007-07-30 14:23:08.000000000 +0200
> +++ b/drivers/net/usb/usbnet.h	2007-07-31 11:08:12.000000000 +0200
> @@ -28,6 +28,7 @@
>  struct usbnet {
>  	/* housekeeping */
>  	struct usb_device	*udev;
> +	struct usb_interface	*intf;
>  	struct driver_info	*driver_info;
>  	const char		*driver_name;
>  	wait_queue_head_t	*wait;
> --- a/drivers/net/usb/usbnet.c	2007-07-30 14:27:40.000000000 +0200
> +++ b/drivers/net/usb/usbnet.c	2007-07-31 11:07:51.000000000 +0200
> @@ -590,6 +590,7 @@ static int usbnet_stop (struct net_devic
>  	dev->flags = 0;
>  	del_timer_sync (&dev->delay);
>  	tasklet_kill (&dev->bh);
> +	usb_autopm_put_interface(dev->intf);
>  
>  	return 0;
>  }
> @@ -603,9 +604,19 @@ static int usbnet_stop (struct net_devic
>  static int usbnet_open (struct net_device *net)
>  {
>  	struct usbnet		*dev = netdev_priv(net);
> -	int			retval = 0;
> +	int			retval;
>  	struct driver_info	*info = dev->driver_info;
>  
> +	if ((retval = usb_autopm_get_interface(dev->intf)) < 0) {
> +		if (netif_msg_ifup (dev))
> +			devinfo (dev,
> +				"resumption fail (%d) usbnet usb-%s-%s, %s",
> +				retval,
> +				dev->udev->bus->bus_name, dev->udev->devpath,
> +			info->description);
> +		goto done_nopm;
> +	}
> +
>  	// put into "known safe" state
>  	if (info->reset && (retval = info->reset (dev)) < 0) {
>  		if (netif_msg_ifup (dev))
> @@ -659,7 +670,10 @@ static int usbnet_open (struct net_devic
>  
>  	// delay posting reads until we're fully open
>  	tasklet_schedule (&dev->bh);
> +	return retval;
>  done:
> +	usb_autopm_put_interface(dev->intf);
> +done_nopm:
>  	return retval;
>  }
>  
> @@ -1143,6 +1157,7 @@ usbnet_probe (struct usb_interface *udev
>  
>  	dev = netdev_priv(net);
>  	dev->udev = xdev;
> +	dev->intf = udev;
>  	dev->driver_info = info;
>  	dev->driver_name = name;
>  	dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV
> @@ -1273,6 +1288,9 @@ int usbnet_suspend (struct usb_interface
>  		netif_device_detach (dev->net);
>  		(void) unlink_urbs (dev, &dev->rxq);
>  		(void) unlink_urbs (dev, &dev->txq);
> +		/* reattach so runtime management can use and
> +		 * wake the device */
> +		netif_device_attach (dev->net);
>  	}
>  	return 0;
>  }
> @@ -1282,10 +1300,9 @@ int usbnet_resume (struct usb_interface 
>  {
>  	struct usbnet		*dev = usb_get_intfdata(intf);
>  
> -	if (!--dev->suspend_count) {
> -		netif_device_attach (dev->net);
> +	if (!--dev->suspend_count)
>  		tasklet_schedule (&dev->bh);
> -	}
> +
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(usbnet_resume);
> 



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
[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.