Re: [PATCH] USB: cleanup the handling of the PM complete call (v2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 11 Jan 2012, Oliver Neukum wrote:

> From 0e0fb10cc75c3f8d60aef9a8fa68ef9b56b86984 Mon Sep 17 00:00:00 2001
> From: Oliver Neukum <oliver@xxxxxxxxxx>
> Date: Wed, 11 Jan 2012 08:37:11 +0100
> Subject: [PATCH] USB: cleanup the handling of the PM complete call
> 
> This eliminates the last instance of a function's behavior
> controlled by a parameter as Linus hates such things.
> 
> Signed-off-by: Oliver Neukum <oneukum@xxxxxxx>

Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

> ---
>  drivers/usb/core/driver.c |   37 ++++++++++++++++++++-----------------
>  drivers/usb/core/usb.c    |    2 +-
>  drivers/usb/core/usb.h    |    1 +
>  3 files changed, 22 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index 57498e2..0c7e85b 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -1330,34 +1330,37 @@ int usb_suspend(struct device *dev, pm_message_t msg)
>  }
>  
>  /* The device lock is held by the PM core */
> -int usb_resume(struct device *dev, pm_message_t msg)
> +int usb_resume_complete(struct device *dev)
>  {
> -	struct usb_device	*udev = to_usb_device(dev);
> -	int			status;
> +	struct usb_device *udev = to_usb_device(dev);
>  
>  	/* For PM complete calls, all we do is rebind interfaces
>  	 * whose needs_binding flag is set
>  	 */
> -	if (msg.event == PM_EVENT_ON) {
> -		if (udev->state != USB_STATE_NOTATTACHED)
> -			do_rebind_interfaces(udev);
> -		status = 0;
> +	if (udev->state != USB_STATE_NOTATTACHED)
> +		do_rebind_interfaces(udev);
> +	return 0;
> +}
>  
> -	/* For all other calls, take the device back to full power and
> +/* The device lock is held by the PM core */
> +int usb_resume(struct device *dev, pm_message_t msg)
> +{
> +	struct usb_device	*udev = to_usb_device(dev);
> +	int			status;
> +
> +	/* For all calls, take the device back to full power and
>  	 * tell the PM core in case it was autosuspended previously.
>  	 * Unbind the interfaces that will need rebinding later,
>  	 * because they fail to support reset_resume.
>  	 * (This can't be done in usb_resume_interface()
> -         * above because it doesn't own the right set of locks.)
> +	 * above because it doesn't own the right set of locks.)
>  	 */
> -	} else {
> -		status = usb_resume_both(udev, msg);
> -		if (status == 0) {
> -			pm_runtime_disable(dev);
> -			pm_runtime_set_active(dev);
> -			pm_runtime_enable(dev);
> -			unbind_no_reset_resume_drivers_interfaces(udev);
> -		}
> +	status = usb_resume_both(udev, msg);
> +	if (status == 0) {
> +		pm_runtime_disable(dev);
> +		pm_runtime_set_active(dev);
> +		pm_runtime_enable(dev);
> +		unbind_no_reset_resume_drivers_interfaces(udev);
>  	}
>  
>  	/* Avoid PM error messages for devices disconnected while suspended
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 73cd900..9260434 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -274,7 +274,7 @@ static int usb_dev_prepare(struct device *dev)
>  static void usb_dev_complete(struct device *dev)
>  {
>  	/* Currently used only for rebinding interfaces */
> -	usb_resume(dev, PMSG_ON);	/* FIXME: change to PMSG_COMPLETE */
> +	usb_resume_complete(dev);
>  }
>  
>  static int usb_dev_suspend(struct device *dev)
> diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
> index 3888778..9aa2422 100644
> --- a/drivers/usb/core/usb.h
> +++ b/drivers/usb/core/usb.h
> @@ -56,6 +56,7 @@ extern void usb_major_cleanup(void);
>  
>  extern int usb_suspend(struct device *dev, pm_message_t msg);
>  extern int usb_resume(struct device *dev, pm_message_t msg);
> +extern int usb_resume_complete(struct device *dev);
>  
>  extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg);
>  extern int usb_port_resume(struct usb_device *dev, pm_message_t msg);
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux