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. Signed-off-by: Ben Dooks <ben.dooks@xxxxxxxxxxxxxxx> --- drivers/iio/proximity/isl29501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/proximity/isl29501.c b/drivers/iio/proximity/isl29501.c index bcebacaf3dab..d509227f47b7 100644 --- a/drivers/iio/proximity/isl29501.c +++ b/drivers/iio/proximity/isl29501.c @@ -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" }, { } -- 2.37.2.352.g3c44437643