diff mbox

fbdev: sm712fb: avoid unused function warnings

Message ID 4240710.SWINpxTKzN@wuerfel (mailing list archive)
State New, archived
Headers show

Commit Message

Arnd Bergmann Nov. 20, 2015, 9:48 p.m. UTC
The sm712fb framebuffer driver encloses the power-management
functions in #ifdef CONFIG_PM, but the smtcfb_pci_suspend/resume
functions are only really used when CONFIG_PM_SLEEP is also
set, as a frequent gcc warning shows:

fbdev/sm712fb.c:1549:12: warning: 'smtcfb_pci_suspend' defined but not used
fbdev/sm712fb.c:1572:12: warning: 'smtcfb_pci_resume' defined but not used

The driver also avoids using the SIMPLE_DEV_PM_OPS macro when
CONFIG_PM is unset, which is redundant.

This changes the driver to remove the #ifdef and instead mark
the functions as __maybe_unused, which is a nicer anyway, as it
provides build testing for all the code in all configurations
and is harder to get wrong.

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


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

Comments

Geert Uytterhoeven Nov. 22, 2015, 8:51 p.m. UTC | #1
Hi Arnd,

On Fri, Nov 20, 2015 at 10:48 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> The sm712fb framebuffer driver encloses the power-management
> functions in #ifdef CONFIG_PM, but the smtcfb_pci_suspend/resume
> functions are only really used when CONFIG_PM_SLEEP is also
> set, as a frequent gcc warning shows:
>
> fbdev/sm712fb.c:1549:12: warning: 'smtcfb_pci_suspend' defined but not used
> fbdev/sm712fb.c:1572:12: warning: 'smtcfb_pci_resume' defined but not used
>
> The driver also avoids using the SIMPLE_DEV_PM_OPS macro when
> CONFIG_PM is unset, which is redundant.

Is it? AFAIK there's no dummy of SIMPLE_DEV_PM_OPS() for the !CONFIG_PM case
yet. May be a good idea to have, though.

> This changes the driver to remove the #ifdef and instead mark
> the functions as __maybe_unused, which is a nicer anyway, as it
> provides build testing for all the code in all configurations
> and is harder to get wrong.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c
> index 629bfa2d2f51..86ae1d4556fc 100644
> --- a/drivers/video/fbdev/sm712fb.c
> +++ b/drivers/video/fbdev/sm712fb.c
> @@ -28,9 +28,7 @@
>  #include <linux/console.h>
>  #include <linux/screen_info.h>
>
> -#ifdef CONFIG_PM
>  #include <linux/pm.h>
> -#endif
>
>  #include "sm712.h"
>
> @@ -1545,8 +1543,7 @@ static void smtcfb_pci_remove(struct pci_dev *pdev)
>         pci_disable_device(pdev);
>  }
>
> -#ifdef CONFIG_PM
> -static int smtcfb_pci_suspend(struct device *device)
> +static int __maybe_unused smtcfb_pci_suspend(struct device *device)
>  {
>         struct pci_dev *pdev = to_pci_dev(device);
>         struct smtcfb_info *sfb;
> @@ -1569,7 +1566,7 @@ static int smtcfb_pci_suspend(struct device *device)
>         return 0;
>  }
>
> -static int smtcfb_pci_resume(struct device *device)
> +static int __maybe_unused smtcfb_pci_resume(struct device *device)
>  {
>         struct pci_dev *pdev = to_pci_dev(device);
>         struct smtcfb_info *sfb;
> @@ -1610,20 +1607,13 @@ static int smtcfb_pci_resume(struct device *device)
>  }
>
>  static SIMPLE_DEV_PM_OPS(sm7xx_pm_ops, smtcfb_pci_suspend, smtcfb_pci_resume);
>
> -#define SM7XX_PM_OPS (&sm7xx_pm_ops)
> -
> -#else  /* !CONFIG_PM */
> -
> -#define SM7XX_PM_OPS NULL
> -
> -#endif /* !CONFIG_PM */
>
>  static struct pci_driver smtcfb_driver = {
>         .name = "smtcfb",
>         .id_table = smtcfb_pci_table,
>         .probe = smtcfb_pci_probe,
>         .remove = smtcfb_pci_remove,
> -       .driver.pm  = SM7XX_PM_OPS,
> +       .driver.pm  = &sm7xx_pm_ops,

Hence now there will always be a struct dev_pm_ops in the binary,
which contains 23 pointers, i.e 92 or 184 bytes.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann Nov. 22, 2015, 9:16 p.m. UTC | #2
On Sunday 22 November 2015 21:51:54 Geert Uytterhoeven wrote:
> Hi Arnd,
> 
> On Fri, Nov 20, 2015 at 10:48 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> > The sm712fb framebuffer driver encloses the power-management
> > functions in #ifdef CONFIG_PM, but the smtcfb_pci_suspend/resume
> > functions are only really used when CONFIG_PM_SLEEP is also
> > set, as a frequent gcc warning shows:
> >
> > fbdev/sm712fb.c:1549:12: warning: 'smtcfb_pci_suspend' defined but not used
> > fbdev/sm712fb.c:1572:12: warning: 'smtcfb_pci_resume' defined but not used
> >
> > The driver also avoids using the SIMPLE_DEV_PM_OPS macro when
> > CONFIG_PM is unset, which is redundant.
> 
> Is it? AFAIK there's no dummy of SIMPLE_DEV_PM_OPS() for the !CONFIG_PM case
> yet. May be a good idea to have, though.

The idea of the macro seems to be that the assignment of the pointers
is left out, but the structure is still there. We could fix that, but
I'd rather try to fix the macro in a way that creates an unused
reference to the functions, so we never need any #ifdef or __maybe_unused
annotation. We could also come up with a way to remove the structure
from the binary in that case, but I can't think of an obvious solution
for that at the moment.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tomi Valkeinen Dec. 7, 2015, 4:11 p.m. UTC | #3
On 20/11/15 23:48, Arnd Bergmann wrote:
> The sm712fb framebuffer driver encloses the power-management
> functions in #ifdef CONFIG_PM, but the smtcfb_pci_suspend/resume
> functions are only really used when CONFIG_PM_SLEEP is also
> set, as a frequent gcc warning shows:
> 
> fbdev/sm712fb.c:1549:12: warning: 'smtcfb_pci_suspend' defined but not used
> fbdev/sm712fb.c:1572:12: warning: 'smtcfb_pci_resume' defined but not used
> 
> The driver also avoids using the SIMPLE_DEV_PM_OPS macro when
> CONFIG_PM is unset, which is redundant.
> 
> This changes the driver to remove the #ifdef and instead mark
> the functions as __maybe_unused, which is a nicer anyway, as it
> provides build testing for all the code in all configurations
> and is harder to get wrong.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks, applied for 4.5.

 Tomi
diff mbox

Patch

diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c
index 629bfa2d2f51..86ae1d4556fc 100644
--- a/drivers/video/fbdev/sm712fb.c
+++ b/drivers/video/fbdev/sm712fb.c
@@ -28,9 +28,7 @@ 
 #include <linux/console.h>
 #include <linux/screen_info.h>
 
-#ifdef CONFIG_PM
 #include <linux/pm.h>
-#endif
 
 #include "sm712.h"
 
@@ -1545,8 +1543,7 @@  static void smtcfb_pci_remove(struct pci_dev *pdev)
 	pci_disable_device(pdev);
 }
 
-#ifdef CONFIG_PM
-static int smtcfb_pci_suspend(struct device *device)
+static int __maybe_unused smtcfb_pci_suspend(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
 	struct smtcfb_info *sfb;
@@ -1569,7 +1566,7 @@  static int smtcfb_pci_suspend(struct device *device)
 	return 0;
 }
 
-static int smtcfb_pci_resume(struct device *device)
+static int __maybe_unused smtcfb_pci_resume(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
 	struct smtcfb_info *sfb;
@@ -1610,20 +1607,13 @@  static int smtcfb_pci_resume(struct device *device)
 }
 
 static SIMPLE_DEV_PM_OPS(sm7xx_pm_ops, smtcfb_pci_suspend, smtcfb_pci_resume);
-#define SM7XX_PM_OPS (&sm7xx_pm_ops)
-
-#else  /* !CONFIG_PM */
-
-#define SM7XX_PM_OPS NULL
-
-#endif /* !CONFIG_PM */
 
 static struct pci_driver smtcfb_driver = {
 	.name = "smtcfb",
 	.id_table = smtcfb_pci_table,
 	.probe = smtcfb_pci_probe,
 	.remove = smtcfb_pci_remove,
-	.driver.pm  = SM7XX_PM_OPS,
+	.driver.pm  = &sm7xx_pm_ops,
 };
 
 static int __init sm712fb_init(void)