Skip to contentSkip to conversation

clk: ralink: mtmips: quiet unused variable warning

PATCH Superseded Sergio Paracuellos 4 participants 6 messages Aug 2, 2023 – Aug 27, 2023 1 message not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sergio Paracuellos

author maintainer
#0 lore raw

PATCH 1/1 clk: ralink: mtmips: quiet unused variable warning

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")
---
 drivers/clk/ralink/clk-mtmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/ralink/clk-mtmips.c +1 -1
index 1e7991439527..6716394b28a3 100644
@@ -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,
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Sergio Paracuellos

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[] = {
| ^

Quoted 6 lines

Silence it declaring 'mtmips_of_match' with '__maybe_unused'.

Fixes 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")

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

If not, thanks for the patch.

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

Quoted 20 lines
---
 drivers/clk/ralink/clk-mtmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/ralink/clk-mtmips.c +1 -2
index 1e7991439527..6716394b28a3 100644
@@ -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

Signature · 2 lines
Thanks,
~Nick Desaulniers
Reviewed-by
#2 lore raw
Quoted 10 lines · Nick Desaulniers
Quoted 8 lines · Sergio Paracuellos

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[] = {
| ^

Quoted 8 lines
Quoted 6 lines

Silence it declaring 'mtmips_of_match' with '__maybe_unused'.

Fixes 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")

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:

Quoted 34 lines

If not, thanks for the patch.

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

Quoted 20 lines
---
 drivers/clk/ralink/clk-mtmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/ralink/clk-mtmips.c +1 -2
index 1e7991439527..6716394b28a3 100644
@@ -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

Signature · 2 lines
Thanks,
~Nick Desaulniers
#3 lore raw
In reply to Nick Desaulniers
Quoted 18 lines · Nick Desaulniers
Quoted 8 lines · Sergio Paracuellos

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[] = {
| ^

Quoted 6 lines

Silence it declaring 'mtmips_of_match' with '__maybe_unused'.

Fixes 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")

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

Quoted 8 lines

If not, thanks for the patch.

(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

#5 lore raw
In reply to a message not in the archive
Quoted 38 lines · Sergio Paracuellos

Hi Arnd.

Quoted 28 lines · Arnd Bergmann
Quoted 18 lines · Nick Desaulniers
Quoted 8 lines · Sergio Paracuellos

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[] = {
| ^

Quoted 6 lines

Silence it declaring 'mtmips_of_match' with '__maybe_unused'.

Fixes 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")

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

Quoted 8 lines

If not, thanks for the patch.

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

Quoted 6 lines

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?

Quoted 2 lines

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

Quoted 8 lines
Quoted 3 lines

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

author maintainer
#6 lore raw

Hi Arnd,

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

Quoted 40 lines · Arnd Bergmann
Quoted 38 lines · Sergio Paracuellos

Hi Arnd.

Quoted 34 lines · Arnd Bergmann
Quoted 18 lines · Nick Desaulniers
Quoted 8 lines · Sergio Paracuellos

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[] = {
| ^

Quoted 6 lines

Silence it declaring 'mtmips_of_match' with '__maybe_unused'.

Fixes 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs")

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

Quoted 8 lines

If not, thanks for the patch.

(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?

Quoted 8 lines
Quoted 2 lines

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

Quoted 11 lines
Quoted 9 lines
Quoted 4 lines

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