diff mbox series

[v2,1/2] pwm: rcar: drop of_match_ptr for ID table

Message ID 20230312135120.357713-1-krzysztof.kozlowski@linaro.org
State Accepted
Headers show
Series [v2,1/2] pwm: rcar: drop of_match_ptr for ID table | expand

Commit Message

Krzysztof Kozlowski March 12, 2023, 1:51 p.m. UTC
The driver can match only via the DT table so the table should be always
used and the of_match_ptr does not have any sense (this also allows ACPI
matching via PRP0001, even though it might not be relevant here).  This
also fixes !CONFIG_OF error:

  drivers/pwm/pwm-rcar.c:252:34: error: ‘rcar_pwm_of_table’ defined but not used [-Werror=unused-const-variable=]

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

---

Changes since v1:
1. Extend commit msg.
---
 drivers/pwm/pwm-rcar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Uwe Kleine-König March 12, 2023, 3:42 p.m. UTC | #1
Hello,

On Sun, Mar 12, 2023 at 02:51:19PM +0100, Krzysztof Kozlowski wrote:
> The driver can match only via the DT table so the table should be always
> used and the of_match_ptr does not have any sense (this also allows ACPI
> matching via PRP0001, even though it might not be relevant here).  This
> also fixes !CONFIG_OF error:
> 
>   drivers/pwm/pwm-rcar.c:252:34: error: ‘rcar_pwm_of_table’ defined but not used [-Werror=unused-const-variable=]
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Hmm, I wonder what else is required here to trigger that warning. On
amd64 I also disabled CONFIG_MODULES as otherwise rcar_pwm_of_table is
used by

	MODULE_DEVICE_TABLE(of, rcar_pwm_of_table);

With that I have:

	uwe@taurus:~/work/kbuild/amd64$ make drivers/pwm/pwm-rcar.o 
	  GEN     Makefile
	  CALL    /home/uwe/gsrc/linux/scripts/checksyscalls.sh
	  DESCEND objtool
	  INSTALL libsubcmd_headers
	  CC      drivers/pwm/pwm-rcar.o
	uwe@taurus:~/work/kbuild/amd64$ make drivers/pwm/pwm-rcar.i
	  GEN     Makefile
	  CALL    /home/uwe/gsrc/linux/scripts/checksyscalls.sh
	  DESCEND objtool
	  INSTALL libsubcmd_headers
	  CPP     drivers/pwm/pwm-rcar.i
	uwe@taurus:~/work/kbuild/amd64$ grep rcar_pwm_of_table drivers/pwm/pwm-rcar.i
	static const struct of_device_id rcar_pwm_of_table[] = {

... some time later ...

ah, you also need W=1 to get that warning because of

	# These warnings generated too much noise in a regular build.
	# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
	KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
	KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)

in the toplevel Makefile.

I guess that explains why there is no previous report by one of the
build bots about this issue.

Best regards
Uwe
Krzysztof Kozlowski March 22, 2023, 6:12 p.m. UTC | #2
On 12/03/2023 16:42, Uwe Kleine-König wrote:
> Hello,
> 
> On Sun, Mar 12, 2023 at 02:51:19PM +0100, Krzysztof Kozlowski wrote:
>> The driver can match only via the DT table so the table should be always
>> used and the of_match_ptr does not have any sense (this also allows ACPI
>> matching via PRP0001, even though it might not be relevant here).  This
>> also fixes !CONFIG_OF error:
>>
>>   drivers/pwm/pwm-rcar.c:252:34: error: ‘rcar_pwm_of_table’ defined but not used [-Werror=unused-const-variable=]
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> Hmm, I wonder what else is required here to trigger that warning. On
> amd64 I also disabled CONFIG_MODULES as otherwise rcar_pwm_of_table is
> used by
> 
> 	MODULE_DEVICE_TABLE(of, rcar_pwm_of_table);

1. x86_64 allyesconfig, remove CONFIG_OF
2. Build with W=1 (this was GCC)

Best regards,
Krzysztof
Uwe Kleine-König March 22, 2023, 8:59 p.m. UTC | #3
Hello Krzysztof,

On Wed, Mar 22, 2023 at 07:12:08PM +0100, Krzysztof Kozlowski wrote:
> On 12/03/2023 16:42, Uwe Kleine-König wrote:
> > Hello,
> > 
> > On Sun, Mar 12, 2023 at 02:51:19PM +0100, Krzysztof Kozlowski wrote:
> >> The driver can match only via the DT table so the table should be always
> >> used and the of_match_ptr does not have any sense (this also allows ACPI
> >> matching via PRP0001, even though it might not be relevant here).  This
> >> also fixes !CONFIG_OF error:
> >>
> >>   drivers/pwm/pwm-rcar.c:252:34: error: ‘rcar_pwm_of_table’ defined but not used [-Werror=unused-const-variable=]
> >>
> >> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > 
> > Hmm, I wonder what else is required here to trigger that warning. On
> > amd64 I also disabled CONFIG_MODULES as otherwise rcar_pwm_of_table is
> > used by
> > 
> > 	MODULE_DEVICE_TABLE(of, rcar_pwm_of_table);
> 
> 1. x86_64 allyesconfig, remove CONFIG_OF
> 2. Build with W=1 (this was GCC)

Ah right, it's not that CONFIG_MODULES must be unset, but the driver
must not be configured as module. So I suggest

	This also fixes the compiler warning

		drivers/pwm/pwm-rcar.c:252:34: error: ‘rcar_pwm_of_table’ defined but not used [-Werror=unused-const-variable=]

	for builds with CONFIG_OF=n, CONFIG_PWM_RCAR=y and W=1.

Best regards
Uwe
Thierry Reding April 6, 2023, 1:45 p.m. UTC | #4
On Sun, Mar 12, 2023 at 02:51:19PM +0100, Krzysztof Kozlowski wrote:
> The driver can match only via the DT table so the table should be always
> used and the of_match_ptr does not have any sense (this also allows ACPI
> matching via PRP0001, even though it might not be relevant here).  This
> also fixes !CONFIG_OF error:
> 
>   drivers/pwm/pwm-rcar.c:252:34: error: ‘rcar_pwm_of_table’ defined but not used [-Werror=unused-const-variable=]
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---
> 
> Changes since v1:
> 1. Extend commit msg.
> ---
>  drivers/pwm/pwm-rcar.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

I've applied both patches with an updated commit message clarifying the
exact configuration as pointed out by Uwe.

Thanks,
Thierry
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c
index 55f46d09602b..8f31f3cc93d5 100644
--- a/drivers/pwm/pwm-rcar.c
+++ b/drivers/pwm/pwm-rcar.c
@@ -260,7 +260,7 @@  static struct platform_driver rcar_pwm_driver = {
 	.remove = rcar_pwm_remove,
 	.driver = {
 		.name = "pwm-rcar",
-		.of_match_table = of_match_ptr(rcar_pwm_of_table),
+		.of_match_table = rcar_pwm_of_table,
 	}
 };
 module_platform_driver(rcar_pwm_driver);