Skip to contentSkip to conversation

eeprom: at24: use of_match_ptr()

PATCH Superseded Bartosz Golaszewski 3 participants 6 messages Nov 22, 2023 – Nov 23, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eeprom: at24: use of_match_ptr()

From: Bartosz Golaszewski <[email protected]>

This driver does not depend on CONFIG_OF so using of_match_ptr() makes sense to reduce the size a bit.

---
 drivers/misc/eeprom/at24.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/misc/eeprom/at24.c +2 -1
index f61a80597a22..76a0b9b2fcc4 100644
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/nvmem-provider.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/property.h>
@@ -812,7 +813,7 @@ static struct i2c_driver at24_driver = {
 	.driver = {
 		.name = "at24",
 		.pm = &at24_pm_ops,
-		.of_match_table = at24_of_match,
+		.of_match_table = of_match_ptr(at24_of_match),
 		.acpi_match_table = ACPI_PTR(at24_acpi_ids),
 	},
 	.probe = at24_probe,
Signature · 1 line
2.40.1
#1 lore raw

Hi!

drivers/misc/eeprom/at24.c static struct i2c_driver at24_driver = { · line 816

Quoted 2 lines · Bartosz Golaszewski
drivers/misc/eeprom/at24.c +1 -1
-		.of_match_table = at24_of_match,
+		.of_match_table = of_match_ptr(at24_of_match),

If you do that, you will need to also add #ifdef CONFIG_OF around the at24_of_match definition, of you'll trigger a warning about an unused const variable (for some configs). I think.

Cheers,
Peter

#2 lore raw
Quoted 7 lines · Peter Rosin

Hi!

drivers/misc/eeprom/at24.c static struct i2c_driver at24_driver = { · line 816

Quoted 2 lines · Bartosz Golaszewski
drivers/misc/eeprom/at24.c +1 -1
-             .of_match_table = at24_of_match,
+             .of_match_table = of_match_ptr(at24_of_match),
Quoted 6 lines

If you do that, you will need to also add #ifdef CONFIG_OF around the at24_of_match definition, of you'll trigger a warning about an unused const variable (for some configs). I think.

Cheers,
Peter

Nope, no warnings even with W=2. This is true for unused functions but unused data structures are just silently removed.

Bart

#3 lore raw
Quoted 12 lines · Bartosz Golaszewski
Quoted 11 lines · Peter Rosin

Hi!

drivers/misc/eeprom/at24.c static struct i2c_driver at24_driver = { · line 816

Quoted 2 lines · Bartosz Golaszewski
drivers/misc/eeprom/at24.c +1 -1
-             .of_match_table = at24_of_match,
+             .of_match_table = of_match_ptr(at24_of_match),

If you do that, you will need to also add #ifdef CONFIG_OF around the at24_of_match definition, of you'll trigger a warning about an unused const variable (for some configs). I think.

Quoted 5 lines
Quoted 2 lines

Cheers,
Peter

Nope, no warnings even with W=2. This is true for unused functions but unused data structures are just silently removed.

Then I wonder what the difference is from the following?

https://lore.kernel.org/all/[email protected]/T/#m3a33dc4c3221ae167563bcff70757af776cf07b1

It sure looks like the exact same pattern to me.
I.e. a static const struct of_device_id paired with of_match_ptr().

CHeers,
Peter

#4 lore raw
Quoted 23 lines · Peter Rosin
Quoted 12 lines · Bartosz Golaszewski
Quoted 11 lines · Peter Rosin

Hi!

drivers/misc/eeprom/at24.c static struct i2c_driver at24_driver = { · line 816

Quoted 2 lines · Bartosz Golaszewski
drivers/misc/eeprom/at24.c +1 -1
-             .of_match_table = at24_of_match,
+             .of_match_table = of_match_ptr(at24_of_match),

If you do that, you will need to also add #ifdef CONFIG_OF around the at24_of_match definition, of you'll trigger a warning about an unused const variable (for some configs). I think.

Quoted 5 lines
Quoted 2 lines

Cheers,
Peter

Nope, no warnings even with W=2. This is true for unused functions but unused data structures are just silently removed.

Then I wonder what the difference is from the following?

Quoted 7 lines

https://lore.kernel.org/all/[email protected]/T/#m3a33dc4c3221ae167563bcff70757af776cf07b1

It sure looks like the exact same pattern to me.
I.e. a static const struct of_device_id paired with of_match_ptr().

CHeers,
Peter

Ah, we need __maybe_unused here.

Bart

#5 lore raw
In reply to Bartosz Golaszewski
kernel test robot noticed the following build warnings:

Hi Bartosz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on brgl/gpio/for-next]
[also build test WARNING on linus/master v6.7-rc2 next-20231122] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Bartosz-Golaszewski/eeprom-at24-use-of_match_ptr/20231123-000103
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20231122155916.38037-1-brgl%40bgdev.pl
patch subject: [PATCH] eeprom: at24: use of_match_ptr()
config: i386-buildonly-randconfig-001-20231123 (https://download.01.org/0day-ci/archive/20231123/[email protected]/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231123/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/misc/eeprom/at24.c:246:34: warning: 'at24_of_match' defined but not used [-Wunused-const-variable=]
    static const struct of_device_id at24_of_match[] = {
                                     ^~~~~~~~~~~~~

vim +/at24_of_match +246 drivers/misc/eeprom/at24.c

2b7a5056a0a7ff drivers/i2c/chips/at24.c Wolfram Sang 2008-07-14 245

7f2a2f0d0d66b2 drivers/misc/eeprom/at24.c Javier Martinez Canillas 2017-10-01 @246  static const struct of_device_id at24_of_match[] = {
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  247  	{ .compatible = "atmel,24c00",		.data = &at24_data_24c00 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  248  	{ .compatible = "atmel,24c01",		.data = &at24_data_24c01 },
0f30aca72c3b68 drivers/misc/eeprom/at24.c Bartosz Golaszewski      2017-12-28  249  	{ .compatible = "atmel,24cs01",		.data = &at24_data_24cs01 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  250  	{ .compatible = "atmel,24c02",		.data = &at24_data_24c02 },
0f30aca72c3b68 drivers/misc/eeprom/at24.c Bartosz Golaszewski      2017-12-28  251  	{ .compatible = "atmel,24cs02",		.data = &at24_data_24cs02 },
0f30aca72c3b68 drivers/misc/eeprom/at24.c Bartosz Golaszewski      2017-12-28  252  	{ .compatible = "atmel,24mac402",	.data = &at24_data_24mac402 },
0f30aca72c3b68 drivers/misc/eeprom/at24.c Bartosz Golaszewski      2017-12-28  253  	{ .compatible = "atmel,24mac602",	.data = &at24_data_24mac602 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  254  	{ .compatible = "atmel,spd",		.data = &at24_data_spd },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  255  	{ .compatible = "atmel,24c04",		.data = &at24_data_24c04 },
0f30aca72c3b68 drivers/misc/eeprom/at24.c Bartosz Golaszewski      2017-12-28  256  	{ .compatible = "atmel,24cs04",		.data = &at24_data_24cs04 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  257  	{ .compatible = "atmel,24c08",		.data = &at24_data_24c08 },
0f30aca72c3b68 drivers/misc/eeprom/at24.c Bartosz Golaszewski      2017-12-28  258  	{ .compatible = "atmel,24cs08",		.data = &at24_data_24cs08 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  259  	{ .compatible = "atmel,24c16",		.data = &at24_data_24c16 },
0f30aca72c3b68 drivers/misc/eeprom/at24.c Bartosz Golaszewski      2017-12-28  260  	{ .compatible = "atmel,24cs16",		.data = &at24_data_24cs16 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  261  	{ .compatible = "atmel,24c32",		.data = &at24_data_24c32 },
4791146e9055dd drivers/misc/eeprom/at24.c Marek Vasut              2023-10-10  262  	{ .compatible = "atmel,24c32d-wl",	.data = &at24_data_24c32d_wlp },
0f30aca72c3b68 drivers/misc/eeprom/at24.c Bartosz Golaszewski      2017-12-28  263  	{ .compatible = "atmel,24cs32",		.data = &at24_data_24cs32 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  264  	{ .compatible = "atmel,24c64",		.data = &at24_data_24c64 },
3774740fb22162 drivers/misc/eeprom/at24.c Alexander Stein          2023-10-13  265  	{ .compatible = "atmel,24c64d-wl",	.data = &at24_data_24c64d_wlp },
0f30aca72c3b68 drivers/misc/eeprom/at24.c Bartosz Golaszewski      2017-12-28  266  	{ .compatible = "atmel,24cs64",		.data = &at24_data_24cs64 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  267  	{ .compatible = "atmel,24c128",		.data = &at24_data_24c128 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  268  	{ .compatible = "atmel,24c256",		.data = &at24_data_24c256 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  269  	{ .compatible = "atmel,24c512",		.data = &at24_data_24c512 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  270  	{ .compatible = "atmel,24c1024",	.data = &at24_data_24c1024 },
d08aea21c89dc2 drivers/misc/eeprom/at24.c Maxim Kochetkov          2021-12-10  271  	{ .compatible = "atmel,24c1025",	.data = &at24_data_24c1025 },
37cf28d3b5bca1 drivers/misc/eeprom/at24.c Adrian Bunk              2018-11-29  272  	{ .compatible = "atmel,24c2048",	.data = &at24_data_24c2048 },
b680f4fa74496a drivers/misc/eeprom/at24.c Sven Van Asbroeck        2017-12-20  273  	{ /* END OF LIST */ },
7f2a2f0d0d66b2 drivers/misc/eeprom/at24.c Javier Martinez Canillas 2017-10-01  274  };
7f2a2f0d0d66b2 drivers/misc/eeprom/at24.c Javier Martinez Canillas 2017-10-01  275  MODULE_DEVICE_TABLE(of, at24_of_match);

7f2a2f0d0d66b2 drivers/misc/eeprom/at24.c Javier Martinez Canillas 2017-10-01 276

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki