diff mbox series

[-next] gpio: max732x: remove redundant CONFIG_OF and of_match_ptr

Message ID 20230801033620.221270-1-wangzhu9@huawei.com
State Superseded
Headers show
Series [-next] gpio: max732x: remove redundant CONFIG_OF and of_match_ptr | expand

Commit Message

Zhu Wang Aug. 1, 2023, 3:36 a.m. UTC
The driver depends on CONFIG_OF, so it is not necessary to use
of_match_ptr here. We remove both CONFIG_OF and of_match_ptr here.

Even for drivers that do not depend on CONFIG_OF, it's almost always
better to leave out the of_match_ptr(), since the only thing it can
possibly do is to save a few bytes of .text if a driver can be used both
with and without it.

Signed-off-by: Zhu Wang <wangzhu9@huawei.com>
---
 drivers/gpio/gpio-max732x.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Andy Shevchenko Aug. 1, 2023, 6:43 p.m. UTC | #1
On Tue, Aug 01, 2023 at 11:36:20AM +0800, Zhu Wang wrote:
> The driver depends on CONFIG_OF, so it is not necessary to use
> of_match_ptr here. We remove both CONFIG_OF and of_match_ptr here.

of_match_ptr()

> Even for drivers that do not depend on CONFIG_OF, it's almost always
> better to leave out the of_match_ptr(), since the only thing it can
> possibly do is to save a few bytes of .text if a driver can be used both
> with and without it.

With this change, drop of.h which is not needed anymore.
OTOH the mod_devicetable.h is implicitly included by i2c.h
and this is used by so many drivers that we may omit explicit
inclusion.
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c
index fca9ca68e387..da7e9c7c431c 100644
--- a/drivers/gpio/gpio-max732x.c
+++ b/drivers/gpio/gpio-max732x.c
@@ -114,7 +114,6 @@  static const struct i2c_device_id max732x_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, max732x_id);
 
-#ifdef CONFIG_OF
 static const struct of_device_id max732x_of_table[] = {
 	{ .compatible = "maxim,max7319" },
 	{ .compatible = "maxim,max7320" },
@@ -128,7 +127,6 @@  static const struct of_device_id max732x_of_table[] = {
 	{ }
 };
 MODULE_DEVICE_TABLE(of, max732x_of_table);
-#endif
 
 struct max732x_chip {
 	struct gpio_chip gpio_chip;
@@ -709,7 +707,7 @@  static int max732x_probe(struct i2c_client *client)
 static struct i2c_driver max732x_driver = {
 	.driver = {
 		.name		= "max732x",
-		.of_match_table	= of_match_ptr(max732x_of_table),
+		.of_match_table	= max732x_of_table,
 	},
 	.probe		= max732x_probe,
 	.id_table	= max732x_id,