netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] drivers: use __maybe_unused to hide pm functions
@ 2016-03-02 15:58 Arnd Bergmann
  2016-03-02 15:59 ` [PATCH 09/14] amd-xgbe: " Arnd Bergmann
  2016-03-02 15:59 ` [PATCH 10/14] wireless: cw1200: use __maybe_unused to hide pm functions_ Arnd Bergmann
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-03-02 15:58 UTC (permalink / raw)
  Cc: linux-arm-kernel, Arnd Bergmann, herbert, k.kozlowski,
	dan.j.williams, vinod.koul, baohua, dmitry.torokhov, tglx, jason,
	marc.zyngier, laurent.pinchart, mchehab, lee.jones, kvalo,
	ludovic.desroches, linus.walleij, sre, dbaryshkov, JBottomley,
	martin.petersen, broonie, linux-crypto, linux-samsung-soc,
	linux-kernel, dmaengine, linux-input, linux-media, netdev,
	linux-wireless, linux-gpio, linux-pm, linux-scsi, alsa-devel

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: herbert@gondor.apana.org.au
Cc: k.kozlowski@samsung.com
Cc: dan.j.williams@intel.com
Cc: vinod.koul@intel.com
Cc: baohua@kernel.org
Cc: dmitry.torokhov@gmail.com
Cc: tglx@linutronix.de
Cc: jason@lakedaemon.net
Cc: marc.zyngier@arm.com
Cc: laurent.pinchart@ideasonboard.com
Cc: mchehab@osg.samsung.com
Cc: lee.jones@linaro.org
Cc: kvalo@codeaurora.org
Cc: ludovic.desroches@atmel.com
Cc: linus.walleij@linaro.org
Cc: sre@kernel.org
Cc: dbaryshkov@gmail.com
Cc: JBottomley@odin.com
Cc: martin.petersen@oracle.com
Cc: broonie@kernel.org
Cc: linux-crypto@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: dmaengine@vger.kernel.org
Cc: linux-input@vger.kernel.org
Cc: linux-media@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: alsa-devel@alsa-project.org
Cc: linux-rockchip@lists.infradead.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 09/14] amd-xgbe: use __maybe_unused to hide pm functions
  2016-03-02 15:58 [PATCH 00/14] drivers: use __maybe_unused to hide pm functions Arnd Bergmann
@ 2016-03-02 15:59 ` Arnd Bergmann
  2016-03-02 15:59 ` [PATCH 10/14] wireless: cw1200: use __maybe_unused to hide pm functions_ Arnd Bergmann
  1 sibling, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-03-02 15:59 UTC (permalink / raw)
  To: Tom Lendacky; +Cc: netdev, Arnd Bergmann, linux-arm-kernel, linux-kernel

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 <arnd@arndb.de>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 10/14] wireless: cw1200: use __maybe_unused to hide pm functions_
  2016-03-02 15:58 [PATCH 00/14] drivers: use __maybe_unused to hide pm functions Arnd Bergmann
  2016-03-02 15:59 ` [PATCH 09/14] amd-xgbe: " Arnd Bergmann
@ 2016-03-02 15:59 ` Arnd Bergmann
  2016-03-08 10:33   ` [10/14] " Kalle Valo
  2016-03-08 10:33   ` Kalle Valo
  1 sibling, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-03-02 15:59 UTC (permalink / raw)
  To: Solomon Peachy, Kalle Valo
  Cc: linux-arm-kernel, Arnd Bergmann, linux-wireless, netdev,
	linux-kernel

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 <arnd@arndb.de>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [10/14] wireless: cw1200: use __maybe_unused to hide pm functions_
  2016-03-02 15:59 ` [PATCH 10/14] wireless: cw1200: use __maybe_unused to hide pm functions_ Arnd Bergmann
@ 2016-03-08 10:33   ` Kalle Valo
  2016-03-08 10:33   ` Kalle Valo
  1 sibling, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2016-03-08 10:33 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Solomon Peachy, linux-arm-kernel, Arnd Bergmann, linux-wireless,
	netdev, linux-kernel


> 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 <arnd@arndb.de>

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

Kalle Valo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [10/14] wireless: cw1200: use __maybe_unused to hide pm functions_
  2016-03-02 15:59 ` [PATCH 10/14] wireless: cw1200: use __maybe_unused to hide pm functions_ Arnd Bergmann
  2016-03-08 10:33   ` [10/14] " Kalle Valo
@ 2016-03-08 10:33   ` Kalle Valo
  1 sibling, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2016-03-08 10:33 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, netdev, linux-wireless, linux-kernel,
	Solomon Peachy, linux-arm-kernel


> 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 <arnd@arndb.de>

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

Kalle Valo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-08 10:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-02 15:58 [PATCH 00/14] drivers: use __maybe_unused to hide pm functions Arnd Bergmann
2016-03-02 15:59 ` [PATCH 09/14] amd-xgbe: " Arnd Bergmann
2016-03-02 15:59 ` [PATCH 10/14] wireless: cw1200: use __maybe_unused to hide pm functions_ Arnd Bergmann
2016-03-08 10:33   ` [10/14] " Kalle Valo
2016-03-08 10:33   ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).