diff mbox series

mmc: sunxi: mark PM functions as __maybe_unused

Message ID 20180525210752.1794502-1-arnd@arndb.de
State New
Headers show
Series mmc: sunxi: mark PM functions as __maybe_unused | expand

Commit Message

Arnd Bergmann May 25, 2018, 9:07 p.m. UTC
The newly added runtime-pm functions cause a harmless warning
when CONFIG_PM is disabled:

drivers/mmc/host/sunxi-mmc.c:1452:12: error: 'sunxi_mmc_runtime_suspend' defined but not used [-Werror=unused-function]
 static int sunxi_mmc_runtime_suspend(struct device *dev)
            ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/mmc/host/sunxi-mmc.c:1435:12: error: 'sunxi_mmc_runtime_resume' defined but not used [-Werror=unused-function]
 static int sunxi_mmc_runtime_resume(struct device *dev)

This marks them as __maybe_unused to shut up the warning.

Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/mmc/host/sunxi-mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Maxime Ripard May 28, 2018, 6:50 a.m. UTC | #1
On Fri, May 25, 2018 at 11:07:42PM +0200, Arnd Bergmann wrote:
> The newly added runtime-pm functions cause a harmless warning

> when CONFIG_PM is disabled:

> 

> drivers/mmc/host/sunxi-mmc.c:1452:12: error: 'sunxi_mmc_runtime_suspend' defined but not used [-Werror=unused-function]

>  static int sunxi_mmc_runtime_suspend(struct device *dev)

>             ^~~~~~~~~~~~~~~~~~~~~~~~~

> drivers/mmc/host/sunxi-mmc.c:1435:12: error: 'sunxi_mmc_runtime_resume' defined but not used [-Werror=unused-function]

>  static int sunxi_mmc_runtime_resume(struct device *dev)

> 

> This marks them as __maybe_unused to shut up the warning.

> 

> Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>


Thanks!
Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
Andy Shevchenko May 28, 2018, 12:12 p.m. UTC | #2
+Cc: Jean

On Mon, May 28, 2018 at 2:13 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Mon, May 28, 2018 at 1:04 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

>> On 25 May 2018 at 23:07, Arnd Bergmann <arnd@arndb.de> wrote:

>>> The newly added runtime-pm functions cause a harmless warning

>>> when CONFIG_PM is disabled:

>>>

>>> drivers/mmc/host/sunxi-mmc.c:1452:12: error: 'sunxi_mmc_runtime_suspend' defined but not used [-Werror=unused-function]

>>>  static int sunxi_mmc_runtime_suspend(struct device *dev)

>>>             ^~~~~~~~~~~~~~~~~~~~~~~~~

>>> drivers/mmc/host/sunxi-mmc.c:1435:12: error: 'sunxi_mmc_runtime_resume' defined but not used [-Werror=unused-function]

>>>  static int sunxi_mmc_runtime_resume(struct device *dev)

>>>

>>> This marks them as __maybe_unused to shut up the warning.

>>

>> Most mmc drivers uses #ifdef CONFIG_PM instead of the __maybe_unused() option.

>>

>> It's not a big deal, but consistency is always good. Would you mind changing?

>

> I'd prefer not to. Most uses of #ifdef CONFIG_PM that get introduced are wrong,

> and cause additional randconfig warnings that I end up having to fix,

> so I always

> do it with __maybe_unused.


Some of the maintainers have strong objection against such changes.
http://lkml.iu.edu/hypermail/linux/kernel/1805.1/06100.html

It seems we might have a split in the opinions, which is not good in
this case (consistency for PM callbacks overall will be broken).

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann May 28, 2018, 3:15 p.m. UTC | #3
On Mon, May 28, 2018 at 2:12 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> +Cc: Jean

>

> On Mon, May 28, 2018 at 2:13 PM, Arnd Bergmann <arnd@arndb.de> wrote:

>> On Mon, May 28, 2018 at 1:04 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

>>> On 25 May 2018 at 23:07, Arnd Bergmann <arnd@arndb.de> wrote:

>>>> The newly added runtime-pm functions cause a harmless warning

>>>> when CONFIG_PM is disabled:

>>>>

>>>> drivers/mmc/host/sunxi-mmc.c:1452:12: error: 'sunxi_mmc_runtime_suspend' defined but not used [-Werror=unused-function]

>>>>  static int sunxi_mmc_runtime_suspend(struct device *dev)

>>>>             ^~~~~~~~~~~~~~~~~~~~~~~~~

>>>> drivers/mmc/host/sunxi-mmc.c:1435:12: error: 'sunxi_mmc_runtime_resume' defined but not used [-Werror=unused-function]

>>>>  static int sunxi_mmc_runtime_resume(struct device *dev)

>>>>

>>>> This marks them as __maybe_unused to shut up the warning.

>>>

>>> Most mmc drivers uses #ifdef CONFIG_PM instead of the __maybe_unused() option.

>>>

>>> It's not a big deal, but consistency is always good. Would you mind changing?

>>

>> I'd prefer not to. Most uses of #ifdef CONFIG_PM that get introduced are wrong,

>> and cause additional randconfig warnings that I end up having to fix,

>> so I always

>> do it with __maybe_unused.

>

> Some of the maintainers have strong objection against such changes.

> http://lkml.iu.edu/hypermail/linux/kernel/1805.1/06100.html

>

> It seems we might have a split in the opinions, which is not good in

> this case (consistency for PM callbacks overall will be broken).


We actually talked about this at the kernel summit last year, and the conclusion
was that we should replace the SET_RUNTIME_PM_OPS(),
SIMPLE_DEV_PM_OPS(), SET_SYSTEM_SLEEP_PM_OPS()
etc macros with new ones that don't require the ugly #ifdef and just silently
drop the unused functions.

Unfortunately we can't extend the existing macros to work that way (it
breaks for drivers that have an #ifdef today), and nobody could come up
with a new name that is at least as readable as the current one.

Note that incorrect #ifdef usage here is the most common source of
newly introduced build warnings and errors in the kernel, everyone gets
those wrong since they are just very confusing.

       Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index 97c6b79b7d6f..837888b96bd3 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -1432,7 +1432,7 @@  static int sunxi_mmc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static int sunxi_mmc_runtime_resume(struct device *dev)
+static int __maybe_unused sunxi_mmc_runtime_resume(struct device *dev)
 {
 	struct mmc_host	*mmc = dev_get_drvdata(dev);
 	struct sunxi_mmc_host *host = mmc_priv(mmc);
@@ -1449,7 +1449,7 @@  static int sunxi_mmc_runtime_resume(struct device *dev)
 	return 0;
 }
 
-static int sunxi_mmc_runtime_suspend(struct device *dev)
+static int __maybe_unused sunxi_mmc_runtime_suspend(struct device *dev)
 {
 	struct mmc_host	*mmc = dev_get_drvdata(dev);
 	struct sunxi_mmc_host *host = mmc_priv(mmc);