diff mbox series

[V3,1/5] i2c: gpio: Fix potential unused warning for 'i2c_gpio_dt_ids'

Message ID 4ace98785f900bf1a818d006ae5906f6b51edf7e.1669359515.git.zhoubinbin@loongson.cn
State Superseded
Headers show
Series i2c: ls2x: Add support for the Loongson-2K/LS7A I2C controller | expand

Commit Message

Binbin Zhou Nov. 25, 2022, 8:54 a.m. UTC
of_match_ptr() compiles into NULL if CONFIG_OF is disabled.
Fix warning by dropping of_match_ptr().

Suggested by Andy Shevchenko, thanks.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/i2c/busses/i2c-gpio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Andy Shevchenko Nov. 25, 2022, 10:21 a.m. UTC | #1
On Fri, Nov 25, 2022 at 04:54:11PM +0800, Binbin Zhou wrote:
> of_match_ptr() compiles into NULL if CONFIG_OF is disabled.
> Fix warning by dropping of_match_ptr().

> Suggested by Andy Shevchenko, thanks.
> 
> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>

We have a tag for that:

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Arnd Bergmann Nov. 25, 2022, 10:35 a.m. UTC | #2
On Fri, Nov 25, 2022, at 09:54, Binbin Zhou wrote:
> of_match_ptr() compiles into NULL if CONFIG_OF is disabled.
> Fix warning by dropping of_match_ptr().
>
> Suggested by Andy Shevchenko, thanks.
>
> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>

Acked-by: Arnd Bergmann <arnd@arndb.de>

I think this is a useful cleanup in general, though I don't think
there is an actual warning in this particular driver that gets fixed
by the patch, so it would be good to change the changelog text to
describe this better: dropping a matching #ifdef check along with
dropping of_match_ptr() is just a cleanup, while dropping
of_match_ptr() that has no corresponding #ifdef fixes an actual
warning.
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index b1985c1667e1..0e4385a9bcf7 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -482,19 +482,17 @@  static int i2c_gpio_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#if defined(CONFIG_OF)
 static const struct of_device_id i2c_gpio_dt_ids[] = {
 	{ .compatible = "i2c-gpio", },
 	{ /* sentinel */ }
 };
 
 MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids);
-#endif
 
 static struct platform_driver i2c_gpio_driver = {
 	.driver		= {
 		.name	= "i2c-gpio",
-		.of_match_table	= of_match_ptr(i2c_gpio_dt_ids),
+		.of_match_table	= i2c_gpio_dt_ids,
 	},
 	.probe		= i2c_gpio_probe,
 	.remove		= i2c_gpio_remove,