drm/bridge: fix -Wunused-const-variable= warning
Subsystems (3)
PATCH 1/1 drm/bridge: fix -Wunused-const-variable= warning
When building with W=1, the following warning occurs.
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c:48:17: warning: ‘anx781x_i2c_addresses’ defined but not used [-Wunused-const-variable=]
static const u8 anx781x_i2c_addresses[] = {
^~~~~~~~~~~~~~~~~~~~~drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c:40:17: warning: ‘anx7808_i2c_addresses’ defined but not used [-Wunused-const-variable=]
static const u8 anx7808_i2c_addresses[] = {
The definition of above two data variables is included by the macro CONFIG_OF, so we also include the data variable definitions in the macro CONFIG_OF. And in addition the data variable anx78xx_match_table is included in the macro CONFIG_OF, so we add CONFIG_OF to the place where it is used.
--- drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c +4 -0
@@ -37,6 +37,7 @@#define XTAL_CLK 270/* 27M */ +#if IS_ENABLED (CONFIG_OF )static const u8 anx7808_i2c_addresses[] = { [I2C_IDX_TX_P0 ] =0x78 , [I2C_IDX_TX_P1] = 0x7a,
@@ -52,6 +53,7 @@ static const u8 anx781x_i2c_addresses[] = { [I2C_IDX_RX_P0] = 0x7e, [I2C_IDX_RX_P1] = 0x80, }; +#endif struct anx78xx_platform_data {struct regulator *dvdd10;
@@ -1387,7 +1389,9 @@ MODULE_DEVICE_TABLE(of, anx78xx_match_table);static struct i2c_driver anx78xx_driver = { .driver = { .name ="anx7814" , +#if IS_ENABLED(CONFIG_OF) .of_match_table =of_match_ptr (anx78xx_match_table), +#endif }, .probe = anx78xx_i2c_probe, .remove = anx78xx_i2c_remove,
Signature · 1 line
2.17.1
[Cc += Arnd, Andy who did similar changes in the past]
Hello,
Quoted 34 lines · Zhu Wang
When building with W=1, the following warning occurs.
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c:48:17: warning: ‘anx781x_i2c_addresses’ defined but not used [-Wunused-const-variable=]static const u8 anx781x_i2c_addresses[] = { ^~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c:40:17: warning: ‘anx7808_i2c_addresses’ defined but not used [-Wunused-const-variable=]
static const u8 anx7808_i2c_addresses[] = {The definition of above two data variables is included by the macro
CONFIG_OF, so we also include the data variable definitions in the macroCONFIG_OF. And in addition the data variableanx78xx_match_tableis included in the macroCONFIG_OF, so we addCONFIG_OFto the place where it is used.Fixes 5d97408e0d70 ("drm/bridge: move ANA78xx driver to analogix subdirectory")Signed-off-by Zhu Wang <[email protected]>--- drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c +1
-0@@ -37,6 +37,7 @@#define XTAL_CLK 270/* 27M */ +#if IS_ENABLED (CONFIG_OF )static const u8 anx7808_i2c_addresses[] = { [I2C_IDX_TX_P0 ] =0x78 , [I2C_IDX_TX_P1] = 0x7a,
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c static const u8 anx781x_i2c_addresses[] = { · line 56
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c +1
-0@@ -52,6 +53,7 @@ static const u8 anx781x_i2c_addresses[] = { [I2C_IDX_RX_P0] = 0x7e, [I2C_IDX_RX_P1] = 0x80, }; +#endif
You can mark anx7808_i2c_addresses with __maybe_unused, then the #if isn't needed.
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c MODULE_DEVICE_TABLE(of, anx78xx_match_table); · line 1394
Quoted 9 lines
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c +2
-0struct anx78xx_platform_data {struct regulator *dvdd10;@@ -1387,7 +1389,9 @@ MODULE_DEVICE_TABLE(of, anx78xx_match_table);static struct i2c_driver anx78xx_driver = { .driver = { .name ="anx7814" , +#if IS_ENABLED(CONFIG_OF) .of_match_table =of_match_ptr (anx78xx_match_table), +#endif
If CONFIG_OF is disabled of_match_ptr(something) evaluates to NULL, so you can drop the #if here.
Having said that the better fix is probably to just do
.of_match_table = anx78xx_match_table,
as systems using ACPI can benefit from the of_match_table, too. See b89a9e9890d4 ("gpio: aggregator: Remove CONFIG_OF and of_match_ptr() protections") for an example.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Quoted 3 lines · Uwe Kleine-König
Quoted 2 lines · Zhu Wang
Fixes 5d97408e0d70 ("drm/bridge: move ANA78xx driver to analogix subdirectory")
This is the wrong commit, the driver was just in a different place before that, and the bug was already present in commit 0647e7dd3f7ab ("drm/bridge: Add Analogix anx78xx support").
Quoted 13 lines
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c static const u8 anx781x_i2c_addresses[] = { · line 56
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c +2
-0+#if IS_ENABLED (CONFIG_OF )static const u8 anx7808_i2c_addresses[] = { [I2C_IDX_TX_P0 ] =0x78 , [I2C_IDX_TX_P1] = 0x7a,@@ -52,6 +53,7 @@ static const u8 anx781x_i2c_addresses[] = { [I2C_IDX_RX_P0] = 0x7e, [I2C_IDX_RX_P1] = 0x80, }; +#endif You can mark
anx7808_i2c_addresseswith__maybe_unused, then the #if isn't needed.
Neither of these should be needed, as the driver only works with CONFIG_OF anyway.
Quoted 13 lines
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c MODULE_DEVICE_TABLE(of, anx78xx_match_table); · line 1394
Quoted 9 lines
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c +2
-0struct anx78xx_platform_data {struct regulator *dvdd10;@@ -1387,7 +1389,9 @@ MODULE_DEVICE_TABLE(of, anx78xx_match_table);static struct i2c_driver anx78xx_driver = { .driver = { .name ="anx7814" , +#if IS_ENABLED(CONFIG_OF) .of_match_table =of_match_ptr (anx78xx_match_table), +#endifIf
CONFIG_OFis disabledof_match_ptr(something)evaluates to NULL, so you can drop the #if here.
Quoted 7 lines
Having said that the better fix is probably to just do
.of_match_table =
anx78xx_match_table,as systems using ACPI can benefit from the
of_match_table, too. Seeb89a9e9890d4("gpio: aggregator: RemoveCONFIG_OFandof_match_ptr()protections") for an example.
Agreed, removing the #ifdef checks and the of_match_ptr() wrapper is the right solution here. I see similar things in other bridge drivers that could be changed at the same time:
$ git grep of_match_ptr drivers/gpu/drm/bridge/ drivers/gpu/drm/bridge/analogix/analogix-anx6345.c: .of_match_table = of_match_ptr(anx6345_match_table), drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c: .of_match_table = of_match_ptr(anx78xx_match_table), drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c: .of_match_table = of_match_ptr(mhdp_ids), drivers/gpu/drm/bridge/chrontel-ch7033.c: .of_match_table = of_match_ptr(ch7033_dt_ids), drivers/gpu/drm/bridge/sil-sii8620.c: .of_match_table = of_match_ptr(sii8620_dt_match), drivers/gpu/drm/bridge/ti-tfp410.c: .of_match_table = of_match_ptr(tfp410_match),
The other ones are even worse because they use of_match_ptr() without the corresponding #ifdef around the match table, so the of_match_ptr() does not even have the effect of saving a few bytes of .data segment.
Arnd