diff mbox series

iio: proximity: isl29501: fix unused of_device_id table

Message ID 20240308180718.1913090-1-ben.dooks@codethink.co.uk (mailing list archive)
State Rejected
Headers show
Series iio: proximity: isl29501: fix unused of_device_id table | expand

Commit Message

Ben Dooks March 8, 2024, 6:07 p.m. UTC
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@codethink.co.uk>
---
 drivers/iio/proximity/isl29501.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron March 9, 2024, 5:35 p.m. UTC | #1
On Fri,  8 Mar 2024 18:07:18 +0000
Ben Dooks <ben.dooks@codethink.co.uk> 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.
> 
> 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@codethink.co.uk>
Hi Ben,

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

Thanks

Jonathan
> ---
>  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" },
>  	{ }
diff mbox series

Patch

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" },
 	{ }