diff mbox series

[11/12] regulator: stm32-vrefbuf: Fix W=1 build warning when CONFIG_OF=n

Message ID 20200820154626.79d83157@xhacker.debian (mailing list archive)
State New, archived
Headers show
Series [01/12] regulator: 88pg86x: Fix W=1 build warning when CONFIG_OF=n | expand

Commit Message

Jisheng Zhang Aug. 20, 2020, 7:46 a.m. UTC
Fix below warning when CONFIG_OF=n:

drivers/regulator/stm32-vrefbuf.c:287:34: warning: ‘stm32_vrefbuf_of_match’ defined but not used [-Wunused-const-variable=]
  287 | static const struct of_device_id stm32_vrefbuf_of_match[] = {
      |                                  ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
---
 drivers/regulator/stm32-vrefbuf.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Fabrice Gasnier Aug. 20, 2020, 8:13 a.m. UTC | #1
On 8/20/20 9:46 AM, Jisheng Zhang wrote:
> Fix below warning when CONFIG_OF=n:
> 
> drivers/regulator/stm32-vrefbuf.c:287:34: warning: ‘stm32_vrefbuf_of_match’ defined but not used [-Wunused-const-variable=]
>   287 | static const struct of_device_id stm32_vrefbuf_of_match[] = {
>       |                                  ^~~~~~~~~~~~~~~~~~~~~~
> 
> Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
> ---
>  drivers/regulator/stm32-vrefbuf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/regulator/stm32-vrefbuf.c b/drivers/regulator/stm32-vrefbuf.c
> index 992bc18101ef..5a5c12d9ea22 100644
> --- a/drivers/regulator/stm32-vrefbuf.c
> +++ b/drivers/regulator/stm32-vrefbuf.c
> @@ -284,11 +284,13 @@ static const struct dev_pm_ops stm32_vrefbuf_pm_ops = {
>  			   NULL)
>  };
>  
> +#ifdef CONFIG_OF

Hi Jisheng,

You could probably adopt "__maybe_unused" here ? E.g. like:

static const struct of_device_id __maybe_unused stm32_vrefbuf_of_match[] = {

I can see other drivers use this already for the same.

Thanks,
Best regards,
Fabrice

>  static const struct of_device_id stm32_vrefbuf_of_match[] = {
>  	{ .compatible = "st,stm32-vrefbuf", },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, stm32_vrefbuf_of_match);
> +#endif
>  
>  static struct platform_driver stm32_vrefbuf_driver = {
>  	.probe = stm32_vrefbuf_probe,
>
Jisheng Zhang Aug. 20, 2020, 8:32 a.m. UTC | #2
On Thu, 20 Aug 2020 10:13:12 +0200 Fabrice Gasnier wrote:

> 
> 
> On 8/20/20 9:46 AM, Jisheng Zhang wrote:
> > Fix below warning when CONFIG_OF=n:
> >
> > drivers/regulator/stm32-vrefbuf.c:287:34: warning: ‘stm32_vrefbuf_of_match’ defined but not used [-Wunused-const-variable=]
> >   287 | static const struct of_device_id stm32_vrefbuf_of_match[] = {
> >       |                                  ^~~~~~~~~~~~~~~~~~~~~~
> >
> > Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
> > ---
> >  drivers/regulator/stm32-vrefbuf.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/regulator/stm32-vrefbuf.c b/drivers/regulator/stm32-vrefbuf.c
> > index 992bc18101ef..5a5c12d9ea22 100644
> > --- a/drivers/regulator/stm32-vrefbuf.c
> > +++ b/drivers/regulator/stm32-vrefbuf.c
> > @@ -284,11 +284,13 @@ static const struct dev_pm_ops stm32_vrefbuf_pm_ops = {
> >                          NULL)
> >  };
> >
> > +#ifdef CONFIG_OF  
> 
> Hi Jisheng,

Hi,

> 
> You could probably adopt "__maybe_unused" here ? E.g. like:

__maybe_unused also fixes the warning. I'm not sure the maintainers' preference.

Hi Mark,

which solution do you prefer?

Thanks in advance

> 
> static const struct of_device_id __maybe_unused stm32_vrefbuf_of_match[] = {
> 
> I can see other drivers use this already for the same.
> 
> Thanks,
> Best regards,
> Fabrice
> 
> >  static const struct of_device_id stm32_vrefbuf_of_match[] = {
> >       { .compatible = "st,stm32-vrefbuf", },
> >       {},
> >  };
> >  MODULE_DEVICE_TABLE(of, stm32_vrefbuf_of_match);
> > +#endif
> >
> >  static struct platform_driver stm32_vrefbuf_driver = {
> >       .probe = stm32_vrefbuf_probe,
> >
Mark Brown Aug. 20, 2020, 10:51 a.m. UTC | #3
On Thu, Aug 20, 2020 at 04:32:32PM +0800, Jisheng Zhang wrote:
> On Thu, 20 Aug 2020 10:13:12 +0200 Fabrice Gasnier wrote:

> > You could probably adopt "__maybe_unused" here ? E.g. like:

> __maybe_unused also fixes the warning. I'm not sure the maintainers' preference.

> which solution do you prefer?

__maybe_unused is a bit nicer.
diff mbox series

Patch

diff --git a/drivers/regulator/stm32-vrefbuf.c b/drivers/regulator/stm32-vrefbuf.c
index 992bc18101ef..5a5c12d9ea22 100644
--- a/drivers/regulator/stm32-vrefbuf.c
+++ b/drivers/regulator/stm32-vrefbuf.c
@@ -284,11 +284,13 @@  static const struct dev_pm_ops stm32_vrefbuf_pm_ops = {
 			   NULL)
 };
 
+#ifdef CONFIG_OF
 static const struct of_device_id stm32_vrefbuf_of_match[] = {
 	{ .compatible = "st,stm32-vrefbuf", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, stm32_vrefbuf_of_match);
+#endif
 
 static struct platform_driver stm32_vrefbuf_driver = {
 	.probe = stm32_vrefbuf_probe,