Re: [PATCHv4 10/12] usb: dwc2: Add suspend/resume for gadget

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

 



[ added linux-kernel ML to cc: ]

Hi,

On Tuesday, August 26, 2014 11:20:01 AM dinguyen@xxxxxxxxxxxxxxxxxxxxx wrote:
> From: Dinh Nguyen <dinguyen@xxxxxxxxxxxxxxxxxxxxx>
> 
> Move suspend/resume code to common platform code.

This should be done at the same time that gadget/host probing is merged
to preserve bisectability.

> Signed-off-by: Dinh Nguyen <dinguyen@xxxxxxxxxxxxxxxxxxxxx>
> Acked-by: Paul Zimmerman <paulz@xxxxxxxxxxxx>
> ---
>  drivers/usb/dwc2/core.h     |  6 ++++++
>  drivers/usb/dwc2/gadget.c   |  4 ++--
>  drivers/usb/dwc2/platform.c | 23 +++++++++++++++++++++++
>  3 files changed, 31 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> index bbb0f52..5bb7e801 100644
> --- a/drivers/usb/dwc2/core.h
> +++ b/drivers/usb/dwc2/core.h
> @@ -964,12 +964,18 @@ extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
>  #if defined(CONFIG_USB_DWC2_PERIPHERAL) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
>  extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
>  extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
> +extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
> +extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
>  extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
>  irqreturn_t s3c_hsotg_irq(int irq, void *pw);
>  #else
>  static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
>  static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
>  { return 0; }
> +static inline int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
> +{ return 0; }
> +static inline int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
> +{ return 0; }
>  static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
>  { return 0; }
>  static inline irqreturn_t s3c_hsotg_irq(int irq, void *pw)
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index aab1b45..09d591e 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -3552,7 +3552,7 @@ int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
>  	return 0;
>  }
>  
> -static int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
> +int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
>  {
>  	unsigned long flags;
>  	int ret = 0;
> @@ -3581,7 +3581,7 @@ static int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
>  	return ret;
>  }
>  
> -static int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
> +int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
>  {
>  	unsigned long flags;
>  	int ret = 0;
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index 278135d..59265ad 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -206,6 +206,27 @@ static int dwc2_driver_probe(struct platform_device *dev)
>  	return retval;
>  }
>  
> +static int dwc2_suspend(struct platform_device *dev, pm_message_t state)
> +{
> +	struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
> +	int ret = 0;
> +
> +	if (dwc2_is_device_mode(dwc2))
> +		ret = s3c_hsotg_suspend(dwc2);
> +	return ret;
> +}
> +
> +static int dwc2_resume(struct platform_device *dev)
> +{
> +	struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
> +	int ret = 0;
> +
> +	if (dwc2_is_device_mode(dwc2))
> +		ret = s3c_hsotg_resume(dwc2);
> +
> +	return ret;
> +}
> +
>  static struct platform_driver dwc2_platform_driver = {
>  	.driver = {
>  		.name = dwc2_driver_name,
> @@ -213,6 +234,8 @@ static struct platform_driver dwc2_platform_driver = {
>  	},
>  	.probe = dwc2_driver_probe,
>  	.remove = dwc2_driver_remove,
> +	.suspend = dwc2_suspend,
> +	.resume = dwc2_resume,

Please use the new PM API (struct dev_pm_ops).

>  };
>  
>  module_platform_driver(dwc2_platform_driver);

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

--
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