2016-03-02 16:01:38

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 00/14] drivers: use __maybe_unused to hide pm functions

I found many variations of the bug in these device drivers (and some
USB drivers I already send patches for in a separate series).

In each case, the power management operations structure conditionally
references suspend/resume functions, but the functions are hidden
in an incorrect #ifdef or not hidden at all.

We could try to correct the #ifdefs, but it seems easier to just
mark those functions as __maybe_unused, which has the same effect
but provides better compile-time test coverage and (subjectively)
looks a bit nicer.

I have a patch series that avoids all warnings in ARM randconfig
builds, and I have verified that all these patches fix a warning that
is still present in today's linux-next, and that they do not
introduce new warnings in any configuration I found.

Note that all these drivers are ARM specific, so I assume that
all portable drivers got fixed already when someone rand into
the problem on x86.

There are no dependencies between the patches, so I'd appreciate
subsystem maintainers to put them directly into their git trees.

Arnd

Arnd Bergmann (14):
pinctrl: at91: use __maybe_unused to hide pm functions
irqchip: st: use __maybe_unused to hide st_irq_syscfg_resume
power: ipaq-micro-battery: use __maybe_unused to hide pm functions
power: pm2301-charger: use __maybe_unused to hide pm functions
mfd: ipaq-micro: use __maybe_unused to hide pm functions
dma: sirf: use __maybe_unused to hide pm functions
hw_random: exynos: use __maybe_unused to hide pm functions
scsi: mvumi: use __maybe_unused to hide pm functions
amd-xgbe: use __maybe_unused to hide pm functions
wireless: cw1200: use __maybe_unused to hide pm functions_
input: spear-keyboard: use __maybe_unused to hide pm functions
keyboard: snvs-pwrkey: use __maybe_unused to hide pm functions
[media] omap3isp: use IS_ENABLED() to hide pm functions
ASoC: rockchip: use __maybe_unused to hide st_irq_syscfg_resume

drivers/char/hw_random/exynos-rng.c | 10 ++++------
drivers/dma/sirf-dma.c | 10 ++++------
drivers/input/keyboard/snvs_pwrkey.c | 4 ++--
drivers/input/keyboard/spear-keyboard.c | 6 ++----
drivers/irqchip/irq-st.c | 2 +-
drivers/media/platform/omap3isp/isp.c | 13 +------------
drivers/mfd/ipaq-micro.c | 2 +-
drivers/net/ethernet/amd/xgbe/xgbe-main.c | 6 ++----
drivers/net/wireless/st/cw1200/cw1200_spi.c | 9 ++-------
drivers/net/wireless/st/cw1200/pm.h | 9 +++++++--
drivers/pinctrl/pinctrl-at91-pio4.c | 4 ++--
drivers/power/ipaq_micro_battery.c | 4 ++--
drivers/power/pm2301_charger.c | 22 ++++++----------------
drivers/scsi/mvumi.c | 4 ++--
sound/soc/rockchip/rockchip_spdif.c | 4 ++--
15 files changed, 40 insertions(+), 69 deletions(-)

--
2.7.0
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]


2016-03-02 16:00:44

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 06/14] dma: sirf: use __maybe_unused to hide pm functions

The sirf dma driver uses #ifdef to check for CONFIG_PM_SLEEP
for its suspend/resume code but then has no #ifdef for the
respective runtime PM code, so we get a warning if CONFIG_PM
is disabled altogether:

drivers/dma/sirf-dma.c:1000:12: error: 'sirfsoc_dma_runtime_resume' defined but not used [-Werror=unused-function]

This removes the existing #ifdef and instead uses __maybe_unused
annotations for all four functions to let the compiler know it
can silently drop the function definition.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/dma/sirf-dma.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index 22ea2419ee56..e48350e65089 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -989,7 +989,7 @@ static int sirfsoc_dma_remove(struct platform_device *op)
return 0;
}

-static int sirfsoc_dma_runtime_suspend(struct device *dev)
+static int __maybe_unused sirfsoc_dma_runtime_suspend(struct device *dev)
{
struct sirfsoc_dma *sdma = dev_get_drvdata(dev);

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

-static int sirfsoc_dma_runtime_resume(struct device *dev)
+static int __maybe_unused sirfsoc_dma_runtime_resume(struct device *dev)
{
struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
int ret;
@@ -1010,8 +1010,7 @@ static int sirfsoc_dma_runtime_resume(struct device *dev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int sirfsoc_dma_pm_suspend(struct device *dev)
+static int __maybe_unused sirfsoc_dma_pm_suspend(struct device *dev)
{
struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
struct sirfsoc_dma_regs *save = &sdma->regs_save;
@@ -1062,7 +1061,7 @@ static int sirfsoc_dma_pm_suspend(struct device *dev)
return 0;
}

-static int sirfsoc_dma_pm_resume(struct device *dev)
+static int __maybe_unused sirfsoc_dma_pm_resume(struct device *dev)
{
struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
struct sirfsoc_dma_regs *save = &sdma->regs_save;
@@ -1121,7 +1120,6 @@ static int sirfsoc_dma_pm_resume(struct device *dev)

return 0;
}
-#endif

static const struct dev_pm_ops sirfsoc_dma_pm_ops = {
SET_RUNTIME_PM_OPS(sirfsoc_dma_runtime_suspend, sirfsoc_dma_runtime_resume, NULL)
--
2.7.0

2016-03-02 16:00:49

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 08/14] scsi: mvumi: use __maybe_unused to hide pm functions

The mvumi scsi hides the references to its suspend/resume functions
in an #ifdef but does not hide the implementation the same way:

drivers/scsi/mvumi.c:2632:12: error: 'mvumi_suspend' defined but not used [-Werror=unused-function]
drivers/scsi/mvumi.c:2651:12: error: 'mvumi_resume' defined but not used [-Werror=unused-function]

This adds __maybe_unused annotations so the compiler knows
it can silently drop them instead of warning, while avoiding
the addition of another #ifdef.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/scsi/mvumi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index 02360de6b7e0..39285070f3b5 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -2629,7 +2629,7 @@ static void mvumi_shutdown(struct pci_dev *pdev)
mvumi_flush_cache(mhba);
}

-static int mvumi_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __maybe_unused mvumi_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct mvumi_hba *mhba = NULL;

@@ -2648,7 +2648,7 @@ static int mvumi_suspend(struct pci_dev *pdev, pm_message_t state)
return 0;
}

-static int mvumi_resume(struct pci_dev *pdev)
+static int __maybe_unused mvumi_resume(struct pci_dev *pdev)
{
int ret;
struct mvumi_hba *mhba = NULL;
--
2.7.0

2016-03-02 16:00:54

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 10/14] wireless: cw1200: use __maybe_unused to hide pm functions_

The cw1200 uses #ifdef to check for CONFIG_PM, but then
uses SIMPLE_DEV_PM_OPS, which leaves the references out when
CONFIG_PM_SLEEP is not defined, so we get a warning with
PM=y && PM_SLEEP=n:

drivers/net/wireless/st/cw1200/cw1200_spi.c:450:12: error: 'cw1200_spi_suspend' defined but not used [-Werror=unused-function]

This removes the incorrect #ifdef and instead uses a __maybe_unused
annotation to let the compiler know it can silently drop
the function definition.

For the DEV_PM_OPS definition, we can use an IS_ENABLED() check
to avoid defining the structure when CONFIG_PM is not set without
the #ifdef.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/net/wireless/st/cw1200/cw1200_spi.c | 9 ++-------
drivers/net/wireless/st/cw1200/pm.h | 9 +++++++--
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/cw1200_spi.c b/drivers/net/wireless/st/cw1200/cw1200_spi.c
index a740083634d8..63f95e9c2992 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_spi.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_spi.c
@@ -446,8 +446,7 @@ static int cw1200_spi_disconnect(struct spi_device *func)
return 0;
}

-#ifdef CONFIG_PM
-static int cw1200_spi_suspend(struct device *dev)
+static int __maybe_unused cw1200_spi_suspend(struct device *dev)
{
struct hwbus_priv *self = spi_get_drvdata(to_spi_device(dev));

@@ -460,16 +459,12 @@ static int cw1200_spi_suspend(struct device *dev)

static SIMPLE_DEV_PM_OPS(cw1200_pm_ops, cw1200_spi_suspend, NULL);

-#endif
-
static struct spi_driver spi_driver = {
.probe = cw1200_spi_probe,
.remove = cw1200_spi_disconnect,
.driver = {
.name = "cw1200_wlan_spi",
-#ifdef CONFIG_PM
- .pm = &cw1200_pm_ops,
-#endif
+ .pm = IS_ENABLED(CONFIG_PM) ? &cw1200_pm_ops : NULL,
},
};

diff --git a/drivers/net/wireless/st/cw1200/pm.h b/drivers/net/wireless/st/cw1200/pm.h
index 3ed90ff22bb8..534548470ebc 100644
--- a/drivers/net/wireless/st/cw1200/pm.h
+++ b/drivers/net/wireless/st/cw1200/pm.h
@@ -31,13 +31,18 @@ int cw1200_pm_init(struct cw1200_pm_state *pm,
void cw1200_pm_deinit(struct cw1200_pm_state *pm);
int cw1200_wow_suspend(struct ieee80211_hw *hw,
struct cfg80211_wowlan *wowlan);
-int cw1200_wow_resume(struct ieee80211_hw *hw);
int cw1200_can_suspend(struct cw1200_common *priv);
+int cw1200_wow_resume(struct ieee80211_hw *hw);
void cw1200_pm_stay_awake(struct cw1200_pm_state *pm,
unsigned long tmo);
#else
static inline void cw1200_pm_stay_awake(struct cw1200_pm_state *pm,
- unsigned long tmo) {
+ unsigned long tmo)
+{
+}
+static inline int cw1200_can_suspend(struct cw1200_common *priv)
+{
+ return 0;
}
#endif
#endif
--
2.7.0

2016-03-02 16:01:10

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 11/14] input: spear-keyboard: use __maybe_unused to hide pm functions

The spear keyboard driver uses #ifdef CONFIG_PM to hide its
power management functions, but then uses references from
SIMPLE_DEV_PM_OPS that are only present if both CONFIG_PM
and CONFIG_PM_SLEEP are set, resulting in a warning about unused
functions:

drivers/input/keyboard/spear-keyboard.c:292:12: error: 'spear_kbd_suspend' defined but not used [-Werror=unused-function]
drivers/input/keyboard/spear-keyboard.c:345:12: error: 'spear_kbd_resume' defined but not used [-Werror=unused-function]

This removes the #ifdef and instead uses a __maybe_unused
annotation.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/input/keyboard/spear-keyboard.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index 623d451767e3..8083eaa0524a 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -288,8 +288,7 @@ static int spear_kbd_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM
-static int spear_kbd_suspend(struct device *dev)
+static int __maybe_unused spear_kbd_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct spear_kbd *kbd = platform_get_drvdata(pdev);
@@ -342,7 +341,7 @@ static int spear_kbd_suspend(struct device *dev)
return 0;
}

-static int spear_kbd_resume(struct device *dev)
+static int __maybe_unused spear_kbd_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct spear_kbd *kbd = platform_get_drvdata(pdev);
@@ -368,7 +367,6 @@ static int spear_kbd_resume(struct device *dev)

return 0;
}
-#endif

static SIMPLE_DEV_PM_OPS(spear_kbd_pm_ops, spear_kbd_suspend, spear_kbd_resume);

--
2.7.0

2016-03-02 16:01:40

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 14/14] ASoC: rockchip: use __maybe_unused to hide st_irq_syscfg_resume

The rockchip spdif driver uses SIMPLE_DEV_PM_OPS to conditionally
set its power management functions, but we get a warning
about rk_spdif_runtime_resume being unused when CONFIG_PM is not
set:

sound/soc/rockchip/rockchip_spdif.c:67:12: error: 'rk_spdif_runtime_resume' defined but not used [-Werror=unused-function]

This adds a __maybe_unused annotation so the compiler knows
it can silently drop it instead of warning.

Signed-off-by: Arnd Bergmann <[email protected]>
---
sound/soc/rockchip/rockchip_spdif.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_spdif.c b/sound/soc/rockchip/rockchip_spdif.c
index 5a806da89f42..274599d4caeb 100644
--- a/sound/soc/rockchip/rockchip_spdif.c
+++ b/sound/soc/rockchip/rockchip_spdif.c
@@ -54,7 +54,7 @@ static const struct of_device_id rk_spdif_match[] = {
};
MODULE_DEVICE_TABLE(of, rk_spdif_match);

-static int rk_spdif_runtime_suspend(struct device *dev)
+static int __maybe_unused rk_spdif_runtime_suspend(struct device *dev)
{
struct rk_spdif_dev *spdif = dev_get_drvdata(dev);

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

-static int rk_spdif_runtime_resume(struct device *dev)
+static int __maybe_unused rk_spdif_runtime_resume(struct device *dev)
{
struct rk_spdif_dev *spdif = dev_get_drvdata(dev);
int ret;
--
2.7.0

2016-03-02 16:00:51

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 03/14] power: ipaq-micro-battery: use __maybe_unused to hide pm functions

The ipaq micro battery driver has suspend/resume functions that
are accessed using SIMPLE_DEV_PM_OPS, which hide the reference
when CONFIG_PM_SLEEP is not set, resulting in a warning about
unused functions:

drivers/power/ipaq_micro_battery.c:284:12: error: 'micro_batt_suspend' defined but not used [-Werror=unused-function]
drivers/power/ipaq_micro_battery.c:292:12: error: 'micro_batt_resume' defined but not used [-Werror=unused-function]

This adds __maybe_unused annotations to let the compiler know
it can silently drop the function definition.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/power/ipaq_micro_battery.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/ipaq_micro_battery.c b/drivers/power/ipaq_micro_battery.c
index f03014ea1dc4..3f314b1a30d7 100644
--- a/drivers/power/ipaq_micro_battery.c
+++ b/drivers/power/ipaq_micro_battery.c
@@ -281,7 +281,7 @@ static int micro_batt_remove(struct platform_device *pdev)
return 0;
}

-static int micro_batt_suspend(struct device *dev)
+static int __maybe_unused micro_batt_suspend(struct device *dev)
{
struct micro_battery *mb = dev_get_drvdata(dev);

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

-static int micro_batt_resume(struct device *dev)
+static int __maybe_unused micro_batt_resume(struct device *dev)
{
struct micro_battery *mb = dev_get_drvdata(dev);

--
2.7.0

2016-03-02 16:02:38

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 12/14] keyboard: snvs-pwrkey: use __maybe_unused to hide pm functions

The SNVS power key driver has suspend/resume functions that
are accessed using SIMPLE_DEV_PM_OPS, which hide the reference
when CONFIG_PM_SLEEP is not set, resulting in a warning about
unused functions:

drivers/input/keyboard/snvs_pwrkey.c:183:12: error: 'imx_snvs_pwrkey_suspend' defined but not used [-Werror=unused-function]
drivers/input/keyboard/snvs_pwrkey.c:194:12: error: 'imx_snvs_pwrkey_resume' defined but not used [-Werror=unused-function]

This adds __maybe_unused annotations to let the compiler know
it can silently drop the function definition.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/input/keyboard/snvs_pwrkey.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
index 9adf13a5864a..b0ffadeb208c 100644
--- a/drivers/input/keyboard/snvs_pwrkey.c
+++ b/drivers/input/keyboard/snvs_pwrkey.c
@@ -180,7 +180,7 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
return 0;
}

-static int imx_snvs_pwrkey_suspend(struct device *dev)
+static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
@@ -191,7 +191,7 @@ static int imx_snvs_pwrkey_suspend(struct device *dev)
return 0;
}

-static int imx_snvs_pwrkey_resume(struct device *dev)
+static int __maybe_unused imx_snvs_pwrkey_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
--
2.7.0

2016-03-02 16:03:06

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 04/14] power: pm2301-charger: use __maybe_unused to hide pm functions

The pm2301 charger driver uses nested #ifdefs to check for both
CONFIG_PM and CONFIG_PM_SLEEP in an attempt to hide its
suspend and runtime-pm operations when they are unused, but
it does not hide the clear_lpn_pin() function in the same
way, so we get a build warning when everything is
disabled:

drivers/power/pm2301_charger.c:123:13: error: 'clear_lpn_pin' defined but not used [-Werror=unused-function]

This removes all the #ifdef and instead uses __maybe_unused
annotations to let the compiler know it can silently drop
the function definition.

For the PM2XXX_PM_OPS, we can use an IS_ENABLED() check
to avoid defining the structure when CONFIG_PM is not set without
the #ifdef.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/power/pm2301_charger.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
index 8f9bd1d0eeb6..fb62ed3fc38c 100644
--- a/drivers/power/pm2301_charger.c
+++ b/drivers/power/pm2301_charger.c
@@ -911,11 +911,7 @@ static struct pm2xxx_irq pm2xxx_charger_irq[] = {
{"PM2XXX_IRQ_INT", pm2xxx_irq_int},
};

-#ifdef CONFIG_PM
-
-#ifdef CONFIG_PM_SLEEP
-
-static int pm2xxx_wall_charger_resume(struct device *dev)
+static int __maybe_unused pm2xxx_wall_charger_resume(struct device *dev)
{
struct i2c_client *i2c_client = to_i2c_client(dev);
struct pm2xxx_charger *pm2;
@@ -931,7 +927,7 @@ static int pm2xxx_wall_charger_resume(struct device *dev)
return 0;
}

-static int pm2xxx_wall_charger_suspend(struct device *dev)
+static int __maybe_unused pm2xxx_wall_charger_suspend(struct device *dev)
{
struct i2c_client *i2c_client = to_i2c_client(dev);
struct pm2xxx_charger *pm2;
@@ -949,9 +945,7 @@ static int pm2xxx_wall_charger_suspend(struct device *dev)
return 0;
}

-#endif
-
-static int pm2xxx_runtime_suspend(struct device *dev)
+static int __maybe_unused pm2xxx_runtime_suspend(struct device *dev)
{
struct i2c_client *pm2xxx_i2c_client = to_i2c_client(dev);
struct pm2xxx_charger *pm2;
@@ -962,7 +956,7 @@ static int pm2xxx_runtime_suspend(struct device *dev)
return 0;
}

-static int pm2xxx_runtime_resume(struct device *dev)
+static int __maybe_unused pm2xxx_runtime_resume(struct device *dev)
{
struct i2c_client *pm2xxx_i2c_client = to_i2c_client(dev);
struct pm2xxx_charger *pm2;
@@ -975,15 +969,11 @@ static int pm2xxx_runtime_resume(struct device *dev)
return 0;
}

-static const struct dev_pm_ops pm2xxx_pm_ops = {
+static const struct dev_pm_ops pm2xxx_pm_ops __maybe_unused = {
SET_SYSTEM_SLEEP_PM_OPS(pm2xxx_wall_charger_suspend,
pm2xxx_wall_charger_resume)
SET_RUNTIME_PM_OPS(pm2xxx_runtime_suspend, pm2xxx_runtime_resume, NULL)
};
-#define PM2XXX_PM_OPS (&pm2xxx_pm_ops)
-#else
-#define PM2XXX_PM_OPS NULL
-#endif

static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
const struct i2c_device_id *id)
@@ -1244,7 +1234,7 @@ static struct i2c_driver pm2xxx_charger_driver = {
.remove = pm2xxx_wall_charger_remove,
.driver = {
.name = "pm2xxx-wall_charger",
- .pm = PM2XXX_PM_OPS,
+ .pm = IS_ENABLED(CONFIG_PM) ? &pm2xxx_pm_ops : NULL,
},
.id_table = pm2xxx_id,
};
--
2.7.0

2016-03-02 16:04:30

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 13/14] [media] omap3isp: use IS_ENABLED() to hide pm functions

The omap3isp driver hides is power management functions using #ifdef
but it fails to hide the isp_suspend_modules/isp_resume_modules
functions in the same way, which leads to a build warning when
CONFIG_PM is disabled:

drivers/media/platform/omap3isp/isp.c:1183:12: error: 'isp_suspend_modules' defined but not used [-Werror=unused-function]
drivers/media/platform/omap3isp/isp.c:1217:13: error: 'isp_resume_modules' defined but not used [-Werror=unused-function]

As the driver manually defines its dev_pm_ops structure and all
members are NULL without CONFIG_PM, we can simply avoid referencing
the structure using an IS_ENABLED() check, and drop all the #ifdef
to avoid all warnings.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/media/platform/omap3isp/isp.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index f9e5245f26ac..7f118baca270 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1713,8 +1713,6 @@ void omap3isp_print_status(struct isp_device *isp)
dev_dbg(isp->dev, "--------------------------------------------\n");
}

-#ifdef CONFIG_PM
-
/*
* Power management support.
*
@@ -1785,15 +1783,6 @@ static void isp_pm_complete(struct device *dev)
isp_resume_modules(isp);
}

-#else
-
-#define isp_pm_prepare NULL
-#define isp_pm_suspend NULL
-#define isp_pm_resume NULL
-#define isp_pm_complete NULL
-
-#endif /* CONFIG_PM */
-
static void isp_unregister_entities(struct isp_device *isp)
{
omap3isp_csi2_unregister_entities(&isp->isp_csi2a);
@@ -2611,7 +2600,7 @@ static struct platform_driver omap3isp_driver = {
.id_table = omap3isp_id_table,
.driver = {
.name = "omap3isp",
- .pm = &omap3isp_pm_ops,
+ .pm = IS_ENABLED(CONFIG_PM) ? &omap3isp_pm_ops : NULL,
.of_match_table = omap3isp_of_table,
},
};
--
2.7.0

2016-03-02 16:04:29

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 07/14] hw_random: exynos: use __maybe_unused to hide pm functions

The exynos random driver uses #ifdef to check for CONFIG_PM, but
then uses SIMPLE_DEV_PM_OPS, which leaves the references out when
CONFIG_PM_SLEEP is not defined, so we get a warning with
PM=y && PM_SLEEP=n:

drivers/char/hw_random/exynos-rng.c:166:12: error: 'exynos_rng_suspend' defined but not used [-Werror=unused-function]
drivers/char/hw_random/exynos-rng.c:171:12: error: 'exynos_rng_resume' defined but not used [-Werror=unused-function]

This removes the incorrect #ifdef and instead uses a __maybe_unused
annotation to let the compiler know it can silently drop
the function definition.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/char/hw_random/exynos-rng.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c
index 30cf4623184f..ada081232528 100644
--- a/drivers/char/hw_random/exynos-rng.c
+++ b/drivers/char/hw_random/exynos-rng.c
@@ -144,8 +144,7 @@ static int exynos_rng_probe(struct platform_device *pdev)
return devm_hwrng_register(&pdev->dev, &exynos_rng->rng);
}

-#ifdef CONFIG_PM
-static int exynos_rng_runtime_suspend(struct device *dev)
+static int __maybe_unused exynos_rng_runtime_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct exynos_rng *exynos_rng = platform_get_drvdata(pdev);
@@ -155,7 +154,7 @@ static int exynos_rng_runtime_suspend(struct device *dev)
return 0;
}

-static int exynos_rng_runtime_resume(struct device *dev)
+static int __maybe_unused exynos_rng_runtime_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct exynos_rng *exynos_rng = platform_get_drvdata(pdev);
@@ -163,12 +162,12 @@ static int exynos_rng_runtime_resume(struct device *dev)
return clk_prepare_enable(exynos_rng->clk);
}

-static int exynos_rng_suspend(struct device *dev)
+static int __maybe_unused exynos_rng_suspend(struct device *dev)
{
return pm_runtime_force_suspend(dev);
}

-static int exynos_rng_resume(struct device *dev)
+static int __maybe_unused exynos_rng_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct exynos_rng *exynos_rng = platform_get_drvdata(pdev);
@@ -180,7 +179,6 @@ static int exynos_rng_resume(struct device *dev)

return exynos_rng_configure(exynos_rng);
}
-#endif

static const struct dev_pm_ops exynos_rng_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(exynos_rng_suspend, exynos_rng_resume)
--
2.7.0

2016-03-02 16:05:59

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 09/14] amd-xgbe: use __maybe_unused to hide pm functions

The amd-xgbe ethernet driver hides its suspend/resume functions
in #ifdef CONFIG_PM, but uses SIMPLE_DEV_PM_OPS() to make the
reference conditional on CONFIG_PM_SLEEP, which results in a
warning when PM_SLEEP is not set but PM is:

drivers/net/ethernet/amd/xgbe/xgbe-main.c:833:12: warning: 'xgbe_suspend' defined but not used [-Wunused-function]
drivers/net/ethernet/amd/xgbe/xgbe-main.c:853:12: warning: 'xgbe_resume' defined but not used [-Wunused-function]

This removes the incorrect #ifdef and instead uses a __maybe_unused
annotation to let the compiler know it can silently drop
the function definition.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/net/ethernet/amd/xgbe/xgbe-main.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index 3eee3201b58f..a86f32106639 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -829,8 +829,7 @@ static int xgbe_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM
-static int xgbe_suspend(struct device *dev)
+static int __maybe_unused xgbe_suspend(struct device *dev)
{
struct net_device *netdev = dev_get_drvdata(dev);
struct xgbe_prv_data *pdata = netdev_priv(netdev);
@@ -850,7 +849,7 @@ static int xgbe_suspend(struct device *dev)
return ret;
}

-static int xgbe_resume(struct device *dev)
+static int __maybe_unused xgbe_resume(struct device *dev)
{
struct net_device *netdev = dev_get_drvdata(dev);
struct xgbe_prv_data *pdata = netdev_priv(netdev);
@@ -868,7 +867,6 @@ static int xgbe_resume(struct device *dev)

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

#ifdef CONFIG_ACPI
static const struct acpi_device_id xgbe_acpi_match[] = {
--
2.7.0

2016-03-02 16:06:53

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH 01/14] pinctrl: at91: use __maybe_unused to hide pm functions

Le 02/03/2016 16:58, Arnd Bergmann a ?crit :
> The at91-pio4 pinctrl driver uses SET_SYSTEM_SLEEP_PM_OPS() to
> conditionally set the correct suspend/resume options, but they
> become unused when CONFIG_PM is disabled:
>
> drivers/pinctrl/pinctrl-at91-pio4.c:827:12: error: 'atmel_pctrl_suspend' defined but not used [-Werror=unused-function]
> drivers/pinctrl/pinctrl-at91-pio4.c:847:12: error: 'atmel_pctrl_resume' defined but not used [-Werror=unused-function]
>
> This adds __maybe_unused annotations so the compiler knows
> it can silently drop them instead of warning.
>
> Signed-off-by: Arnd Bergmann <[email protected]>

Indeed, nice like this:
Acked-by: Nicolas Ferre <[email protected]>

Thanks, bye.


> ---
> drivers/pinctrl/pinctrl-at91-pio4.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
> index ee69db6ae1c7..4429312e848d 100644
> --- a/drivers/pinctrl/pinctrl-at91-pio4.c
> +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
> @@ -824,7 +824,7 @@ static struct pinctrl_desc atmel_pinctrl_desc = {
> .pmxops = &atmel_pmxops,
> };
>
> -static int atmel_pctrl_suspend(struct device *dev)
> +static int __maybe_unused atmel_pctrl_suspend(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
> @@ -844,7 +844,7 @@ static int atmel_pctrl_suspend(struct device *dev)
> return 0;
> }
>
> -static int atmel_pctrl_resume(struct device *dev)
> +static int __maybe_unused atmel_pctrl_resume(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
>


--
Nicolas Ferre

2016-03-02 16:00:23

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 01/14] pinctrl: at91: use __maybe_unused to hide pm functions

The at91-pio4 pinctrl driver uses SET_SYSTEM_SLEEP_PM_OPS() to
conditionally set the correct suspend/resume options, but they
become unused when CONFIG_PM is disabled:

drivers/pinctrl/pinctrl-at91-pio4.c:827:12: error: 'atmel_pctrl_suspend' defined but not used [-Werror=unused-function]
drivers/pinctrl/pinctrl-at91-pio4.c:847:12: error: 'atmel_pctrl_resume' defined but not used [-Werror=unused-function]

This adds __maybe_unused annotations so the compiler knows
it can silently drop them instead of warning.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/pinctrl/pinctrl-at91-pio4.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index ee69db6ae1c7..4429312e848d 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -824,7 +824,7 @@ static struct pinctrl_desc atmel_pinctrl_desc = {
.pmxops = &atmel_pmxops,
};

-static int atmel_pctrl_suspend(struct device *dev)
+static int __maybe_unused atmel_pctrl_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
@@ -844,7 +844,7 @@ static int atmel_pctrl_suspend(struct device *dev)
return 0;
}

-static int atmel_pctrl_resume(struct device *dev)
+static int __maybe_unused atmel_pctrl_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
--
2.7.0

2016-03-02 16:07:50

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 02/14] irqchip: st: use __maybe_unused to hide st_irq_syscfg_resume

the st irqchip driver uses SIMPLE_DEV_PM_OPS to conditionally
set its power management functions, but we get a warning
about st_irq_syscfg_resume being unused when CONFIG_PM is not
set:

drivers/irqchip/irq-st.c:183:12: error: 'st_irq_syscfg_resume' defined but not used [-Werror=unused-function]

This adds a __maybe_unused annotation so the compiler knows
it can silently drop it instead of warning.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/irqchip/irq-st.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-st.c b/drivers/irqchip/irq-st.c
index 9af48a85c16f..5e0e250db0be 100644
--- a/drivers/irqchip/irq-st.c
+++ b/drivers/irqchip/irq-st.c
@@ -180,7 +180,7 @@ static int st_irq_syscfg_probe(struct platform_device *pdev)
return st_irq_syscfg_enable(pdev);
}

-static int st_irq_syscfg_resume(struct device *dev)
+static int __maybe_unused st_irq_syscfg_resume(struct device *dev)
{
struct st_irq_syscfg *ddata = dev_get_drvdata(dev);

--
2.7.0

2016-03-02 16:00:20

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 05/14] mfd: ipaq-micro: use __maybe_unused to hide pm functions

The ipaq-micro driver uses SET_SYSTEM_SLEEP_PM_OPS() to
remove the reference to its resume function, but does
not use an #ifdef around the definition, so we get
a build warning:

drivers/mfd/ipaq-micro.c:379:12: error: 'micro_resume' defined but not used [-Werror=unused-function]

This adds a __maybe_unused annotation so the compiler knows
it can silently drop it instead of warning.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/mfd/ipaq-micro.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/ipaq-micro.c b/drivers/mfd/ipaq-micro.c
index a41859c55bda..df16fd1df68b 100644
--- a/drivers/mfd/ipaq-micro.c
+++ b/drivers/mfd/ipaq-micro.c
@@ -376,7 +376,7 @@ static const struct mfd_cell micro_cells[] = {
{ .name = "ipaq-micro-leds", },
};

-static int micro_resume(struct device *dev)
+static int __maybe_unused micro_resume(struct device *dev)
{
struct ipaq_micro *micro = dev_get_drvdata(dev);

--
2.7.0

2016-03-02 16:38:13

by Frank Li

[permalink] [raw]
Subject: RE: [PATCH 12/14] keyboard: snvs-pwrkey: use __maybe_unused to hide pm functions



> -----Original Message-----
> From: Arnd Bergmann [mailto:[email protected]]
> Sent: Wednesday, March 02, 2016 9:59 AM
> To: Dmitry Torokhov <[email protected]>
> Cc: [email protected]; Arnd Bergmann <[email protected]>;
> Shawn Guo <[email protected]>; [email protected]; Javier
> Martinez Canillas <[email protected]>; Frank Li
> <[email protected]>; [email protected]; linux-
> [email protected]
> Subject: [PATCH 12/14] keyboard: snvs-pwrkey: use __maybe_unused to hide
> pm functions
>
> The SNVS power key driver has suspend/resume functions that are accessed
> using SIMPLE_DEV_PM_OPS, which hide the reference when
> CONFIG_PM_SLEEP is not set, resulting in a warning about unused functions:
>
> drivers/input/keyboard/snvs_pwrkey.c:183:12: error:
> 'imx_snvs_pwrkey_suspend' defined but not used [-Werror=unused-function]
> drivers/input/keyboard/snvs_pwrkey.c:194:12: error:
> 'imx_snvs_pwrkey_resume' defined but not used [-Werror=unused-function]
>
> This adds __maybe_unused annotations to let the compiler know it can
> silently drop the function definition.
>
> Signed-off-by: Arnd Bergmann <[email protected]>

Acked-by: Frank Li <[email protected]>

> ---
> drivers/input/keyboard/snvs_pwrkey.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/keyboard/snvs_pwrkey.c
> b/drivers/input/keyboard/snvs_pwrkey.c
> index 9adf13a5864a..b0ffadeb208c 100644
> --- a/drivers/input/keyboard/snvs_pwrkey.c
> +++ b/drivers/input/keyboard/snvs_pwrkey.c
> @@ -180,7 +180,7 @@ static int imx_snvs_pwrkey_probe(struct
> platform_device *pdev)
> return 0;
> }
>
> -static int imx_snvs_pwrkey_suspend(struct device *dev)
> +static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev); @@ -
> 191,7 +191,7 @@ static int imx_snvs_pwrkey_suspend(struct device *dev)
> return 0;
> }
>
> -static int imx_snvs_pwrkey_resume(struct device *dev)
> +static int __maybe_unused imx_snvs_pwrkey_resume(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
> --
> 2.7.0

2016-03-02 16:48:17

by Ludovic Desroches

[permalink] [raw]
Subject: Re: [PATCH 01/14] pinctrl: at91: use __maybe_unused to hide pm functions

On Wed, Mar 02, 2016 at 04:58:53PM +0100, Arnd Bergmann wrote:
> The at91-pio4 pinctrl driver uses SET_SYSTEM_SLEEP_PM_OPS() to
> conditionally set the correct suspend/resume options, but they
> become unused when CONFIG_PM is disabled:
>
> drivers/pinctrl/pinctrl-at91-pio4.c:827:12: error: 'atmel_pctrl_suspend' defined but not used [-Werror=unused-function]
> drivers/pinctrl/pinctrl-at91-pio4.c:847:12: error: 'atmel_pctrl_resume' defined but not used [-Werror=unused-function]
>
> This adds __maybe_unused annotations so the compiler knows
> it can silently drop them instead of warning.
>
> Signed-off-by: Arnd Bergmann <[email protected]>
Acked-by: Ludovic Desroches <[email protected]>

Thanks

> ---
> drivers/pinctrl/pinctrl-at91-pio4.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
> index ee69db6ae1c7..4429312e848d 100644
> --- a/drivers/pinctrl/pinctrl-at91-pio4.c
> +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
> @@ -824,7 +824,7 @@ static struct pinctrl_desc atmel_pinctrl_desc = {
> .pmxops = &atmel_pmxops,
> };
>
> -static int atmel_pctrl_suspend(struct device *dev)
> +static int __maybe_unused atmel_pctrl_suspend(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
> @@ -844,7 +844,7 @@ static int atmel_pctrl_suspend(struct device *dev)
> return 0;
> }
>
> -static int atmel_pctrl_resume(struct device *dev)
> +static int __maybe_unused atmel_pctrl_resume(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
> --
> 2.7.0
>

2016-03-02 17:12:44

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 12/14] keyboard: snvs-pwrkey: use __maybe_unused to hide pm functions

On Wed, Mar 02, 2016 at 04:04:46PM +0000, Frank Li wrote:
>
>
> > -----Original Message-----
> > From: Arnd Bergmann [mailto:[email protected]]
> > Sent: Wednesday, March 02, 2016 9:59 AM
> > To: Dmitry Torokhov <[email protected]>
> > Cc: [email protected]; Arnd Bergmann <[email protected]>;
> > Shawn Guo <[email protected]>; [email protected]; Javier
> > Martinez Canillas <[email protected]>; Frank Li
> > <[email protected]>; [email protected]; linux-
> > [email protected]
> > Subject: [PATCH 12/14] keyboard: snvs-pwrkey: use __maybe_unused to hide
> > pm functions
> >
> > The SNVS power key driver has suspend/resume functions that are accessed
> > using SIMPLE_DEV_PM_OPS, which hide the reference when
> > CONFIG_PM_SLEEP is not set, resulting in a warning about unused functions:
> >
> > drivers/input/keyboard/snvs_pwrkey.c:183:12: error:
> > 'imx_snvs_pwrkey_suspend' defined but not used [-Werror=unused-function]
> > drivers/input/keyboard/snvs_pwrkey.c:194:12: error:
> > 'imx_snvs_pwrkey_resume' defined but not used [-Werror=unused-function]
> >
> > This adds __maybe_unused annotations to let the compiler know it can
> > silently drop the function definition.
> >
> > Signed-off-by: Arnd Bergmann <[email protected]>
>
> Acked-by: Frank Li <[email protected]>

Applied, thank you.

>
> > ---
> > drivers/input/keyboard/snvs_pwrkey.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/keyboard/snvs_pwrkey.c
> > b/drivers/input/keyboard/snvs_pwrkey.c
> > index 9adf13a5864a..b0ffadeb208c 100644
> > --- a/drivers/input/keyboard/snvs_pwrkey.c
> > +++ b/drivers/input/keyboard/snvs_pwrkey.c
> > @@ -180,7 +180,7 @@ static int imx_snvs_pwrkey_probe(struct
> > platform_device *pdev)
> > return 0;
> > }
> >
> > -static int imx_snvs_pwrkey_suspend(struct device *dev)
> > +static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
> > {
> > struct platform_device *pdev = to_platform_device(dev);
> > struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev); @@ -
> > 191,7 +191,7 @@ static int imx_snvs_pwrkey_suspend(struct device *dev)
> > return 0;
> > }
> >
> > -static int imx_snvs_pwrkey_resume(struct device *dev)
> > +static int __maybe_unused imx_snvs_pwrkey_resume(struct device *dev)
> > {
> > struct platform_device *pdev = to_platform_device(dev);
> > struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
> > --
> > 2.7.0
>

--
Dmitry

2016-03-02 17:13:06

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 11/14] input: spear-keyboard: use __maybe_unused to hide pm functions

On Wed, Mar 02, 2016 at 04:59:03PM +0100, Arnd Bergmann wrote:
> The spear keyboard driver uses #ifdef CONFIG_PM to hide its
> power management functions, but then uses references from
> SIMPLE_DEV_PM_OPS that are only present if both CONFIG_PM
> and CONFIG_PM_SLEEP are set, resulting in a warning about unused
> functions:
>
> drivers/input/keyboard/spear-keyboard.c:292:12: error: 'spear_kbd_suspend' defined but not used [-Werror=unused-function]
> drivers/input/keyboard/spear-keyboard.c:345:12: error: 'spear_kbd_resume' defined but not used [-Werror=unused-function]
>
> This removes the #ifdef and instead uses a __maybe_unused
> annotation.
>
> Signed-off-by: Arnd Bergmann <[email protected]>

Applied, thank you.

> ---
> drivers/input/keyboard/spear-keyboard.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
> index 623d451767e3..8083eaa0524a 100644
> --- a/drivers/input/keyboard/spear-keyboard.c
> +++ b/drivers/input/keyboard/spear-keyboard.c
> @@ -288,8 +288,7 @@ static int spear_kbd_remove(struct platform_device *pdev)
> return 0;
> }
>
> -#ifdef CONFIG_PM
> -static int spear_kbd_suspend(struct device *dev)
> +static int __maybe_unused spear_kbd_suspend(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct spear_kbd *kbd = platform_get_drvdata(pdev);
> @@ -342,7 +341,7 @@ static int spear_kbd_suspend(struct device *dev)
> return 0;
> }
>
> -static int spear_kbd_resume(struct device *dev)
> +static int __maybe_unused spear_kbd_resume(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct spear_kbd *kbd = platform_get_drvdata(pdev);
> @@ -368,7 +367,6 @@ static int spear_kbd_resume(struct device *dev)
>
> return 0;
> }
> -#endif
>
> static SIMPLE_DEV_PM_OPS(spear_kbd_pm_ops, spear_kbd_suspend, spear_kbd_resume);
>
> --
> 2.7.0
>

--
Dmitry

2016-03-02 23:44:06

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 07/14] hw_random: exynos: use __maybe_unused to hide pm functions

On 03.03.2016 00:58, Arnd Bergmann wrote:
> The exynos random driver uses #ifdef to check for CONFIG_PM, but
> then uses SIMPLE_DEV_PM_OPS, which leaves the references out when
> CONFIG_PM_SLEEP is not defined, so we get a warning with
> PM=y && PM_SLEEP=n:
>
> drivers/char/hw_random/exynos-rng.c:166:12: error: 'exynos_rng_suspend' defined but not used [-Werror=unused-function]
> drivers/char/hw_random/exynos-rng.c:171:12: error: 'exynos_rng_resume' defined but not used [-Werror=unused-function]
>
> This removes the incorrect #ifdef and instead uses a __maybe_unused
> annotation to let the compiler know it can silently drop
> the function definition.
>
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> drivers/char/hw_random/exynos-rng.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>

Reviewed-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof

2016-03-03 03:43:27

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH 06/14] dma: sirf: use __maybe_unused to hide pm functions

On Wed, Mar 02, 2016 at 04:58:58PM +0100, Arnd Bergmann wrote:
> The sirf dma driver uses #ifdef to check for CONFIG_PM_SLEEP
> for its suspend/resume code but then has no #ifdef for the
> respective runtime PM code, so we get a warning if CONFIG_PM
> is disabled altogether:
>
> drivers/dma/sirf-dma.c:1000:12: error: 'sirfsoc_dma_runtime_resume' defined but not used [-Werror=unused-function]
>
> This removes the existing #ifdef and instead uses __maybe_unused
> annotations for all four functions to let the compiler know it
> can silently drop the function definition.

Hi Arnd,

Rather than telling compiler that this maybe used why not add ifdef for it's
suspend/resume as well, what are the demerits of that approach?

--
~Vinod

>
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> drivers/dma/sirf-dma.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
> index 22ea2419ee56..e48350e65089 100644
> --- a/drivers/dma/sirf-dma.c
> +++ b/drivers/dma/sirf-dma.c
> @@ -989,7 +989,7 @@ static int sirfsoc_dma_remove(struct platform_device *op)
> return 0;
> }
>
> -static int sirfsoc_dma_runtime_suspend(struct device *dev)
> +static int __maybe_unused sirfsoc_dma_runtime_suspend(struct device *dev)
> {
> struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
>
> @@ -997,7 +997,7 @@ static int sirfsoc_dma_runtime_suspend(struct device *dev)
> return 0;
> }
>
> -static int sirfsoc_dma_runtime_resume(struct device *dev)
> +static int __maybe_unused sirfsoc_dma_runtime_resume(struct device *dev)
> {
> struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
> int ret;
> @@ -1010,8 +1010,7 @@ static int sirfsoc_dma_runtime_resume(struct device *dev)
> return 0;
> }
>
> -#ifdef CONFIG_PM_SLEEP
> -static int sirfsoc_dma_pm_suspend(struct device *dev)
> +static int __maybe_unused sirfsoc_dma_pm_suspend(struct device *dev)
> {
> struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
> struct sirfsoc_dma_regs *save = &sdma->regs_save;
> @@ -1062,7 +1061,7 @@ static int sirfsoc_dma_pm_suspend(struct device *dev)
> return 0;
> }
>
> -static int sirfsoc_dma_pm_resume(struct device *dev)
> +static int __maybe_unused sirfsoc_dma_pm_resume(struct device *dev)
> {
> struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
> struct sirfsoc_dma_regs *save = &sdma->regs_save;
> @@ -1121,7 +1120,6 @@ static int sirfsoc_dma_pm_resume(struct device *dev)
>
> return 0;
> }
> -#endif
>
> static const struct dev_pm_ops sirfsoc_dma_pm_ops = {
> SET_RUNTIME_PM_OPS(sirfsoc_dma_runtime_suspend, sirfsoc_dma_runtime_resume, NULL)
> --
> 2.7.0
>

2016-03-03 08:30:18

by Johannes Thumshirn

[permalink] [raw]
Subject: Re: [PATCH 08/14] scsi: mvumi: use __maybe_unused to hide pm functions

On Wed, Mar 02, 2016 at 04:59:00PM +0100, Arnd Bergmann wrote:
> The mvumi scsi hides the references to its suspend/resume functions
> in an #ifdef but does not hide the implementation the same way:
>
> drivers/scsi/mvumi.c:2632:12: error: 'mvumi_suspend' defined but not used [-Werror=unused-function]
> drivers/scsi/mvumi.c:2651:12: error: 'mvumi_resume' defined but not used [-Werror=unused-function]
>
> This adds __maybe_unused annotations so the compiler knows
> it can silently drop them instead of warning, while avoiding
> the addition of another #ifdef.
>
> Signed-off-by: Arnd Bergmann <[email protected]>

Reviewed-by: Johannes Thumshirn <[email protected]>

--
Johannes Thumshirn Storage
[email protected] +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

2016-03-03 12:34:01

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 06/14] dma: sirf: use __maybe_unused to hide pm functions

On Thursday 03 March 2016 09:17:31 Vinod Koul wrote:
> On Wed, Mar 02, 2016 at 04:58:58PM +0100, Arnd Bergmann wrote:
> > The sirf dma driver uses #ifdef to check for CONFIG_PM_SLEEP
> > for its suspend/resume code but then has no #ifdef for the
> > respective runtime PM code, so we get a warning if CONFIG_PM
> > is disabled altogether:
> >
> > drivers/dma/sirf-dma.c:1000:12: error: 'sirfsoc_dma_runtime_resume' defined but not used [-Werror=unused-function]
> >
> > This removes the existing #ifdef and instead uses __maybe_unused
> > annotations for all four functions to let the compiler know it
> > can silently drop the function definition.
>
> Hi Arnd,
>
> Rather than telling compiler that this maybe used why not add ifdef for it's
> suspend/resume as well, what are the demerits of that approach?
>

As I tried to explain in the cover letter, everyone gets the #ifdef
wrong, and the __maybe_unused annotation is harder to get wrong here.

This particular driver illustrates that well: sirfsoc_dma_remove()
calls sirfsoc_dma_runtime_suspend(), so we must hide the
resume function, but not suspend, and that is counterintuitive.

Other drivers have other problems, e.g. functions that get called
only from within the sections under an #ifdef, and then those
need the same #ifdef added, which gets even more complicated when
you have both runtime-pm and suspend support.

Arnd

2016-03-03 14:23:29

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 03/14] power: ipaq-micro-battery: use __maybe_unused to hide pm functions

Hi,

On Wed, Mar 02, 2016 at 04:58:55PM +0100, Arnd Bergmann wrote:
> The ipaq micro battery driver has suspend/resume functions that
> are accessed using SIMPLE_DEV_PM_OPS, which hide the reference
> when CONFIG_PM_SLEEP is not set, resulting in a warning about
> unused functions:
>
> drivers/power/ipaq_micro_battery.c:284:12: error: 'micro_batt_suspend' defined but not used [-Werror=unused-function]
> drivers/power/ipaq_micro_battery.c:292:12: error: 'micro_batt_resume' defined but not used [-Werror=unused-function]
>
> This adds __maybe_unused annotations to let the compiler know
> it can silently drop the function definition.

Thanks, queued.

-- Sebastian


Attachments:
(No filename) (671.00 B)
signature.asc (819.00 B)
Download all attachments

2016-03-03 14:23:48

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 04/14] power: pm2301-charger: use __maybe_unused to hide pm functions

Hi,

On Wed, Mar 02, 2016 at 04:58:56PM +0100, Arnd Bergmann wrote:
> The pm2301 charger driver uses nested #ifdefs to check for both
> CONFIG_PM and CONFIG_PM_SLEEP in an attempt to hide its
> suspend and runtime-pm operations when they are unused, but
> it does not hide the clear_lpn_pin() function in the same
> way, so we get a build warning when everything is
> disabled:
>
> drivers/power/pm2301_charger.c:123:13: error: 'clear_lpn_pin' defined but not used [-Werror=unused-function]
>
> This removes all the #ifdef and instead uses __maybe_unused
> annotations to let the compiler know it can silently drop
> the function definition.
>
> For the PM2XXX_PM_OPS, we can use an IS_ENABLED() check
> to avoid defining the structure when CONFIG_PM is not set without
> the #ifdef.

Thanks, queued.

-- Sebastian


Attachments:
(No filename) (818.00 B)
signature.asc (819.00 B)
Download all attachments

2016-03-04 14:58:01

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH 06/14] dma: sirf: use __maybe_unused to hide pm functions

On Thu, Mar 03, 2016 at 01:33:17PM +0100, Arnd Bergmann wrote:
> On Thursday 03 March 2016 09:17:31 Vinod Koul wrote:
> > On Wed, Mar 02, 2016 at 04:58:58PM +0100, Arnd Bergmann wrote:
> > > The sirf dma driver uses #ifdef to check for CONFIG_PM_SLEEP
> > > for its suspend/resume code but then has no #ifdef for the
> > > respective runtime PM code, so we get a warning if CONFIG_PM
> > > is disabled altogether:
> > >
> > > drivers/dma/sirf-dma.c:1000:12: error: 'sirfsoc_dma_runtime_resume' defined but not used [-Werror=unused-function]
> > >
> > > This removes the existing #ifdef and instead uses __maybe_unused
> > > annotations for all four functions to let the compiler know it
> > > can silently drop the function definition.
> >
> > Hi Arnd,
> >
> > Rather than telling compiler that this maybe used why not add ifdef for it's
> > suspend/resume as well, what are the demerits of that approach?
> >
>
> As I tried to explain in the cover letter, everyone gets the #ifdef
> wrong, and the __maybe_unused annotation is harder to get wrong here.
>
> This particular driver illustrates that well: sirfsoc_dma_remove()
> calls sirfsoc_dma_runtime_suspend(), so we must hide the
> resume function, but not suspend, and that is counterintuitive.
>
> Other drivers have other problems, e.g. functions that get called
> only from within the sections under an #ifdef, and then those
> need the same #ifdef added, which gets even more complicated when
> you have both runtime-pm and suspend support.

Thanks, applied now after fixing subsystem name

--
~Vinod

2016-03-05 22:09:32

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH 08/14] scsi: mvumi: use __maybe_unused to hide pm functions

>>>>> "Arnd" == Arnd Bergmann <[email protected]> writes:

Arnd> The mvumi scsi hides the references to its suspend/resume
Arnd> functions in an #ifdef but does not hide the implementation the
Arnd> same way:

Applied to 4.6/scsi-queue.

--
Martin K. Petersen Oracle Linux Engineering

2016-03-08 04:27:44

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 05/14] mfd: ipaq-micro: use __maybe_unused to hide pm functions

On Wed, 02 Mar 2016, Arnd Bergmann wrote:

> The ipaq-micro driver uses SET_SYSTEM_SLEEP_PM_OPS() to
> remove the reference to its resume function, but does
> not use an #ifdef around the definition, so we get
> a build warning:
>
> drivers/mfd/ipaq-micro.c:379:12: error: 'micro_resume' defined but not used [-Werror=unused-function]
>
> This adds a __maybe_unused annotation so the compiler knows
> it can silently drop it instead of warning.
>
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> drivers/mfd/ipaq-micro.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

> diff --git a/drivers/mfd/ipaq-micro.c b/drivers/mfd/ipaq-micro.c
> index a41859c55bda..df16fd1df68b 100644
> --- a/drivers/mfd/ipaq-micro.c
> +++ b/drivers/mfd/ipaq-micro.c
> @@ -376,7 +376,7 @@ static const struct mfd_cell micro_cells[] = {
> { .name = "ipaq-micro-leds", },
> };
>
> -static int micro_resume(struct device *dev)
> +static int __maybe_unused micro_resume(struct device *dev)
> {
> struct ipaq_micro *micro = dev_get_drvdata(dev);
>

--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2016-03-08 10:34:01

by Kalle Valo

[permalink] [raw]
Subject: Re: [10/14] wireless: cw1200: use __maybe_unused to hide pm functions_


> The cw1200 uses #ifdef to check for CONFIG_PM, but then
> uses SIMPLE_DEV_PM_OPS, which leaves the references out when
> CONFIG_PM_SLEEP is not defined, so we get a warning with
> PM=y && PM_SLEEP=n:
>
> drivers/net/wireless/st/cw1200/cw1200_spi.c:450:12: error: 'cw1200_spi_suspend' defined but not used [-Werror=unused-function]
>
> This removes the incorrect #ifdef and instead uses a __maybe_unused
> annotation to let the compiler know it can silently drop
> the function definition.
>
> For the DEV_PM_OPS definition, we can use an IS_ENABLED() check
> to avoid defining the structure when CONFIG_PM is not set without
> the #ifdef.
>
> Signed-off-by: Arnd Bergmann <[email protected]>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

2016-03-09 04:09:27

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 01/14] pinctrl: at91: use __maybe_unused to hide pm functions

On Wed, Mar 2, 2016 at 10:58 PM, Arnd Bergmann <[email protected]> wrote:

> The at91-pio4 pinctrl driver uses SET_SYSTEM_SLEEP_PM_OPS() to
> conditionally set the correct suspend/resume options, but they
> become unused when CONFIG_PM is disabled:
>
> drivers/pinctrl/pinctrl-at91-pio4.c:827:12: error: 'atmel_pctrl_suspend' defined but not used [-Werror=unused-function]
> drivers/pinctrl/pinctrl-at91-pio4.c:847:12: error: 'atmel_pctrl_resume' defined but not used [-Werror=unused-function]
>
> This adds __maybe_unused annotations so the compiler knows
> it can silently drop them instead of warning.
>
> Signed-off-by: Arnd Bergmann <[email protected]>

Patch applied with the maintainer ACKs.

Yours,
Linus Walleij

2016-03-11 13:31:35

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 07/14] hw_random: exynos: use __maybe_unused to hide pm functions

On Wed, Mar 02, 2016 at 04:58:59PM +0100, Arnd Bergmann wrote:
> The exynos random driver uses #ifdef to check for CONFIG_PM, but
> then uses SIMPLE_DEV_PM_OPS, which leaves the references out when
> CONFIG_PM_SLEEP is not defined, so we get a warning with
> PM=y && PM_SLEEP=n:
>
> drivers/char/hw_random/exynos-rng.c:166:12: error: 'exynos_rng_suspend' defined but not used [-Werror=unused-function]
> drivers/char/hw_random/exynos-rng.c:171:12: error: 'exynos_rng_resume' defined but not used [-Werror=unused-function]
>
> This removes the incorrect #ifdef and instead uses a __maybe_unused
> annotation to let the compiler know it can silently drop
> the function definition.
>
> Signed-off-by: Arnd Bergmann <[email protected]>

Applied.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt