diff mbox series

eeprom: at24: use of_match_ptr()

Message ID 20231122155916.38037-1-brgl@bgdev.pl
State Superseded
Headers show
Series eeprom: at24: use of_match_ptr() | expand

Commit Message

Bartosz Golaszewski Nov. 22, 2023, 3:59 p.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/misc/eeprom/at24.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Peter Rosin Nov. 22, 2023, 4:41 p.m. UTC | #1
Hi!

2023-11-22 at 16:59, Bartosz Golaszewski wrote:
> -		.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
Bartosz Golaszewski Nov. 22, 2023, 4:57 p.m. UTC | #2
On Wed, 22 Nov 2023 at 17:41, Peter Rosin <peda@axentia.se> wrote:
>
> Hi!
>
> 2023-11-22 at 16:59, Bartosz Golaszewski wrote:
> > -             .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

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

Bart
Peter Rosin Nov. 22, 2023, 5:13 p.m. UTC | #3
2023-11-22 at 17:57, Bartosz Golaszewski wrote:
> On Wed, 22 Nov 2023 at 17:41, Peter Rosin <peda@axentia.se> wrote:
>>
>> Hi!
>>
>> 2023-11-22 at 16:59, Bartosz Golaszewski wrote:
>>> -             .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
> 
> 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/202311161306.opyfcoCY-lkp@intel.com/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
Bartosz Golaszewski Nov. 22, 2023, 5:26 p.m. UTC | #4
On Wed, Nov 22, 2023 at 6:14 PM Peter Rosin <peda@axentia.se> wrote:
>
>
> 2023-11-22 at 17:57, Bartosz Golaszewski wrote:
> > On Wed, 22 Nov 2023 at 17:41, Peter Rosin <peda@axentia.se> wrote:
> >>
> >> Hi!
> >>
> >> 2023-11-22 at 16:59, Bartosz Golaszewski wrote:
> >>> -             .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
> >
> > 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/202311161306.opyfcoCY-lkp@intel.com/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
kernel test robot Nov. 23, 2023, 3:16 a.m. UTC | #5
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/202311231054.oSloZJkd-lkp@intel.com/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/202311231054.oSloZJkd-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311231054.oSloZJkd-lkp@intel.com/

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
diff mbox series

Patch

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index f61a80597a22..76a0b9b2fcc4 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -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,