llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] clk: ralink: mtmips: quiet unused variable warning
       [not found] <20230802092647.3000666-1-sergio.paracuellos@gmail.com>
@ 2023-08-02 21:26 ` Nick Desaulniers
  2023-08-02 21:32   ` Nathan Chancellor
  2023-08-02 22:01   ` Arnd Bergmann
  0 siblings, 2 replies; 5+ messages in thread
From: Nick Desaulniers @ 2023-08-02 21:26 UTC (permalink / raw)
  To: Sergio Paracuellos, Arnd Bergmann, Nathan Chancellor
  Cc: linux-clk, tsbogend, sboyd, mturquette, linux-kernel,
	kernel test robot, clang-built-linux

On Wed, Aug 2, 2023 at 2:26 AM Sergio Paracuellos
<sergio.paracuellos@gmail.com> wrote:
>
> When CONFIG_OF is disabled then the matching table is not referenced and
> the following warning appears:
>
> drivers/clk/ralink/clk-mtmips.c:821:34: warning: unused variable 'mtmips_of_match' [-Wunused-const-variable]
> 821 |   static const struct of_device_id mtmips_of_match[] = {
>     |                          ^
>
> Silence it declaring 'mtmips_of_match' with '__maybe_unused'.
>
> Fixes: 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202307242310.CdOnd2py-lkp@intel.com/
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>

I think this is fine; Arnd or Nathan do you have a preference? or thoughts here?

If not, thanks for the patch.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

(I have a slight preference for wrapping the use in `#ifdef CONFIG_OF`
since with the approach used by this patch, if all users are removed
we will never get a warning for this var. But it's a weak preference;
it's more important to me that we don't have -Werror promote this
warning to a build breakage)

> ---
>  drivers/clk/ralink/clk-mtmips.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/ralink/clk-mtmips.c b/drivers/clk/ralink/clk-mtmips.c
> index 1e7991439527..6716394b28a3 100644
> --- a/drivers/clk/ralink/clk-mtmips.c
> +++ b/drivers/clk/ralink/clk-mtmips.c
> @@ -820,7 +820,7 @@ static const struct mtmips_clk_data mt76x8_clk_data = {
>         .num_clk_periph = ARRAY_SIZE(mt76x8_pherip_clks),
>  };
>
> -static const struct of_device_id mtmips_of_match[] = {
> +static const __maybe_unused struct of_device_id mtmips_of_match[] = {
>         {
>                 .compatible = "ralink,rt2880-sysc",
>                 .data = &rt2880_clk_data,
> --
> 2.25.1
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: ralink: mtmips: quiet unused variable warning
  2023-08-02 21:26 ` [PATCH] clk: ralink: mtmips: quiet unused variable warning Nick Desaulniers
@ 2023-08-02 21:32   ` Nathan Chancellor
  2023-08-02 22:01   ` Arnd Bergmann
  1 sibling, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2023-08-02 21:32 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Sergio Paracuellos, Arnd Bergmann, linux-clk, tsbogend, sboyd,
	mturquette, linux-kernel, kernel test robot, clang-built-linux

On Wed, Aug 02, 2023 at 02:26:43PM -0700, Nick Desaulniers wrote:
> On Wed, Aug 2, 2023 at 2:26 AM Sergio Paracuellos
> <sergio.paracuellos@gmail.com> wrote:
> >
> > When CONFIG_OF is disabled then the matching table is not referenced and
> > the following warning appears:
> >
> > drivers/clk/ralink/clk-mtmips.c:821:34: warning: unused variable 'mtmips_of_match' [-Wunused-const-variable]
> > 821 |   static const struct of_device_id mtmips_of_match[] = {
> >     |                          ^
> >
> > Silence it declaring 'mtmips_of_match' with '__maybe_unused'.
> >
> > Fixes: 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202307242310.CdOnd2py-lkp@intel.com/
> > Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> 
> I think this is fine; Arnd or Nathan do you have a preference? or thoughts here?

I do not have much of a preference either, I tend to agree with your
reasoning for preferring the #ifdef but '__maybe_unused' is relatively
easy to audit on a per-file basis and I think that is more common than
the '#ifdef CONFIG_OF'.

Small nit, I think __maybe_unused typically goes between the variable
name and equals, like

  static const struct of_device_id mtmips_of_match[] __maybe_unused = {

but this is obviously fine. Regardless:

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> If not, thanks for the patch.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> 
> (I have a slight preference for wrapping the use in `#ifdef CONFIG_OF`
> since with the approach used by this patch, if all users are removed
> we will never get a warning for this var. But it's a weak preference;
> it's more important to me that we don't have -Werror promote this
> warning to a build breakage)
> 
> > ---
> >  drivers/clk/ralink/clk-mtmips.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/clk/ralink/clk-mtmips.c b/drivers/clk/ralink/clk-mtmips.c
> > index 1e7991439527..6716394b28a3 100644
> > --- a/drivers/clk/ralink/clk-mtmips.c
> > +++ b/drivers/clk/ralink/clk-mtmips.c
> > @@ -820,7 +820,7 @@ static const struct mtmips_clk_data mt76x8_clk_data = {
> >         .num_clk_periph = ARRAY_SIZE(mt76x8_pherip_clks),
> >  };
> >
> > -static const struct of_device_id mtmips_of_match[] = {
> > +static const __maybe_unused struct of_device_id mtmips_of_match[] = {
> >         {
> >                 .compatible = "ralink,rt2880-sysc",
> >                 .data = &rt2880_clk_data,
> > --
> > 2.25.1
> >
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: ralink: mtmips: quiet unused variable warning
  2023-08-02 21:26 ` [PATCH] clk: ralink: mtmips: quiet unused variable warning Nick Desaulniers
  2023-08-02 21:32   ` Nathan Chancellor
@ 2023-08-02 22:01   ` Arnd Bergmann
       [not found]     ` <CAMhs-H-2g2QF8NjZOknEop_3UFc_R3YYhpEveU2fc-Ks-iM1bA@mail.gmail.com>
  1 sibling, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2023-08-02 22:01 UTC (permalink / raw)
  To: Nick Desaulniers, Sergio Paracuellos, Nathan Chancellor
  Cc: linux-clk, Thomas Bogendoerfer, Stephen Boyd, Michael Turquette,
	linux-kernel, kernel test robot, clang-built-linux

On Wed, Aug 2, 2023, at 23:26, Nick Desaulniers wrote:
> On Wed, Aug 2, 2023 at 2:26 AM Sergio Paracuellos <sergio.paracuellos@gmail.com> wrote:
>>
>> When CONFIG_OF is disabled then the matching table is not referenced and
>> the following warning appears:
>>
>> drivers/clk/ralink/clk-mtmips.c:821:34: warning: unused variable 'mtmips_of_match' [-Wunused-const-variable]
>> 821 |   static const struct of_device_id mtmips_of_match[] = {
>>     |                          ^
>>
>> Silence it declaring 'mtmips_of_match' with '__maybe_unused'.
>>
>> Fixes: 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")
>> Reported-by: kernel test robot <lkp@intel.com>
>> Closes: https://lore.kernel.org/oe-kbuild-all/202307242310.CdOnd2py-lkp@intel.com/
>> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
>
> I think this is fine; Arnd or Nathan do you have a preference? or thoughts here?
>
> If not, thanks for the patch.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> (I have a slight preference for wrapping the use in `#ifdef CONFIG_OF`
> since with the approach used by this patch, if all users are removed
> we will never get a warning for this var. But it's a weak preference;
> it's more important to me that we don't have -Werror promote this
> warning to a build breakage)

I don't understand why there are two match tables in the same
driver, with almost the same contents. I have not looked very
closely here, but why can't we just drop the mtmips_clk_of_match[]
table (the one without the .data fields) and use the same
table for both? Is this because of the ralink,rt2880-reset entry
that is missing in mtmips_of_match, or is that another bug?

I also see that there is both a platform_driver instance for
late probing and a list of CLK_OF_DECLARE_DRIVER() entries.
Do we need both here?

      Arnd

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: ralink: mtmips: quiet unused variable warning
       [not found]     ` <CAMhs-H-2g2QF8NjZOknEop_3UFc_R3YYhpEveU2fc-Ks-iM1bA@mail.gmail.com>
@ 2023-08-03  7:58       ` Arnd Bergmann
  2023-08-27  1:23         ` Sergio Paracuellos
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2023-08-03  7:58 UTC (permalink / raw)
  To: Sergio Paracuellos
  Cc: Michael Turquette, Nathan Chancellor, Nick Desaulniers,
	Stephen Boyd, Thomas Bogendoerfer, clang-built-linux,
	kernel test robot, linux-clk, linux-kernel

On Thu, Aug 3, 2023, at 00:35, Sergio Paracuellos wrote:
> Hi Arnd. 
>
> El El jue, 3 ago 2023 a las 0:02, Arnd Bergmann <arnd@kernel.org> escribió:
>> On Wed, Aug 2, 2023, at 23:26, Nick Desaulniers wrote:
>> > On Wed, Aug 2, 2023 at 2:26 AM Sergio Paracuellos <sergio.paracuellos@gmail.com> wrote:
>> >>
>> >> When CONFIG_OF is disabled then the matching table is not referenced and
>> >> the following warning appears:
>> >>
>> >> drivers/clk/ralink/clk-mtmips.c:821:34: warning: unused variable 'mtmips_of_match' [-Wunused-const-variable]
>> >> 821 |   static const struct of_device_id mtmips_of_match[] = {
>> >>     |                          ^
>> >>
>> >> Silence it declaring 'mtmips_of_match' with '__maybe_unused'.
>> >>
>> >> Fixes: 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")
>> >> Reported-by: kernel test robot <lkp@intel.com>
>> >> Closes: https://lore.kernel.org/oe-kbuild-all/202307242310.CdOnd2py-lkp@intel.com/
>> >> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
>> >
>> > I think this is fine; Arnd or Nathan do you have a preference? or thoughts here?
>> >
>> > If not, thanks for the patch.
>> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>> >
>> > (I have a slight preference for wrapping the use in `#ifdef CONFIG_OF`
>> > since with the approach used by this patch, if all users are removed
>> > we will never get a warning for this var. But it's a weak preference;
>> > it's more important to me that we don't have -Werror promote this
>> > warning to a build breakage)
>> 
>> I don't understand why there are two match tables in the same
>> driver, with almost the same contents. I have not looked very
>> closely here, but why can't we just drop the mtmips_clk_of_match[]
>> table (the one without the .data fields) and use the same
>> table for both? Is this because of the ralink,rt2880-reset entry
>> that is missing in mtmips_of_match, or is that another bug?
>
> ralink,rt2880-reset is for old dts compatibility and only applies to 
> reset driver. The one with data fields apply for clocks and is needed.

Ok, I see. It still looks like the two tables can simply be
merged by adding the ralink,rt2880-reset entry to mtmips_of_match[],
which will allow it to be used for mtmips_clk_driver (which doesn't
use the data) as well as for mtmips_clk_init() (which doesn't
need get called for ralink,rt2880-reset).

>> I also see that there is both a platform_driver instance for
>> late probing and a list of CLK_OF_DECLARE_DRIVER() entries.
>> Do we need both here?
>
> This system controller driver provide clock and reset controllers. 
> Clock cannot be a platform driver since we need to set 
> mips_hpr_frequency at a very early sargento. Reset stuff can be a 
> platform driver so both of them are needed.

     Arnd

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: ralink: mtmips: quiet unused variable warning
  2023-08-03  7:58       ` Arnd Bergmann
@ 2023-08-27  1:23         ` Sergio Paracuellos
  0 siblings, 0 replies; 5+ messages in thread
From: Sergio Paracuellos @ 2023-08-27  1:23 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Michael Turquette, Nathan Chancellor, Nick Desaulniers,
	Stephen Boyd, Thomas Bogendoerfer, clang-built-linux,
	kernel test robot, linux-clk, linux-kernel

Hi Arnd,

Sorry for the late response. I was on a family vacation trip.

On Thu, Aug 3, 2023 at 9:58 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> On Thu, Aug 3, 2023, at 00:35, Sergio Paracuellos wrote:
> > Hi Arnd.
> >
> > El El jue, 3 ago 2023 a las 0:02, Arnd Bergmann <arnd@kernel.org> escribió:
> >> On Wed, Aug 2, 2023, at 23:26, Nick Desaulniers wrote:
> >> > On Wed, Aug 2, 2023 at 2:26 AM Sergio Paracuellos <sergio.paracuellos@gmail.com> wrote:
> >> >>
> >> >> When CONFIG_OF is disabled then the matching table is not referenced and
> >> >> the following warning appears:
> >> >>
> >> >> drivers/clk/ralink/clk-mtmips.c:821:34: warning: unused variable 'mtmips_of_match' [-Wunused-const-variable]
> >> >> 821 |   static const struct of_device_id mtmips_of_match[] = {
> >> >>     |                          ^
> >> >>
> >> >> Silence it declaring 'mtmips_of_match' with '__maybe_unused'.
> >> >>
> >> >> Fixes: 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")
> >> >> Reported-by: kernel test robot <lkp@intel.com>
> >> >> Closes: https://lore.kernel.org/oe-kbuild-all/202307242310.CdOnd2py-lkp@intel.com/
> >> >> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> >> >
> >> > I think this is fine; Arnd or Nathan do you have a preference? or thoughts here?
> >> >
> >> > If not, thanks for the patch.
> >> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> >> >
> >> > (I have a slight preference for wrapping the use in `#ifdef CONFIG_OF`
> >> > since with the approach used by this patch, if all users are removed
> >> > we will never get a warning for this var. But it's a weak preference;
> >> > it's more important to me that we don't have -Werror promote this
> >> > warning to a build breakage)
> >>
> >> I don't understand why there are two match tables in the same
> >> driver, with almost the same contents. I have not looked very
> >> closely here, but why can't we just drop the mtmips_clk_of_match[]
> >> table (the one without the .data fields) and use the same
> >> table for both? Is this because of the ralink,rt2880-reset entry
> >> that is missing in mtmips_of_match, or is that another bug?
> >
> > ralink,rt2880-reset is for old dts compatibility and only applies to
> > reset driver. The one with data fields apply for clocks and is needed.
>
> Ok, I see. It still looks like the two tables can simply be
> merged by adding the ralink,rt2880-reset entry to mtmips_of_match[],
> which will allow it to be used for mtmips_clk_driver (which doesn't
> use the data) as well as for mtmips_clk_init() (which doesn't
> need get called for ralink,rt2880-reset).

I think I see your point, thank you. I'll do some test with this
approach and will send a new patch properly addressing this.

Thanks,
    Sergio Paracuellos

>
> >> I also see that there is both a platform_driver instance for
> >> late probing and a list of CLK_OF_DECLARE_DRIVER() entries.
> >> Do we need both here?
> >
> > This system controller driver provide clock and reset controllers.
> > Clock cannot be a platform driver since we need to set
> > mips_hpr_frequency at a very early sargento. Reset stuff can be a
> > platform driver so both of them are needed.
>
>      Arnd

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-27  1:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230802092647.3000666-1-sergio.paracuellos@gmail.com>
2023-08-02 21:26 ` [PATCH] clk: ralink: mtmips: quiet unused variable warning Nick Desaulniers
2023-08-02 21:32   ` Nathan Chancellor
2023-08-02 22:01   ` Arnd Bergmann
     [not found]     ` <CAMhs-H-2g2QF8NjZOknEop_3UFc_R3YYhpEveU2fc-Ks-iM1bA@mail.gmail.com>
2023-08-03  7:58       ` Arnd Bergmann
2023-08-27  1:23         ` Sergio Paracuellos

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).