diff mbox series

[-next,v2] drm/i2c: tda998x: remove redundant CONFIG_OF and of_match_ptr

Message ID 20230801033220.219869-1-wangzhu9@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next,v2] drm/i2c: tda998x: remove redundant CONFIG_OF and of_match_ptr | expand

Commit Message

wangzhu Aug. 1, 2023, 3:32 a.m. UTC
The driver depends on CONFIG_OF, so it is not necessary to use CONFIG_OF
and of_match_ptr here, we remove them all.

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>

---
Changes in v2:
Remove CONFIG_OF which includes tda998x_ids
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Andy Shevchenko Aug. 1, 2023, 6 p.m. UTC | #1
On Tue, Aug 01, 2023 at 11:32:20AM +0800, Zhu Wang wrote:
> The driver depends on CONFIG_OF, so it is not necessary to use CONFIG_OF
> and of_match_ptr here, we remove them all.
> 
> 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.

Instead, you may convert this driver to use device property APIs and make it
OF-free (okay, almost, with one API that still would be called for OF, but not
for the rest).
Arnd Bergmann Aug. 1, 2023, 6:10 p.m. UTC | #2
On Tue, Aug 1, 2023, at 20:00, Andy Shevchenko wrote:
> On Tue, Aug 01, 2023 at 11:32:20AM +0800, Zhu Wang wrote:
>> The driver depends on CONFIG_OF, so it is not necessary to use CONFIG_OF
>> and of_match_ptr here, we remove them all.
>> 
>> 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.
>
> Instead, you may convert this driver to use device property APIs and make it
> OF-free (okay, almost, with one API that still would be called for OF, but not
> for the rest).

No, there is really no need for that. That can be done if anyone ever
needs this driver to again work with hardwired properties from another
device, or from ACPI, until then this would be a waste of time.

Removing of_match_ptr() on the other hand is useful since it is
a common source of bugs.

      Arnd
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index d8d7de18dd65..9666e0746240 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -2084,13 +2084,11 @@  static void tda998x_remove(struct i2c_client *client)
 	tda998x_destroy(&client->dev);
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id tda998x_dt_ids[] = {
 	{ .compatible = "nxp,tda998x", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, tda998x_dt_ids);
-#endif
 
 static const struct i2c_device_id tda998x_ids[] = {
 	{ "tda998x", 0 },
@@ -2103,7 +2101,7 @@  static struct i2c_driver tda998x_driver = {
 	.remove = tda998x_remove,
 	.driver = {
 		.name = "tda998x",
-		.of_match_table = of_match_ptr(tda998x_dt_ids),
+		.of_match_table = tda998x_dt_ids,
 	},
 	.id_table = tda998x_ids,
 };