2020-09-03 11:30:16

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 00/20] usb: Use new pm_ptr() macro

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

--
2.28.0


2020-09-03 11:32:13

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 01/20] usb/host: ohci-platform: Use pm_ptr() macro

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 <[email protected]>
---
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);
@@ -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

2020-09-03 11:40:37

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 05/20] usb/cdns3: core: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/cdns3/core.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 5c1586ec7824..dacab9e9ef92 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -546,9 +546,7 @@ static int cdns3_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-
-static int cdns3_suspend(struct device *dev)
+static int __maybe_unused cdns3_suspend(struct device *dev)
{
struct cdns3 *cdns = dev_get_drvdata(dev);
unsigned long flags;
@@ -568,7 +566,7 @@ static int cdns3_suspend(struct device *dev)
return 0;
}

-static int cdns3_resume(struct device *dev)
+static int __maybe_unused cdns3_resume(struct device *dev)
{
struct cdns3 *cdns = dev_get_drvdata(dev);
unsigned long flags;
@@ -588,11 +586,8 @@ static int cdns3_resume(struct device *dev)

return 0;
}
-#endif

-static const struct dev_pm_ops cdns3_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(cdns3_suspend, cdns3_resume)
-};
+static SIMPLE_DEV_PM_OPS(cdns3_pm_ops, cdns3_suspend, cdns3_resume);

#ifdef CONFIG_OF
static const struct of_device_id of_cdns3_match[] = {
@@ -608,7 +603,7 @@ static struct platform_driver cdns3_driver = {
.driver = {
.name = "cdns-usb3",
.of_match_table = of_match_ptr(of_cdns3_match),
- .pm = &cdns3_pm_ops,
+ .pm = pm_ptr(&cdns3_pm_ops),
},
};

--
2.28.0

2020-09-03 11:42:35

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 09/20] usb/musb: am35x: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/musb/am35x.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 660641ab1545..6162111f4cae 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -547,8 +547,7 @@ static int am35x_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int am35x_suspend(struct device *dev)
+static int __maybe_unused am35x_suspend(struct device *dev)
{
struct am35x_glue *glue = dev_get_drvdata(dev);
struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
@@ -564,7 +563,7 @@ static int am35x_suspend(struct device *dev)
return 0;
}

-static int am35x_resume(struct device *dev)
+static int __maybe_unused am35x_resume(struct device *dev)
{
struct am35x_glue *glue = dev_get_drvdata(dev);
struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
@@ -589,7 +588,6 @@ static int am35x_resume(struct device *dev)

return 0;
}
-#endif

static SIMPLE_DEV_PM_OPS(am35x_pm_ops, am35x_suspend, am35x_resume);

@@ -598,7 +596,7 @@ static struct platform_driver am35x_driver = {
.remove = am35x_remove,
.driver = {
.name = "musb-am35x",
- .pm = &am35x_pm_ops,
+ .pm = pm_ptr(&am35x_pm_ops),
},
};

--
2.28.0

2020-09-03 11:43:23

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 08/20] usb/misc: usb4604: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/misc/usb4604.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/misc/usb4604.c b/drivers/usb/misc/usb4604.c
index 1b4de651e697..2142af9bbdec 100644
--- a/drivers/usb/misc/usb4604.c
+++ b/drivers/usb/misc/usb4604.c
@@ -112,8 +112,7 @@ static int usb4604_i2c_probe(struct i2c_client *i2c,
return usb4604_probe(hub);
}

-#ifdef CONFIG_PM_SLEEP
-static int usb4604_i2c_suspend(struct device *dev)
+static int __maybe_unused usb4604_i2c_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct usb4604 *hub = i2c_get_clientdata(client);
@@ -123,7 +122,7 @@ static int usb4604_i2c_suspend(struct device *dev)
return 0;
}

-static int usb4604_i2c_resume(struct device *dev)
+static int __maybe_unused usb4604_i2c_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct usb4604 *hub = i2c_get_clientdata(client);
@@ -132,7 +131,6 @@ static int usb4604_i2c_resume(struct device *dev)

return 0;
}
-#endif

static SIMPLE_DEV_PM_OPS(usb4604_i2c_pm_ops, usb4604_i2c_suspend,
usb4604_i2c_resume);
@@ -154,7 +152,7 @@ MODULE_DEVICE_TABLE(of, usb4604_of_match);
static struct i2c_driver usb4604_i2c_driver = {
.driver = {
.name = "usb4604",
- .pm = &usb4604_i2c_pm_ops,
+ .pm = pm_ptr(&usb4604_i2c_pm_ops),
.of_match_table = of_match_ptr(usb4604_of_match),
},
.probe = usb4604_i2c_probe,
--
2.28.0

2020-09-03 11:43:23

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 06/20] usb/chipidea: core: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/chipidea/core.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index aa40e510b806..af64ab98fb56 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -1231,9 +1231,8 @@ static int ci_hdrc_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM
/* Prepare wakeup by SRP before suspend */
-static void ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
+static void __maybe_unused ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
{
if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
!hw_read_otgsc(ci, OTGSC_ID)) {
@@ -1245,7 +1244,7 @@ static void ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
}

/* Handle SRP when wakeup by data pulse */
-static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
+static void __maybe_unused ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
{
if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
(ci->fsm.a_bus_drop == 1) && (ci->fsm.a_bus_req == 0)) {
@@ -1259,7 +1258,7 @@ static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
}
}

-static void ci_controller_suspend(struct ci_hdrc *ci)
+static void __maybe_unused ci_controller_suspend(struct ci_hdrc *ci)
{
disable_irq(ci->irq);
ci_hdrc_enter_lpm(ci, true);
@@ -1277,7 +1276,7 @@ static void ci_controller_suspend(struct ci_hdrc *ci)
* interrupt (wakeup int) only let the controller be out of
* low power mode, but not handle any interrupts.
*/
-static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
+static void __maybe_unused ci_extcon_wakeup_int(struct ci_hdrc *ci)
{
struct ci_hdrc_cable *cable_id, *cable_vbus;
u32 otgsc = hw_read_otgsc(ci, ~0);
@@ -1294,7 +1293,7 @@ static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
ci_irq(ci->irq, ci);
}

-static int ci_controller_resume(struct device *dev)
+static int __maybe_unused ci_controller_resume(struct device *dev)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
int ret;
@@ -1332,8 +1331,7 @@ static int ci_controller_resume(struct device *dev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int ci_suspend(struct device *dev)
+static int __maybe_unused ci_suspend(struct device *dev)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);

@@ -1366,7 +1364,7 @@ static int ci_suspend(struct device *dev)
return 0;
}

-static int ci_resume(struct device *dev)
+static int __maybe_unused ci_resume(struct device *dev)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
int ret;
@@ -1386,9 +1384,8 @@ static int ci_resume(struct device *dev)

return ret;
}
-#endif /* CONFIG_PM_SLEEP */

-static int ci_runtime_suspend(struct device *dev)
+static int __maybe_unused ci_runtime_suspend(struct device *dev)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);

@@ -1408,13 +1405,12 @@ static int ci_runtime_suspend(struct device *dev)
return 0;
}

-static int ci_runtime_resume(struct device *dev)
+static int __maybe_unused ci_runtime_resume(struct device *dev)
{
return ci_controller_resume(dev);
}

-#endif /* CONFIG_PM */
-static const struct dev_pm_ops ci_pm_ops = {
+static const struct dev_pm_ops __maybe_unused ci_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(ci_suspend, ci_resume)
SET_RUNTIME_PM_OPS(ci_runtime_suspend, ci_runtime_resume, NULL)
};
@@ -1424,7 +1420,7 @@ static struct platform_driver ci_hdrc_driver = {
.remove = ci_hdrc_remove,
.driver = {
.name = "ci_hdrc",
- .pm = &ci_pm_ops,
+ .pm = pm_ptr(&ci_pm_ops),
.dev_groups = ci_groups,
},
};
--
2.28.0

2020-09-03 11:43:48

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 13/20] usb/phy: am335x: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/phy/phy-am335x.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c
index 8524475d942d..a238f866634b 100644
--- a/drivers/usb/phy/phy-am335x.c
+++ b/drivers/usb/phy/phy-am335x.c
@@ -90,8 +90,7 @@ static int am335x_phy_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int am335x_phy_suspend(struct device *dev)
+static int __maybe_unused am335x_phy_suspend(struct device *dev)
{
struct am335x_phy *am_phy = dev_get_drvdata(dev);

@@ -111,7 +110,7 @@ static int am335x_phy_suspend(struct device *dev)
return 0;
}

-static int am335x_phy_resume(struct device *dev)
+static int __maybe_unused am335x_phy_resume(struct device *dev)
{
struct am335x_phy *am_phy = dev_get_drvdata(dev);

@@ -122,7 +121,6 @@ static int am335x_phy_resume(struct device *dev)

return 0;
}
-#endif

static SIMPLE_DEV_PM_OPS(am335x_pm_ops, am335x_phy_suspend, am335x_phy_resume);

@@ -137,7 +135,7 @@ static struct platform_driver am335x_phy_driver = {
.remove = am335x_phy_remove,
.driver = {
.name = "am335x-phy-driver",
- .pm = &am335x_pm_ops,
+ .pm = pm_ptr(&am335x_pm_ops),
.of_match_table = am335x_phy_ids,
},
};
--
2.28.0

2020-09-03 11:43:49

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 14/20] usb/phy: mxs-usb: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/phy/phy-mxs-usb.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 67b39dc62b37..c5e32d51563f 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -815,8 +815,8 @@ static int mxs_phy_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on)
+static void __maybe_unused
+mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on)
{
unsigned int reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR;

@@ -832,7 +832,7 @@ static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on)
reg, BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL);
}

-static int mxs_phy_system_suspend(struct device *dev)
+static int __maybe_unused mxs_phy_system_suspend(struct device *dev)
{
struct mxs_phy *mxs_phy = dev_get_drvdata(dev);

@@ -842,7 +842,7 @@ static int mxs_phy_system_suspend(struct device *dev)
return 0;
}

-static int mxs_phy_system_resume(struct device *dev)
+static int __maybe_unused mxs_phy_system_resume(struct device *dev)
{
struct mxs_phy *mxs_phy = dev_get_drvdata(dev);

@@ -851,7 +851,6 @@ static int mxs_phy_system_resume(struct device *dev)

return 0;
}
-#endif /* CONFIG_PM_SLEEP */

static SIMPLE_DEV_PM_OPS(mxs_phy_pm, mxs_phy_system_suspend,
mxs_phy_system_resume);
@@ -862,7 +861,7 @@ static struct platform_driver mxs_phy_driver = {
.driver = {
.name = DRIVER_NAME,
.of_match_table = mxs_phy_dt_ids,
- .pm = &mxs_phy_pm,
+ .pm = pm_ptr(&mxs_phy_pm),
},
};

--
2.28.0

2020-09-03 11:44:59

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 11/20] usb/musb: musb_dsps: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/musb/musb_dsps.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 30085b2be7b9..cb196bb6661d 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -665,26 +665,22 @@ dsps_dma_controller_create(struct musb *musb, void __iomem *base)
return controller;
}

-#ifdef CONFIG_PM_SLEEP
-static void dsps_dma_controller_suspend(struct dsps_glue *glue)
+static void __maybe_unused dsps_dma_controller_suspend(struct dsps_glue *glue)
{
void __iomem *usbss_base = glue->usbss_base;

musb_writel(usbss_base, USBSS_IRQ_CLEARR, USBSS_IRQ_PD_COMP);
}

-static void dsps_dma_controller_resume(struct dsps_glue *glue)
+static void __maybe_unused dsps_dma_controller_resume(struct dsps_glue *glue)
{
void __iomem *usbss_base = glue->usbss_base;

musb_writel(usbss_base, USBSS_IRQ_ENABLER, USBSS_IRQ_PD_COMP);
}
-#endif
#else /* CONFIG_USB_TI_CPPI41_DMA */
-#ifdef CONFIG_PM_SLEEP
-static void dsps_dma_controller_suspend(struct dsps_glue *glue) {}
-static void dsps_dma_controller_resume(struct dsps_glue *glue) {}
-#endif
+static void __maybe_unused dsps_dma_controller_suspend(struct dsps_glue *glue) {}
+static void __maybe_unused dsps_dma_controller_resume(struct dsps_glue *glue) {}
#endif /* CONFIG_USB_TI_CPPI41_DMA */

static struct musb_platform_ops dsps_ops = {
@@ -961,8 +957,7 @@ static const struct of_device_id musb_dsps_of_match[] = {
};
MODULE_DEVICE_TABLE(of, musb_dsps_of_match);

-#ifdef CONFIG_PM_SLEEP
-static int dsps_suspend(struct device *dev)
+static int __maybe_unused dsps_suspend(struct device *dev)
{
struct dsps_glue *glue = dev_get_drvdata(dev);
const struct dsps_musb_wrapper *wrp = glue->wrp;
@@ -996,7 +991,7 @@ static int dsps_suspend(struct device *dev)
return 0;
}

-static int dsps_resume(struct device *dev)
+static int __maybe_unused dsps_resume(struct device *dev)
{
struct dsps_glue *glue = dev_get_drvdata(dev);
const struct dsps_musb_wrapper *wrp = glue->wrp;
@@ -1024,7 +1019,6 @@ static int dsps_resume(struct device *dev)

return 0;
}
-#endif

static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume);

@@ -1033,7 +1027,7 @@ static struct platform_driver dsps_usbss_driver = {
.remove = dsps_remove,
.driver = {
.name = "musb-dsps",
- .pm = &dsps_pm_ops,
+ .pm = pm_ptr(&dsps_pm_ops),
.of_match_table = musb_dsps_of_match,
},
};
--
2.28.0

2020-09-03 11:51:27

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 16/20] usb/gadget/udc: bdc: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/gadget/udc/bdc/bdc_core.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 5ff36525044e..da3a7a59ccae 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -597,8 +597,7 @@ static int bdc_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int bdc_suspend(struct device *dev)
+static int __maybe_unused bdc_suspend(struct device *dev)
{
struct bdc *bdc = dev_get_drvdata(dev);
int ret;
@@ -611,7 +610,7 @@ static int bdc_suspend(struct device *dev)
return ret;
}

-static int bdc_resume(struct device *dev)
+static int __maybe_unused bdc_resume(struct device *dev)
{
struct bdc *bdc = dev_get_drvdata(dev);
int ret;
@@ -630,8 +629,6 @@ static int bdc_resume(struct device *dev)
return 0;
}

-#endif /* CONFIG_PM_SLEEP */
-
static SIMPLE_DEV_PM_OPS(bdc_pm_ops, bdc_suspend,
bdc_resume);

@@ -644,7 +641,7 @@ static const struct of_device_id bdc_of_match[] = {
static struct platform_driver bdc_driver = {
.driver = {
.name = BRCM_BDC_NAME,
- .pm = &bdc_pm_ops,
+ .pm = pm_ptr(&bdc_pm_ops),
.of_match_table = bdc_of_match,
},
.probe = bdc_probe,
--
2.28.0

2020-09-03 11:56:16

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 19/20] usb/gadget/udc: renesas: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/gadget/udc/renesas_usb3.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 0c418ce50ba0..4e8ba5914eff 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2867,8 +2867,7 @@ static int renesas_usb3_probe(struct platform_device *pdev)
return ret;
}

-#ifdef CONFIG_PM_SLEEP
-static int renesas_usb3_suspend(struct device *dev)
+static int __maybe_unused renesas_usb3_suspend(struct device *dev)
{
struct renesas_usb3 *usb3 = dev_get_drvdata(dev);

@@ -2884,7 +2883,7 @@ static int renesas_usb3_suspend(struct device *dev)
return 0;
}

-static int renesas_usb3_resume(struct device *dev)
+static int __maybe_unused renesas_usb3_resume(struct device *dev)
{
struct renesas_usb3 *usb3 = dev_get_drvdata(dev);

@@ -2899,7 +2898,6 @@ static int renesas_usb3_resume(struct device *dev)

return 0;
}
-#endif

static SIMPLE_DEV_PM_OPS(renesas_usb3_pm_ops, renesas_usb3_suspend,
renesas_usb3_resume);
@@ -2909,7 +2907,7 @@ static struct platform_driver renesas_usb3_driver = {
.remove = renesas_usb3_remove,
.driver = {
.name = udc_name,
- .pm = &renesas_usb3_pm_ops,
+ .pm = pm_ptr(&renesas_usb3_pm_ops),
.of_match_table = of_match_ptr(usb3_of_match),
},
};
--
2.28.0

2020-09-03 11:56:39

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 20/20] usb/gadget/udc: snps: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/gadget/udc/snps_udc_plat.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/udc/snps_udc_plat.c b/drivers/usb/gadget/udc/snps_udc_plat.c
index 32f1d3e90c26..6b8f08287c84 100644
--- a/drivers/usb/gadget/udc/snps_udc_plat.c
+++ b/drivers/usb/gadget/udc/snps_udc_plat.c
@@ -257,8 +257,7 @@ static int udc_plat_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int udc_plat_suspend(struct device *dev)
+static int __maybe_unused udc_plat_suspend(struct device *dev)
{
struct udc *udc;

@@ -275,7 +274,7 @@ static int udc_plat_suspend(struct device *dev)
return 0;
}

-static int udc_plat_resume(struct device *dev)
+static int __maybe_unused udc_plat_resume(struct device *dev)
{
struct udc *udc;
int ret;
@@ -302,11 +301,8 @@ static int udc_plat_resume(struct device *dev)

return 0;
}
-static const struct dev_pm_ops udc_plat_pm_ops = {
- .suspend = udc_plat_suspend,
- .resume = udc_plat_resume,
-};
-#endif
+
+static SIMPLE_DEV_PM_OPS(plat_pm_ops, udc_plat_suspend, udc_plat_resume);

#if defined(CONFIG_OF)
static const struct of_device_id of_udc_match[] = {
@@ -324,9 +320,7 @@ static struct platform_driver udc_plat_driver = {
.driver = {
.name = "snps-udc-plat",
.of_match_table = of_match_ptr(of_udc_match),
-#ifdef CONFIG_PM_SLEEP
- .pm = &udc_plat_pm_ops,
-#endif
+ .pm = pm_ptr(&udc_plat_pm_ops),
},
};
module_platform_driver(udc_plat_driver);
--
2.28.0

2020-09-03 15:17:36

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 17/20] usb/gadget/udc: mv-u3d: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/gadget/udc/mv_u3d_core.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c
index 5486f5a70868..a7e3736fd0c1 100644
--- a/drivers/usb/gadget/udc/mv_u3d_core.c
+++ b/drivers/usb/gadget/udc/mv_u3d_core.c
@@ -1988,8 +1988,7 @@ static int mv_u3d_probe(struct platform_device *dev)
return retval;
}

-#ifdef CONFIG_PM_SLEEP
-static int mv_u3d_suspend(struct device *dev)
+static int __maybe_unused mv_u3d_suspend(struct device *dev)
{
struct mv_u3d *u3d = dev_get_drvdata(dev);

@@ -2012,7 +2011,7 @@ static int mv_u3d_suspend(struct device *dev)
return 0;
}

-static int mv_u3d_resume(struct device *dev)
+static int __maybe_unused mv_u3d_resume(struct device *dev)
{
struct mv_u3d *u3d = dev_get_drvdata(dev);
int retval;
@@ -2031,7 +2030,6 @@ static int mv_u3d_resume(struct device *dev)

return 0;
}
-#endif

static SIMPLE_DEV_PM_OPS(mv_u3d_pm_ops, mv_u3d_suspend, mv_u3d_resume);

@@ -2051,7 +2049,7 @@ static struct platform_driver mv_u3d_driver = {
.shutdown = mv_u3d_shutdown,
.driver = {
.name = "mv-u3d",
- .pm = &mv_u3d_pm_ops,
+ .pm = pm_ptr(&mv_u3d_pm_ops),
},
};

--
2.28.0

2020-09-03 15:17:48

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 15/20] usb/gadget/udc: atmel: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/gadget/udc/atmel_usba_udc.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index a6426dd1cfef..38da3f3ebde7 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -2359,8 +2359,7 @@ static int usba_udc_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int usba_udc_suspend(struct device *dev)
+static int __maybe_unused usba_udc_suspend(struct device *dev)
{
struct usba_udc *udc = dev_get_drvdata(dev);

@@ -2393,7 +2392,7 @@ static int usba_udc_suspend(struct device *dev)
return 0;
}

-static int usba_udc_resume(struct device *dev)
+static int __maybe_unused usba_udc_resume(struct device *dev)
{
struct usba_udc *udc = dev_get_drvdata(dev);

@@ -2417,7 +2416,6 @@ static int usba_udc_resume(struct device *dev)

return 0;
}
-#endif

static SIMPLE_DEV_PM_OPS(usba_udc_pm_ops, usba_udc_suspend, usba_udc_resume);

@@ -2425,7 +2423,7 @@ static struct platform_driver udc_driver = {
.remove = usba_udc_remove,
.driver = {
.name = "atmel_usba_udc",
- .pm = &usba_udc_pm_ops,
+ .pm = pm_ptr(&usba_udc_pm_ops),
.of_match_table = atmel_udc_dt_ids,
},
};
--
2.28.0

2020-09-03 15:19:02

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 18/20] usb/gadget/udc: pch: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/gadget/udc/pch_udc.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index 8afc31d94b0e..9e26b5ab3058 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -3042,8 +3042,7 @@ static void pch_udc_remove(struct pci_dev *pdev)
pch_udc_exit(dev);
}

-#ifdef CONFIG_PM_SLEEP
-static int pch_udc_suspend(struct device *d)
+static int __maybe_unused pch_udc_suspend(struct device *d)
{
struct pch_udc_dev *dev = dev_get_drvdata(d);

@@ -3053,16 +3052,12 @@ static int pch_udc_suspend(struct device *d)
return 0;
}

-static int pch_udc_resume(struct device *d)
+static int __maybe_unused pch_udc_resume(struct device *d)
{
return 0;
}

static SIMPLE_DEV_PM_OPS(pch_udc_pm, pch_udc_suspend, pch_udc_resume);
-#define PCH_UDC_PM_OPS (&pch_udc_pm)
-#else
-#define PCH_UDC_PM_OPS NULL
-#endif /* CONFIG_PM_SLEEP */

static int pch_udc_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
@@ -3171,7 +3166,7 @@ static struct pci_driver pch_udc_driver = {
.remove = pch_udc_remove,
.shutdown = pch_udc_shutdown,
.driver = {
- .pm = PCH_UDC_PM_OPS,
+ .pm = pm_ptr(&pch_udc_pm),
},
};

--
2.28.0

2020-09-03 15:19:17

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 10/20] usb/musb: da8xx: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/musb/da8xx.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 1c023c0091c4..7a13463006e3 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -598,8 +598,7 @@ static int da8xx_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int da8xx_suspend(struct device *dev)
+static int __maybe_unused da8xx_suspend(struct device *dev)
{
int ret;
struct da8xx_glue *glue = dev_get_drvdata(dev);
@@ -612,7 +611,7 @@ static int da8xx_suspend(struct device *dev)
return 0;
}

-static int da8xx_resume(struct device *dev)
+static int __maybe_unused da8xx_resume(struct device *dev)
{
int ret;
struct da8xx_glue *glue = dev_get_drvdata(dev);
@@ -622,7 +621,6 @@ static int da8xx_resume(struct device *dev)
return ret;
return phy_power_on(glue->phy);
}
-#endif

static SIMPLE_DEV_PM_OPS(da8xx_pm_ops, da8xx_suspend, da8xx_resume);

@@ -641,7 +639,7 @@ static struct platform_driver da8xx_driver = {
.remove = da8xx_remove,
.driver = {
.name = "musb-da8xx",
- .pm = &da8xx_pm_ops,
+ .pm = pm_ptr(&da8xx_pm_ops),
.of_match_table = of_match_ptr(da8xx_id_table),
},
};
--
2.28.0

2020-09-03 15:19:49

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 03/20] usb/host: ehci-npcm7xx: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/host/ehci-npcm7xx.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-npcm7xx.c b/drivers/usb/host/ehci-npcm7xx.c
index adaf8fb4b459..6b5a7a873e01 100644
--- a/drivers/usb/host/ehci-npcm7xx.c
+++ b/drivers/usb/host/ehci-npcm7xx.c
@@ -37,8 +37,7 @@ static const char hcd_name[] = "npcm7xx-ehci";

static struct hc_driver __read_mostly ehci_npcm7xx_hc_driver;

-#ifdef CONFIG_PM_SLEEP
-static int ehci_npcm7xx_drv_suspend(struct device *dev)
+static int __maybe_unused ehci_npcm7xx_drv_suspend(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
bool do_wakeup = device_may_wakeup(dev);
@@ -46,14 +45,13 @@ static int ehci_npcm7xx_drv_suspend(struct device *dev)
return ehci_suspend(hcd, do_wakeup);
}

-static int ehci_npcm7xx_drv_resume(struct device *dev)
+static int __maybe_unused ehci_npcm7xx_drv_resume(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);

ehci_resume(hcd, false);
return 0;
}
-#endif /* CONFIG_PM_SLEEP */

static SIMPLE_DEV_PM_OPS(ehci_npcm7xx_pm_ops, ehci_npcm7xx_drv_suspend,
ehci_npcm7xx_drv_resume);
@@ -183,7 +181,7 @@ static struct platform_driver npcm7xx_ehci_hcd_driver = {
.driver = {
.name = "npcm7xx-ehci",
.bus = &platform_bus_type,
- .pm = &ehci_npcm7xx_pm_ops,
+ .pm = pm_ptr(&ehci_npcm7xx_pm_ops),
.of_match_table = npcm7xx_ehci_id_table,
}
};
--
2.28.0

2020-09-03 15:19:59

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 07/20] usb/misc: usb3503: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/misc/usb3503.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index 116bd789e568..48099c6bf04c 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -322,8 +322,7 @@ static int usb3503_platform_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int usb3503_suspend(struct usb3503 *hub)
+static int __maybe_unused usb3503_suspend(struct usb3503 *hub)
{
usb3503_switch_mode(hub, USB3503_MODE_STANDBY);
clk_disable_unprepare(hub->clk);
@@ -331,7 +330,7 @@ static int usb3503_suspend(struct usb3503 *hub)
return 0;
}

-static int usb3503_resume(struct usb3503 *hub)
+static int __maybe_unused usb3503_resume(struct usb3503 *hub)
{
clk_prepare_enable(hub->clk);
usb3503_switch_mode(hub, hub->mode);
@@ -339,30 +338,29 @@ static int usb3503_resume(struct usb3503 *hub)
return 0;
}

-static int usb3503_i2c_suspend(struct device *dev)
+static int __maybe_unused usb3503_i2c_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);

return usb3503_suspend(i2c_get_clientdata(client));
}

-static int usb3503_i2c_resume(struct device *dev)
+static int __maybe_unused usb3503_i2c_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);

return usb3503_resume(i2c_get_clientdata(client));
}

-static int usb3503_platform_suspend(struct device *dev)
+static int __maybe_unused usb3503_platform_suspend(struct device *dev)
{
return usb3503_suspend(dev_get_drvdata(dev));
}

-static int usb3503_platform_resume(struct device *dev)
+static int __maybe_unused usb3503_platform_resume(struct device *dev)
{
return usb3503_resume(dev_get_drvdata(dev));
}
-#endif

static SIMPLE_DEV_PM_OPS(usb3503_i2c_pm_ops, usb3503_i2c_suspend,
usb3503_i2c_resume);
@@ -388,7 +386,7 @@ MODULE_DEVICE_TABLE(of, usb3503_of_match);
static struct i2c_driver usb3503_i2c_driver = {
.driver = {
.name = USB3503_I2C_NAME,
- .pm = &usb3503_i2c_pm_ops,
+ .pm = pm_ptr(&usb3503_i2c_pm_ops),
.of_match_table = of_match_ptr(usb3503_of_match),
},
.probe = usb3503_i2c_probe,
@@ -400,7 +398,7 @@ static struct platform_driver usb3503_platform_driver = {
.driver = {
.name = USB3503_I2C_NAME,
.of_match_table = of_match_ptr(usb3503_of_match),
- .pm = &usb3503_platform_pm_ops,
+ .pm = pm_ptr(&usb3503_platform_pm_ops),
},
.probe = usb3503_platform_probe,
.remove = usb3503_platform_remove,
--
2.28.0

2020-09-03 15:20:56

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 12/20] usb/musb: ux500: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/musb/ux500.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 73538d1d0524..3defe83f3a16 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -327,8 +327,7 @@ static int ux500_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int ux500_suspend(struct device *dev)
+static int __maybe_unused ux500_suspend(struct device *dev)
{
struct ux500_glue *glue = dev_get_drvdata(dev);
struct musb *musb = glue_to_musb(glue);
@@ -341,7 +340,7 @@ static int ux500_suspend(struct device *dev)
return 0;
}

-static int ux500_resume(struct device *dev)
+static int __maybe_unused ux500_resume(struct device *dev)
{
struct ux500_glue *glue = dev_get_drvdata(dev);
struct musb *musb = glue_to_musb(glue);
@@ -358,7 +357,6 @@ static int ux500_resume(struct device *dev)

return 0;
}
-#endif

static SIMPLE_DEV_PM_OPS(ux500_pm_ops, ux500_suspend, ux500_resume);

@@ -374,7 +372,7 @@ static struct platform_driver ux500_driver = {
.remove = ux500_remove,
.driver = {
.name = "musb-ux500",
- .pm = &ux500_pm_ops,
+ .pm = pm_ptr(&ux500_pm_ops),
.of_match_table = ux500_match,
},
};
--
2.28.0

2020-09-03 15:22:20

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 04/20] usb/host: ehci-platform: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/host/ehci-platform.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 006c4f6188a5..4585a3a24678 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -410,8 +410,7 @@ static int ehci_platform_remove(struct platform_device *dev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int ehci_platform_suspend(struct device *dev)
+static int __maybe_unused ehci_platform_suspend(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
@@ -433,7 +432,7 @@ static int ehci_platform_suspend(struct device *dev)
return ret;
}

-static int ehci_platform_resume(struct device *dev)
+static int __maybe_unused ehci_platform_resume(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
@@ -464,7 +463,6 @@ static int ehci_platform_resume(struct device *dev)

return 0;
}
-#endif /* CONFIG_PM_SLEEP */

static const struct of_device_id vt8500_ehci_ids[] = {
{ .compatible = "via,vt8500-ehci", },
@@ -499,7 +497,7 @@ static struct platform_driver ehci_platform_driver = {
.shutdown = usb_hcd_platform_shutdown,
.driver = {
.name = "ehci-platform",
- .pm = &ehci_platform_pm_ops,
+ .pm = pm_ptr(&ehci_platform_pm_ops),
.of_match_table = vt8500_ehci_ids,
.acpi_match_table = ACPI_PTR(ehci_acpi_match),
}
--
2.28.0

2020-09-03 15:22:58

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 02/20] usb/host: ehci-spear: Use pm_ptr() macro

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 <[email protected]>
---
drivers/usb/host/ehci-spear.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index add796c78561..3694e450a11a 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -34,8 +34,7 @@ struct spear_ehci {

static struct hc_driver __read_mostly ehci_spear_hc_driver;

-#ifdef CONFIG_PM_SLEEP
-static int ehci_spear_drv_suspend(struct device *dev)
+static int __maybe_unused ehci_spear_drv_suspend(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
bool do_wakeup = device_may_wakeup(dev);
@@ -43,14 +42,13 @@ static int ehci_spear_drv_suspend(struct device *dev)
return ehci_suspend(hcd, do_wakeup);
}

-static int ehci_spear_drv_resume(struct device *dev)
+static int __maybe_unused ehci_spear_drv_resume(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);

ehci_resume(hcd, false);
return 0;
}
-#endif /* CONFIG_PM_SLEEP */

static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend,
ehci_spear_drv_resume);
@@ -155,7 +153,7 @@ static struct platform_driver spear_ehci_hcd_driver = {
.driver = {
.name = "spear-ehci",
.bus = &platform_bus_type,
- .pm = &ehci_spear_pm_ops,
+ .pm = pm_ptr(&ehci_spear_pm_ops),
.of_match_table = spear_ehci_id_table,
}
};
--
2.28.0

2020-09-03 15:37:22

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH 01/20] usb/host: ohci-platform: Use pm_ptr() macro

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 <[email protected]>
> ---
> 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
>

2020-09-03 15:48:43

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH 04/20] usb/host: ehci-platform: Use pm_ptr() macro

On Thu, Sep 03, 2020 at 01:25:38PM +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 <[email protected]>
> ---
> drivers/usb/host/ehci-platform.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
> index 006c4f6188a5..4585a3a24678 100644
> --- a/drivers/usb/host/ehci-platform.c
> +++ b/drivers/usb/host/ehci-platform.c
> @@ -410,8 +410,7 @@ static int ehci_platform_remove(struct platform_device *dev)
> return 0;
> }
>
> -#ifdef CONFIG_PM_SLEEP
> -static int ehci_platform_suspend(struct device *dev)
> +static int __maybe_unused ehci_platform_suspend(struct device *dev)
> {
> struct usb_hcd *hcd = dev_get_drvdata(dev);
> struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
> @@ -433,7 +432,7 @@ static int ehci_platform_suspend(struct device *dev)
> return ret;
> }
>
> -static int ehci_platform_resume(struct device *dev)
> +static int __maybe_unused ehci_platform_resume(struct device *dev)
> {
> struct usb_hcd *hcd = dev_get_drvdata(dev);
> struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
> @@ -464,7 +463,6 @@ static int ehci_platform_resume(struct device *dev)
>
> return 0;
> }
> -#endif /* CONFIG_PM_SLEEP */
>
> static const struct of_device_id vt8500_ehci_ids[] = {
> { .compatible = "via,vt8500-ehci", },
> @@ -499,7 +497,7 @@ static struct platform_driver ehci_platform_driver = {
> .shutdown = usb_hcd_platform_shutdown,
> .driver = {
> .name = "ehci-platform",
> - .pm = &ehci_platform_pm_ops,
> + .pm = pm_ptr(&ehci_platform_pm_ops),
> .of_match_table = vt8500_ehci_ids,
> .acpi_match_table = ACPI_PTR(ehci_acpi_match),
> }
> --
> 2.28.0

For patches 2 - 4:

Acked-by: Alan Stern <[email protected]>

2020-09-05 00:03:51

by Peter Chen

[permalink] [raw]
Subject: Re: [PATCH 06/20] usb/chipidea: core: Use pm_ptr() macro

On 20-09-03 13:25:40, 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.

For using __maybe_unused or using MACRO, it depends. The chipidea core
has many functions are only used for power management, you need to add
__maybe_unused for everyone of them, I still prefer using MACRO.

Peter
>
> Signed-off-by: Paul Cercueil <[email protected]>
> ---
> drivers/usb/chipidea/core.c | 26 +++++++++++---------------
> 1 file changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index aa40e510b806..af64ab98fb56 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -1231,9 +1231,8 @@ static int ci_hdrc_remove(struct platform_device *pdev)
> return 0;
> }
>
> -#ifdef CONFIG_PM
> /* Prepare wakeup by SRP before suspend */
> -static void ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
> +static void __maybe_unused ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
> {
> if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
> !hw_read_otgsc(ci, OTGSC_ID)) {
> @@ -1245,7 +1244,7 @@ static void ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
> }
>
> /* Handle SRP when wakeup by data pulse */
> -static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
> +static void __maybe_unused ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
> {
> if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
> (ci->fsm.a_bus_drop == 1) && (ci->fsm.a_bus_req == 0)) {
> @@ -1259,7 +1258,7 @@ static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
> }
> }
>
> -static void ci_controller_suspend(struct ci_hdrc *ci)
> +static void __maybe_unused ci_controller_suspend(struct ci_hdrc *ci)
> {
> disable_irq(ci->irq);
> ci_hdrc_enter_lpm(ci, true);
> @@ -1277,7 +1276,7 @@ static void ci_controller_suspend(struct ci_hdrc *ci)
> * interrupt (wakeup int) only let the controller be out of
> * low power mode, but not handle any interrupts.
> */
> -static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
> +static void __maybe_unused ci_extcon_wakeup_int(struct ci_hdrc *ci)
> {
> struct ci_hdrc_cable *cable_id, *cable_vbus;
> u32 otgsc = hw_read_otgsc(ci, ~0);
> @@ -1294,7 +1293,7 @@ static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
> ci_irq(ci->irq, ci);
> }
>
> -static int ci_controller_resume(struct device *dev)
> +static int __maybe_unused ci_controller_resume(struct device *dev)
> {
> struct ci_hdrc *ci = dev_get_drvdata(dev);
> int ret;
> @@ -1332,8 +1331,7 @@ static int ci_controller_resume(struct device *dev)
> return 0;
> }
>
> -#ifdef CONFIG_PM_SLEEP
> -static int ci_suspend(struct device *dev)
> +static int __maybe_unused ci_suspend(struct device *dev)
> {
> struct ci_hdrc *ci = dev_get_drvdata(dev);
>
> @@ -1366,7 +1364,7 @@ static int ci_suspend(struct device *dev)
> return 0;
> }
>
> -static int ci_resume(struct device *dev)
> +static int __maybe_unused ci_resume(struct device *dev)
> {
> struct ci_hdrc *ci = dev_get_drvdata(dev);
> int ret;
> @@ -1386,9 +1384,8 @@ static int ci_resume(struct device *dev)
>
> return ret;
> }
> -#endif /* CONFIG_PM_SLEEP */
>
> -static int ci_runtime_suspend(struct device *dev)
> +static int __maybe_unused ci_runtime_suspend(struct device *dev)
> {
> struct ci_hdrc *ci = dev_get_drvdata(dev);
>
> @@ -1408,13 +1405,12 @@ static int ci_runtime_suspend(struct device *dev)
> return 0;
> }
>
> -static int ci_runtime_resume(struct device *dev)
> +static int __maybe_unused ci_runtime_resume(struct device *dev)
> {
> return ci_controller_resume(dev);
> }
>
> -#endif /* CONFIG_PM */
> -static const struct dev_pm_ops ci_pm_ops = {
> +static const struct dev_pm_ops __maybe_unused ci_pm_ops = {
> SET_SYSTEM_SLEEP_PM_OPS(ci_suspend, ci_resume)
> SET_RUNTIME_PM_OPS(ci_runtime_suspend, ci_runtime_resume, NULL)
> };
> @@ -1424,7 +1420,7 @@ static struct platform_driver ci_hdrc_driver = {
> .remove = ci_hdrc_remove,
> .driver = {
> .name = "ci_hdrc",
> - .pm = &ci_pm_ops,
> + .pm = pm_ptr(&ci_pm_ops),
> .dev_groups = ci_groups,
> },
> };
> --
> 2.28.0
>

--

Thanks,
Peter Chen

2020-09-05 00:09:37

by Peter Chen

[permalink] [raw]
Subject: Re: [PATCH 14/20] usb/phy: mxs-usb: Use pm_ptr() macro

On 20-09-03 13:25:48, 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 <[email protected]>
> ---
> drivers/usb/phy/phy-mxs-usb.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index 67b39dc62b37..c5e32d51563f 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -815,8 +815,8 @@ static int mxs_phy_remove(struct platform_device *pdev)
> return 0;
> }
>
> -#ifdef CONFIG_PM_SLEEP
> -static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on)
> +static void __maybe_unused
> +mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on)
> {
> unsigned int reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR;
>
> @@ -832,7 +832,7 @@ static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on)
> reg, BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL);
> }
>
> -static int mxs_phy_system_suspend(struct device *dev)
> +static int __maybe_unused mxs_phy_system_suspend(struct device *dev)
> {
> struct mxs_phy *mxs_phy = dev_get_drvdata(dev);
>
> @@ -842,7 +842,7 @@ static int mxs_phy_system_suspend(struct device *dev)
> return 0;
> }
>
> -static int mxs_phy_system_resume(struct device *dev)
> +static int __maybe_unused mxs_phy_system_resume(struct device *dev)
> {
> struct mxs_phy *mxs_phy = dev_get_drvdata(dev);
>
> @@ -851,7 +851,6 @@ static int mxs_phy_system_resume(struct device *dev)
>
> return 0;
> }
> -#endif /* CONFIG_PM_SLEEP */
>
> static SIMPLE_DEV_PM_OPS(mxs_phy_pm, mxs_phy_system_suspend,
> mxs_phy_system_resume);
> @@ -862,7 +861,7 @@ static struct platform_driver mxs_phy_driver = {
> .driver = {
> .name = DRIVER_NAME,
> .of_match_table = mxs_phy_dt_ids,
> - .pm = &mxs_phy_pm,
> + .pm = pm_ptr(&mxs_phy_pm),
> },
> };
>
> --

Acked-by: Peter Chen <[email protected]>

--

Thanks,
Peter Chen

2020-09-07 06:08:45

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 14/20] usb/phy: mxs-usb: Use pm_ptr() macro

Paul Cercueil <[email protected]> writes:

> 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 <[email protected]>
> ---

Acked-by: Felipe Balbi <[email protected]>

--
balbi


Attachments:
signature.asc (873.00 B)