mbox series

[00/20] usb: Use new pm_ptr() macro

Message ID 20200903112554.34263-1-paul@crapouillou.net
Headers show
Series usb: Use new pm_ptr() macro | expand

Message

Paul Cercueil Sept. 3, 2020, 11:25 a.m. UTC
The pm_ptr() macro was introduced to avoid conditional compilation of
the PM code. Instead of having the .suspend/.resume functions compiled
conditionally if CONFIG_PM_SLEEP, they are now always visible by the
compiler, which can then detect bugs, and will be discarded if unused.

Cheers,
-Paul

Paul Cercueil (20):
  usb/host: ohci-platform: Use pm_ptr() macro
  usb/host: ehci-spear: Use pm_ptr() macro
  usb/host: ehci-npcm7xx: Use pm_ptr() macro
  usb/host: ehci-platform: Use pm_ptr() macro
  usb/cdns3: core: Use pm_ptr() macro
  usb/chipidea: core: Use pm_ptr() macro
  usb/misc: usb3503: Use pm_ptr() macro
  usb/misc: usb4604: Use pm_ptr() macro
  usb/musb: am35x: Use pm_ptr() macro
  usb/musb: da8xx: Use pm_ptr() macro
  usb/musb: musb_dsps: Use pm_ptr() macro
  usb/musb: ux500: Use pm_ptr() macro
  usb/phy: am335x: Use pm_ptr() macro
  usb/phy: mxs-usb: Use pm_ptr() macro
  usb/gadget/udc: atmel: Use pm_ptr() macro
  usb/gadget/udc: bdc: Use pm_ptr() macro
  usb/gadget/udc: mv-u3d: Use pm_ptr() macro
  usb/gadget/udc: pch: Use pm_ptr() macro
  usb/gadget/udc: renesas: Use pm_ptr() macro
  usb/gadget/udc: snps: Use pm_ptr() macro

 drivers/usb/cdns3/core.c                | 13 ++++---------
 drivers/usb/chipidea/core.c             | 26 +++++++++++--------------
 drivers/usb/gadget/udc/atmel_usba_udc.c |  8 +++-----
 drivers/usb/gadget/udc/bdc/bdc_core.c   |  9 +++------
 drivers/usb/gadget/udc/mv_u3d_core.c    |  8 +++-----
 drivers/usb/gadget/udc/pch_udc.c        | 11 +++--------
 drivers/usb/gadget/udc/renesas_usb3.c   |  8 +++-----
 drivers/usb/gadget/udc/snps_udc_plat.c  | 16 +++++----------
 drivers/usb/host/ehci-npcm7xx.c         |  8 +++-----
 drivers/usb/host/ehci-platform.c        |  8 +++-----
 drivers/usb/host/ehci-spear.c           |  8 +++-----
 drivers/usb/host/ohci-platform.c        | 19 ++++++++----------
 drivers/usb/misc/usb3503.c              | 18 ++++++++---------
 drivers/usb/misc/usb4604.c              |  8 +++-----
 drivers/usb/musb/am35x.c                |  8 +++-----
 drivers/usb/musb/da8xx.c                |  8 +++-----
 drivers/usb/musb/musb_dsps.c            | 20 +++++++------------
 drivers/usb/musb/ux500.c                |  8 +++-----
 drivers/usb/phy/phy-am335x.c            |  8 +++-----
 drivers/usb/phy/phy-mxs-usb.c           | 11 +++++------
 20 files changed, 87 insertions(+), 144 deletions(-)

Comments

Alan Stern Sept. 3, 2020, 3:34 p.m. UTC | #1
On Thu, Sep 03, 2020 at 01:25:35PM +0200, Paul Cercueil wrote:
> Use the newly introduced pm_ptr() macro, and mark the suspend/resume
> functions __maybe_unused. These functions can then be moved outside the
> CONFIG_PM_SUSPEND block, and the compiler can then process them and
> detect build failures independently of the config. If unused, they will
> simply be discarded by the compiler.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/usb/host/ohci-platform.c | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
> index 4a8456f12a73..21400d7d8b0a 100644
> --- a/drivers/usb/host/ohci-platform.c
> +++ b/drivers/usb/host/ohci-platform.c
> @@ -176,22 +176,21 @@ static int ohci_platform_probe(struct platform_device *dev)
>  	if (pdata->num_ports)
>  		ohci->num_ports = pdata->num_ports;
>  
> -#ifndef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO
> -	if (ohci->flags & OHCI_QUIRK_BE_MMIO) {
> +	if (!IS_ENABLED(CONFIG_USB_OHCI_BIG_ENDIAN_MMIO) &&
> +	    ohci->flags & OHCI_QUIRK_BE_MMIO) {
>  		dev_err(&dev->dev,
>  			"Error: CONFIG_USB_OHCI_BIG_ENDIAN_MMIO not set\n");
>  		err = -EINVAL;
>  		goto err_reset;
>  	}
> -#endif
> -#ifndef CONFIG_USB_OHCI_BIG_ENDIAN_DESC
> -	if (ohci->flags & OHCI_QUIRK_BE_DESC) {
> +
> +	if (!IS_ENABLED(CONFIG_USB_OHCI_BIG_ENDIAN_DESC) &&
> +	    ohci->flags & OHCI_QUIRK_BE_DESC) {
>  		dev_err(&dev->dev,
>  			"Error: CONFIG_USB_OHCI_BIG_ENDIAN_DESC not set\n");
>  		err = -EINVAL;
>  		goto err_reset;
>  	}
> -#endif
>  
>  	pm_runtime_set_active(&dev->dev);
>  	pm_runtime_enable(&dev->dev);

The changes above don't seem to have any connection with the patch 
description.  Please don't mix multiple changes in a single patch.

The rest of the patch is okay.

Alan Stern

> @@ -267,8 +266,7 @@ static int ohci_platform_remove(struct platform_device *dev)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
> -static int ohci_platform_suspend(struct device *dev)
> +static int __maybe_unused ohci_platform_suspend(struct device *dev)
>  {
>  	struct usb_hcd *hcd = dev_get_drvdata(dev);
>  	struct usb_ohci_pdata *pdata = dev->platform_data;
> @@ -286,7 +284,7 @@ static int ohci_platform_suspend(struct device *dev)
>  	return ret;
>  }
>  
> -static int ohci_platform_resume(struct device *dev)
> +static int __maybe_unused ohci_platform_resume(struct device *dev)
>  {
>  	struct usb_hcd *hcd = dev_get_drvdata(dev);
>  	struct usb_ohci_pdata *pdata = dev_get_platdata(dev);
> @@ -306,7 +304,6 @@ static int ohci_platform_resume(struct device *dev)
>  
>  	return 0;
>  }
> -#endif /* CONFIG_PM_SLEEP */
>  
>  static const struct of_device_id ohci_platform_ids[] = {
>  	{ .compatible = "generic-ohci", },
> @@ -332,7 +329,7 @@ static struct platform_driver ohci_platform_driver = {
>  	.shutdown	= usb_hcd_platform_shutdown,
>  	.driver		= {
>  		.name	= "ohci-platform",
> -		.pm	= &ohci_platform_pm_ops,
> +		.pm	= pm_ptr(&ohci_platform_pm_ops),
>  		.of_match_table = ohci_platform_ids,
>  	}
>  };
> -- 
> 2.28.0
>