Skip to contentSkip to conversation

Input: bfin_rotary - mark suspend and resume code as __maybe_unused

PATCH In review Dmitry Torokhov 3 participants 4 messages Feb 6, 2015 – Feb 10, 2015

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: bfin_rotary - mark suspend and resume code as __maybe_unused

Instead of using #ifdef to guard potentially unused suspend and resume code let's mark them as __maybe_unused so they still get discarded if they are not used but we do not get warning. This allows for better compile coverage.

---
 drivers/input/misc/bfin_rotary.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/input/misc/bfin_rotary.c +4 -10
index a39793c..09d7612 100644
@@ -232,8 +232,7 @@ static int bfin_rotary_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int bfin_rotary_suspend(struct device *dev)
+static int __maybe_unused bfin_rotary_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct bfin_rot *rotary = platform_get_drvdata(pdev);
@@ -248,7 +247,7 @@ static int bfin_rotary_suspend(struct device *dev)
 	return 0;
 }
 
-static int bfin_rotary_resume(struct device *dev)
+static int __maybe_unused bfin_rotary_resume(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct bfin_rot *rotary = platform_get_drvdata(pdev);
@@ -266,20 +265,15 @@ static int bfin_rotary_resume(struct device *dev)
 	return 0;
 }
 
-static const struct dev_pm_ops bfin_rotary_pm_ops = {
-	.suspend	= bfin_rotary_suspend,
-	.resume		= bfin_rotary_resume,
-};
-#endif
+static SIMPLE_DEV_PM_OPS(bfin_rotary_pm_ops,
+			 bfin_rotary_suspend, bfin_rotary_resume);
 
 static struct platform_driver bfin_rotary_device_driver = {
 	.probe		= bfin_rotary_probe,
 	.remove		= bfin_rotary_remove,
 	.driver		= {
 		.name	= "bfin-rotary",
-#ifdef CONFIG_PM
 		.pm	= &bfin_rotary_pm_ops,
-#endif
 	},
 };
 module_platform_driver(bfin_rotary_device_driver);
Signature · 5 lines
2.2.0.rc0.207.ga3a616c


-- 
Dmitry
#1 lore raw

Hi Dmitry,

Quoted 39 lines · Dmitry Torokhov

Instead of using #ifdef to guard potentially unused suspend and resume code let's mark them as __maybe_unused so they still get discarded if they are not used but we do not get warning. This allows for better compile coverage.

---
 drivers/input/misc/bfin_rotary.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/input/misc/bfin_rotary.c +2 -6
index a39793c..09d7612 100644
@@ -232,8 +232,7 @@ static int bfin_rotary_remove(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
-static int bfin_rotary_suspend(struct device *dev)
+static int __maybe_unused bfin_rotary_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct bfin_rot *rotary = platform_get_drvdata(pdev);
@@ -248,7 +247,7 @@ static int bfin_rotary_suspend(struct device *dev)
        return 0;
 }
 
-static int bfin_rotary_resume(struct device *dev)
+static int __maybe_unused bfin_rotary_resume(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct bfin_rot *rotary = platform_get_drvdata(pdev);
@@ -266,20 +265,15 @@ static int bfin_rotary_resume(struct device *dev)
        return 0;
 }
 
-static const struct dev_pm_ops bfin_rotary_pm_ops = {
-       .suspend        = bfin_rotary_suspend,
-       .resume         = bfin_rotary_resume,

drivers/input/misc/bfin_rotary.c static int bfin_rotary_resume(struct device *dev) · line 275

Quoted 10 lines
drivers/input/misc/bfin_rotary.c +2 -2
-};
-#endif
+static SIMPLE_DEV_PM_OPS(bfin_rotary_pm_ops,
+                        bfin_rotary_suspend, bfin_rotary_resume);
 
 static struct platform_driver bfin_rotary_device_driver = {
        .probe          = bfin_rotary_probe,
        .remove         = bfin_rotary_remove,
        .driver         = {
                .name   = "bfin-rotary",

You missed
.owner = THIS_MODULE,
here.

Quoted 10 lines
drivers/input/misc/bfin_rotary.c +0 -3
-#ifdef CONFIG_PM
                .pm     = &bfin_rotary_pm_ops,
-#endif
        },
 };
 module_platform_driver(bfin_rotary_device_driver);
--

2.2.0.rc0.207.ga3a616c

Regards,

Sonic

#2 lore raw
Quoted 9 lines · Sonic Zhang
Quoted 5 lines

static struct platform_driver bfin_rotary_device_driver = {

        .probe          = bfin_rotary_probe,
        .remove         = bfin_rotary_remove,
        .driver         = {
                .name   = "bfin-rotary",

You missed
.owner = THIS_MODULE,
here.

That line was removed in v3.19-rc1 by commit 776bd315a7721574 ("input: misc: drop owner assignment from platform_drivers").

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Acked-by on v1 1/1
#3 lore raw
In reply to Dmitry Torokhov

Hi Dmitry,

Since the line I mentioned was removed in v3.19-rc1, I am fine with this patch.

Quoted 65 lines · Dmitry Torokhov

Instead of using #ifdef to guard potentially unused suspend and resume code let's mark them as __maybe_unused so they still get discarded if they are not used but we do not get warning. This allows for better compile coverage.

---
 drivers/input/misc/bfin_rotary.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/input/misc/bfin_rotary.c +4 -11
index a39793c..09d7612 100644
@@ -232,8 +232,7 @@ static int bfin_rotary_remove(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
-static int bfin_rotary_suspend(struct device *dev)
+static int __maybe_unused bfin_rotary_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct bfin_rot *rotary = platform_get_drvdata(pdev);
@@ -248,7 +247,7 @@ static int bfin_rotary_suspend(struct device *dev)
        return 0;
 }
 
-static int bfin_rotary_resume(struct device *dev)
+static int __maybe_unused bfin_rotary_resume(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct bfin_rot *rotary = platform_get_drvdata(pdev);
@@ -266,20 +265,15 @@ static int bfin_rotary_resume(struct device *dev)
        return 0;
 }
 
-static const struct dev_pm_ops bfin_rotary_pm_ops = {
-       .suspend        = bfin_rotary_suspend,
-       .resume         = bfin_rotary_resume,
-};
-#endif
+static SIMPLE_DEV_PM_OPS(bfin_rotary_pm_ops,
+                        bfin_rotary_suspend, bfin_rotary_resume);
 
 static struct platform_driver bfin_rotary_device_driver = {
        .probe          = bfin_rotary_probe,
        .remove         = bfin_rotary_remove,
        .driver         = {
                .name   = "bfin-rotary",
-#ifdef CONFIG_PM
                .pm     = &bfin_rotary_pm_ops,
-#endif
        },
 };
 module_platform_driver(bfin_rotary_device_driver);
--

2.2.0.rc0.207.ga3a616c

--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html