* [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused
@ 2020-10-01 9:52 Michael Brunner
2020-10-02 7:01 ` Lee Jones
0 siblings, 1 reply; 6+ messages in thread
From: Michael Brunner @ 2020-10-01 9:52 UTC (permalink / raw)
To: lee.jones; +Cc: mibru, linux-kernel
The Intel 0-DAY CI Kernel Test Service reports an unused variable
warning when compiling with clang for PowerPC:
>> drivers/mfd/kempld-core.c:556:36: warning: unused variable 'kempld_acpi_table' [-Wunused-const-variable]
static const struct acpi_device_id kempld_acpi_table[] = {
The issue can be fixed by marking kempld_acpi_table as __maybe_unused.
Fixes: e8299c7313af ("[PATCH] mfd: Add ACPI support to Kontron PLD driver")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Michael Brunner <michael.brunner@kontron.com>
---
drivers/mfd/kempld-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 1dfe556df038..273481dfaad4 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -553,7 +553,7 @@ static int kempld_remove(struct platform_device *pdev)
return 0;
}
-static const struct acpi_device_id kempld_acpi_table[] = {
+static const struct acpi_device_id __maybe_unused kempld_acpi_table[] = {
{ "KEM0001", (kernel_ulong_t)&kempld_platform_data_generic },
{}
};
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused
2020-10-01 9:52 [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused Michael Brunner
@ 2020-10-02 7:01 ` Lee Jones
2020-10-05 7:07 ` Michael Brunner
0 siblings, 1 reply; 6+ messages in thread
From: Lee Jones @ 2020-10-02 7:01 UTC (permalink / raw)
To: Michael Brunner; +Cc: mibru, linux-kernel
On Thu, 01 Oct 2020, Michael Brunner wrote:
> The Intel 0-DAY CI Kernel Test Service reports an unused variable
> warning when compiling with clang for PowerPC:
>
> >> drivers/mfd/kempld-core.c:556:36: warning: unused variable 'kempld_acpi_table' [-Wunused-const-variable]
> static const struct acpi_device_id kempld_acpi_table[] = {
>
> The issue can be fixed by marking kempld_acpi_table as __maybe_unused.
>
> Fixes: e8299c7313af ("[PATCH] mfd: Add ACPI support to Kontron PLD driver")
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Michael Brunner <michael.brunner@kontron.com>
> ---
> drivers/mfd/kempld-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
> index 1dfe556df038..273481dfaad4 100644
> --- a/drivers/mfd/kempld-core.c
> +++ b/drivers/mfd/kempld-core.c
> @@ -553,7 +553,7 @@ static int kempld_remove(struct platform_device *pdev)
> return 0;
> }
>
> -static const struct acpi_device_id kempld_acpi_table[] = {
> +static const struct acpi_device_id __maybe_unused kempld_acpi_table[] = {
> { "KEM0001", (kernel_ulong_t)&kempld_platform_data_generic },
> {}
> };
This is not the right fix. Better just to compile it out completely
in these circumstances. I already have a fix for this in soak.
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused
2020-10-02 7:01 ` Lee Jones
@ 2020-10-05 7:07 ` Michael Brunner
2020-10-06 6:53 ` Lee Jones
0 siblings, 1 reply; 6+ messages in thread
From: Michael Brunner @ 2020-10-05 7:07 UTC (permalink / raw)
To: lee.jones; +Cc: mibru, linux-kernel
On Fri, 2020-10-02 at 08:01 +0100, Lee Jones wrote:
> On Thu, 01 Oct 2020, Michael Brunner wrote:
>
> > The Intel 0-DAY CI Kernel Test Service reports an unused variable
> > warning when compiling with clang for PowerPC:
> >
> > > > drivers/mfd/kempld-core.c:556:36: warning: unused variable
> > > > 'kempld_acpi_table' [-Wunused-const-variable]
> > static const struct acpi_device_id kempld_acpi_table[] = {
> >
> > The issue can be fixed by marking kempld_acpi_table as
> > __maybe_unused.
> >
> > Fixes: e8299c7313af ("[PATCH] mfd: Add ACPI support to Kontron PLD
> > driver")
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Michael Brunner <michael.brunner@kontron.com>
> > ---
> > drivers/mfd/kempld-core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
> > index 1dfe556df038..273481dfaad4 100644
> > --- a/drivers/mfd/kempld-core.c
> > +++ b/drivers/mfd/kempld-core.c
> > @@ -553,7 +553,7 @@ static int kempld_remove(struct platform_device
> > *pdev)
> > return 0;
> > }
> >
> > -static const struct acpi_device_id kempld_acpi_table[] = {
> > +static const struct acpi_device_id __maybe_unused
> > kempld_acpi_table[] = {
> > { "KEM0001", (kernel_ulong_t)&kempld_platform_data_generic },
> > {}
> > };
>
> This is not the right fix. Better just to compile it out completely
> in these circumstances. I already have a fix for this in soak.
Ok - thank you for the other fix you submitted!
But just out of curiosity - in process/coding-style.rst is written that
__maybe_unused should be preferred over wrapping in preprocessor
conditionals, if a function or variable may potentially go unused in a
particular configuration. So why is my patch not the right one here? At
least in my tests it seemed to solve the issue.
Thanks,
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused
2020-10-05 7:07 ` Michael Brunner
@ 2020-10-06 6:53 ` Lee Jones
2020-10-06 15:54 ` Michael Brunner
0 siblings, 1 reply; 6+ messages in thread
From: Lee Jones @ 2020-10-06 6:53 UTC (permalink / raw)
To: Michael Brunner; +Cc: mibru, linux-kernel
On Mon, 05 Oct 2020, Michael Brunner wrote:
> On Fri, 2020-10-02 at 08:01 +0100, Lee Jones wrote:
> > On Thu, 01 Oct 2020, Michael Brunner wrote:
> >
> > > The Intel 0-DAY CI Kernel Test Service reports an unused variable
> > > warning when compiling with clang for PowerPC:
> > >
> > > > > drivers/mfd/kempld-core.c:556:36: warning: unused variable
> > > > > 'kempld_acpi_table' [-Wunused-const-variable]
> > > static const struct acpi_device_id kempld_acpi_table[] = {
> > >
> > > The issue can be fixed by marking kempld_acpi_table as
> > > __maybe_unused.
> > >
> > > Fixes: e8299c7313af ("[PATCH] mfd: Add ACPI support to Kontron PLD
> > > driver")
> > >
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Signed-off-by: Michael Brunner <michael.brunner@kontron.com>
> > > ---
> > > drivers/mfd/kempld-core.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
> > > index 1dfe556df038..273481dfaad4 100644
> > > --- a/drivers/mfd/kempld-core.c
> > > +++ b/drivers/mfd/kempld-core.c
> > > @@ -553,7 +553,7 @@ static int kempld_remove(struct platform_device
> > > *pdev)
> > > return 0;
> > > }
> > >
> > > -static const struct acpi_device_id kempld_acpi_table[] = {
> > > +static const struct acpi_device_id __maybe_unused
> > > kempld_acpi_table[] = {
> > > { "KEM0001", (kernel_ulong_t)&kempld_platform_data_generic },
> > > {}
> > > };
> >
> > This is not the right fix. Better just to compile it out completely
> > in these circumstances. I already have a fix for this in soak.
>
> Ok - thank you for the other fix you submitted!
>
> But just out of curiosity - in process/coding-style.rst is written that
> __maybe_unused should be preferred over wrapping in preprocessor
> conditionals, if a function or variable may potentially go unused in a
> particular configuration. So why is my patch not the right one here? At
> least in my tests it seemed to solve the issue.
It's a bone of contention for sure. In these kinds of scenarios
(i.e. ACPI and OF tables) it is way more common to wrap them:
$ git grep -B3 'acpi_device_id\|of_device_id' | grep 'CONFIG_ACPI\|CONFIG_OF' | wc -l
596
$ git grep -B3 'acpi_device_id\|of_device_id' | grep __maybe_unused | wc -l
63
Parsing them out completely, also has the benefit of saving space,
reducing the size of the finalised binary.
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused
2020-10-06 6:53 ` Lee Jones
@ 2020-10-06 15:54 ` Michael Brunner
2020-10-07 7:10 ` Lee Jones
0 siblings, 1 reply; 6+ messages in thread
From: Michael Brunner @ 2020-10-06 15:54 UTC (permalink / raw)
To: lee.jones; +Cc: mibru, linux-kernel
On Tue, 2020-10-06 at 07:53 +0100, Lee Jones wrote:
> On Mon, 05 Oct 2020, Michael Brunner wrote:
>
> > On Fri, 2020-10-02 at 08:01 +0100, Lee Jones wrote:
> > > On Thu, 01 Oct 2020, Michael Brunner wrote:
> > >
> > > > The Intel 0-DAY CI Kernel Test Service reports an unused variable
> > > > warning when compiling with clang for PowerPC:
> > > >
> > > > > > drivers/mfd/kempld-core.c:556:36: warning: unused variable
> > > > > > 'kempld_acpi_table' [-Wunused-const-variable]
> > > > static const struct acpi_device_id kempld_acpi_table[] = {
> > > >
> > > > The issue can be fixed by marking kempld_acpi_table as
> > > > __maybe_unused.
> > > >
> > > > Fixes: e8299c7313af ("[PATCH] mfd: Add ACPI support to Kontron PLD
> > > > driver")
> > > >
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > Signed-off-by: Michael Brunner <michael.brunner@kontron.com>
> > > > ---
> > > > drivers/mfd/kempld-core.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
> > > > index 1dfe556df038..273481dfaad4 100644
> > > > --- a/drivers/mfd/kempld-core.c
> > > > +++ b/drivers/mfd/kempld-core.c
> > > > @@ -553,7 +553,7 @@ static int kempld_remove(struct platform_device
> > > > *pdev)
> > > > return 0;
> > > > }
> > > >
> > > > -static const struct acpi_device_id kempld_acpi_table[] = {
> > > > +static const struct acpi_device_id __maybe_unused
> > > > kempld_acpi_table[] = {
> > > > { "KEM0001", (kernel_ulong_t)&kempld_platform_data_generic },
> > > > {}
> > > > };
> > >
> > > This is not the right fix. Better just to compile it out completely
> > > in these circumstances. I already have a fix for this in soak.
> >
> > Ok - thank you for the other fix you submitted!
> >
> > But just out of curiosity - in process/coding-style.rst is written that
> > __maybe_unused should be preferred over wrapping in preprocessor
> > conditionals, if a function or variable may potentially go unused in a
> > particular configuration. So why is my patch not the right one here? At
> > least in my tests it seemed to solve the issue.
>
> It's a bone of contention for sure. In these kinds of scenarios
> (i.e. ACPI and OF tables) it is way more common to wrap them:
>
> $ git grep -B3 'acpi_device_id\|of_device_id' | grep 'CONFIG_ACPI\|CONFIG_OF' | wc -l
> 596
> $ git grep -B3 'acpi_device_id\|of_device_id' | grep __maybe_unused | wc -l
> 63
>
> Parsing them out completely, also has the benefit of saving space,
> reducing the size of the finalised binary.
Doesn't the compiler remove it anyway? At least in my test I didn't see
a difference in the resulting object files.
Doing a crosscheck, by adding __attribute__((used)) to the definition
of kempld_acpi_table, the object file size increased and
kempld_acpi_table showed up in the symbol table.
Nevertheless, I don't want to start a discussion. I am fine with using
the preprocessor. Just wanted to make sure I understand the technical
implications of both solutions.
Thank you for your time!
Best regards,
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused
2020-10-06 15:54 ` Michael Brunner
@ 2020-10-07 7:10 ` Lee Jones
0 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2020-10-07 7:10 UTC (permalink / raw)
To: Michael Brunner; +Cc: mibru, linux-kernel
On Tue, 06 Oct 2020, Michael Brunner wrote:
> On Tue, 2020-10-06 at 07:53 +0100, Lee Jones wrote:
> > On Mon, 05 Oct 2020, Michael Brunner wrote:
> >
> > > On Fri, 2020-10-02 at 08:01 +0100, Lee Jones wrote:
> > > > On Thu, 01 Oct 2020, Michael Brunner wrote:
> > > >
> > > > > The Intel 0-DAY CI Kernel Test Service reports an unused variable
> > > > > warning when compiling with clang for PowerPC:
> > > > >
> > > > > > > drivers/mfd/kempld-core.c:556:36: warning: unused variable
> > > > > > > 'kempld_acpi_table' [-Wunused-const-variable]
> > > > > static const struct acpi_device_id kempld_acpi_table[] = {
> > > > >
> > > > > The issue can be fixed by marking kempld_acpi_table as
> > > > > __maybe_unused.
> > > > >
> > > > > Fixes: e8299c7313af ("[PATCH] mfd: Add ACPI support to Kontron PLD
> > > > > driver")
> > > > >
> > > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > > Signed-off-by: Michael Brunner <michael.brunner@kontron.com>
> > > > > ---
> > > > > drivers/mfd/kempld-core.c | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
> > > > > index 1dfe556df038..273481dfaad4 100644
> > > > > --- a/drivers/mfd/kempld-core.c
> > > > > +++ b/drivers/mfd/kempld-core.c
> > > > > @@ -553,7 +553,7 @@ static int kempld_remove(struct platform_device
> > > > > *pdev)
> > > > > return 0;
> > > > > }
> > > > >
> > > > > -static const struct acpi_device_id kempld_acpi_table[] = {
> > > > > +static const struct acpi_device_id __maybe_unused
> > > > > kempld_acpi_table[] = {
> > > > > { "KEM0001", (kernel_ulong_t)&kempld_platform_data_generic },
> > > > > {}
> > > > > };
> > > >
> > > > This is not the right fix. Better just to compile it out completely
> > > > in these circumstances. I already have a fix for this in soak.
> > >
> > > Ok - thank you for the other fix you submitted!
> > >
> > > But just out of curiosity - in process/coding-style.rst is written that
> > > __maybe_unused should be preferred over wrapping in preprocessor
> > > conditionals, if a function or variable may potentially go unused in a
> > > particular configuration. So why is my patch not the right one here? At
> > > least in my tests it seemed to solve the issue.
> >
> > It's a bone of contention for sure. In these kinds of scenarios
> > (i.e. ACPI and OF tables) it is way more common to wrap them:
> >
> > $ git grep -B3 'acpi_device_id\|of_device_id' | grep 'CONFIG_ACPI\|CONFIG_OF' | wc -l
> > 596
> > $ git grep -B3 'acpi_device_id\|of_device_id' | grep __maybe_unused | wc -l
> > 63
> >
> > Parsing them out completely, also has the benefit of saving space,
> > reducing the size of the finalised binary.
>
> Doesn't the compiler remove it anyway? At least in my test I didn't see
> a difference in the resulting object files.
> Doing a crosscheck, by adding __attribute__((used)) to the definition
> of kempld_acpi_table, the object file size increased and
> kempld_acpi_table showed up in the symbol table.
>
> Nevertheless, I don't want to start a discussion. I am fine with using
> the preprocessor. Just wanted to make sure I understand the technical
> implications of both solutions.
This is what happened last time I submitted a patch using
__maybe_unused:
https://lkml.org/lkml/2020/8/17/1704
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-10-07 7:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01 9:52 [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused Michael Brunner
2020-10-02 7:01 ` Lee Jones
2020-10-05 7:07 ` Michael Brunner
2020-10-06 6:53 ` Lee Jones
2020-10-06 15:54 ` Michael Brunner
2020-10-07 7:10 ` Lee Jones
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).