Skip to contentSkip to conversation

iio: proximity: isl29501: fix unused of_device_id table

PATCH In review Ben Dooks 2 participants 2 messages Mar 8, 2024 – Mar 9, 2024 IIO

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 iio: proximity: isl29501: fix unused of_device_id table

Under certain build conditions, the following warning is being generated from the isl29501 driver due to OF being configured but the driver being built in.

drivers/iio/proximity/isl29501.c:999:34: warning: ‘isl29501_i2c_matches’ defined but not used [-Wunused-const-variable=]
999 | static const struct of_device_id isl29501_i2c_matches[] = {

The isl29501_i2c_matches[] is only passed to MODULE_DEVICE_TABLE() and thus is not referenced if the driver is built into the kernel. Fix by adding a check for MODULE around the #if block.

---
 drivers/iio/proximity/isl29501.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/proximity/isl29501.c +1 -1
index bcebacaf3dab..d509227f47b7 100644
@@ -995,7 +995,7 @@ static const struct i2c_device_id isl29501_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, isl29501_id);
 
-#if defined(CONFIG_OF)
+#if defined(CONFIG_OF) && defined(MODULE)
 static const struct of_device_id isl29501_i2c_matches[] = {
 	{ .compatible = "renesas,isl29501" },
 	{ }
Signature · 1 line
2.37.2.352.g3c44437643
maintainer
#1 lore raw
Quoted 4 lines · On Fri, 8 Mar 2024 18:07:18 +0000 Ben Dooks <[email protected]> wrote:

Under certain build conditions, the following warning is being generated from the isl29501 driver due to OF being configured but the driver being built in.

Quoted 8 lines

drivers/iio/proximity/isl29501.c:999:34: warning: ‘isl29501_i2c_matches’ defined but not used [-Wunused-const-variable=]
999 | static const struct of_device_id isl29501_i2c_matches[] = {

The isl29501_i2c_matches[] is only passed to MODULE_DEVICE_TABLE() and thus is not referenced if the driver is built into the kernel. Fix by adding a check for MODULE around the #if block.

Hi Ben,

Already applied a different fix for this which is to allow matching via the table.

Thanks

Jonathan

Quoted 17 lines
---
 drivers/iio/proximity/isl29501.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/proximity/isl29501.c +1 -1
index bcebacaf3dab..d509227f47b7 100644
@@ -995,7 +995,7 @@ static const struct i2c_device_id isl29501_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, isl29501_id);
 
-#if defined(CONFIG_OF)
+#if defined(CONFIG_OF) && defined(MODULE)
 static const struct of_device_id isl29501_i2c_matches[] = {
 	{ .compatible = "renesas,isl29501" },
 	{ }