mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] nvmem: layouts: Create a macro to register drivers
@ 2023-03-15 10:00 Miquel Raynal
  2023-03-15 10:00 ` [PATCH 1/4] nvmem: Add macro to register nvmem layout drivers Miquel Raynal
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Miquel Raynal @ 2023-03-15 10:00 UTC (permalink / raw)
  To: Srinivas Kandagatla, Greg Kroah-Hartman, linux-kernel
  Cc: Michael Walle, Rafał Miłecki, Robert Marko,
	Luka Perkov, Thomas Petazzoni, Miquel Raynal

Hello Srinivas,

Following your former review, here are a few changes creating and using
a macro to simplify nvmem layout driver registration.

While doing that I figured out the MODULE_ALIAS() macro in the Onie TLV
driver was useless and wrong, so there is a patch to drop it, but if you
wish you can also squash it with:
"nvmem: layouts: onie-tlv: Add new layout driver".

Thanks!
Miquèl

Miquel Raynal (4):
  nvmem: Add macro to register nvmem layout drivers
  nvmem: layouts: sl28vpd: Use module_nvmem_layout_driver()
  nvmem: layouts: onie-tlv: Use module_nvmem_layout_driver()
  nvmem: layouts: onie-tlv: Drop wrong module alias

 drivers/nvmem/layouts/onie-tlv.c | 15 +--------------
 drivers/nvmem/layouts/sl28vpd.c  | 14 +-------------
 include/linux/nvmem-provider.h   |  5 +++++
 3 files changed, 7 insertions(+), 27 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] nvmem: Add macro to register nvmem layout drivers
  2023-03-15 10:00 [PATCH 0/4] nvmem: layouts: Create a macro to register drivers Miquel Raynal
@ 2023-03-15 10:00 ` Miquel Raynal
  2023-03-16 16:28   ` Rafał Miłecki
  2023-03-15 10:00 ` [PATCH 2/4] nvmem: layouts: sl28vpd: Use module_nvmem_layout_driver() Miquel Raynal
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Miquel Raynal @ 2023-03-15 10:00 UTC (permalink / raw)
  To: Srinivas Kandagatla, Greg Kroah-Hartman, linux-kernel
  Cc: Michael Walle, Rafał Miłecki, Robert Marko,
	Luka Perkov, Thomas Petazzoni, Miquel Raynal

Provide a module_nvmem_layout_driver() macro at the end of the
nvmem-provider.h header to reduce the boilerplate when registering nvmem
layout drivers.

Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 include/linux/nvmem-provider.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 0cf9f9490514..a1c668018894 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -240,4 +240,9 @@ nvmem_layout_get_match_data(struct nvmem_device *nvmem,
 }
 
 #endif /* CONFIG_NVMEM */
+
+#define module_nvmem_layout_driver(__layout_driver)		\
+	module_driver(__layout_driver, nvmem_layout_register,	\
+		      nvmem_layout_unregister)
+
 #endif  /* ifndef _LINUX_NVMEM_PROVIDER_H */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/4] nvmem: layouts: sl28vpd: Use module_nvmem_layout_driver()
  2023-03-15 10:00 [PATCH 0/4] nvmem: layouts: Create a macro to register drivers Miquel Raynal
  2023-03-15 10:00 ` [PATCH 1/4] nvmem: Add macro to register nvmem layout drivers Miquel Raynal
@ 2023-03-15 10:00 ` Miquel Raynal
  2023-03-15 10:00 ` [PATCH 3/4] nvmem: layouts: onie-tlv: " Miquel Raynal
  2023-03-15 10:00 ` [PATCH 4/4] nvmem: layouts: onie-tlv: Drop wrong module alias Miquel Raynal
  3 siblings, 0 replies; 7+ messages in thread
From: Miquel Raynal @ 2023-03-15 10:00 UTC (permalink / raw)
  To: Srinivas Kandagatla, Greg Kroah-Hartman, linux-kernel
  Cc: Michael Walle, Rafał Miłecki, Robert Marko,
	Luka Perkov, Thomas Petazzoni, Miquel Raynal

Stop open-coding the module init/exit functions. Use the
module_nvmem_layout_driver() instead.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/nvmem/layouts/sl28vpd.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/nvmem/layouts/sl28vpd.c b/drivers/nvmem/layouts/sl28vpd.c
index 9370e41bad73..9cc1715c2fd5 100644
--- a/drivers/nvmem/layouts/sl28vpd.c
+++ b/drivers/nvmem/layouts/sl28vpd.c
@@ -146,19 +146,7 @@ struct nvmem_layout sl28vpd_layout = {
 	.of_match_table = sl28vpd_of_match_table,
 	.add_cells = sl28vpd_add_cells,
 };
-
-static int __init sl28vpd_init(void)
-{
-	return nvmem_layout_register(&sl28vpd_layout);
-}
-
-static void __exit sl28vpd_exit(void)
-{
-	nvmem_layout_unregister(&sl28vpd_layout);
-}
-
-module_init(sl28vpd_init);
-module_exit(sl28vpd_exit);
+module_nvmem_layout_driver(sl28vpd_layout);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Michael Walle <michael@walle.cc>");
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/4] nvmem: layouts: onie-tlv: Use module_nvmem_layout_driver()
  2023-03-15 10:00 [PATCH 0/4] nvmem: layouts: Create a macro to register drivers Miquel Raynal
  2023-03-15 10:00 ` [PATCH 1/4] nvmem: Add macro to register nvmem layout drivers Miquel Raynal
  2023-03-15 10:00 ` [PATCH 2/4] nvmem: layouts: sl28vpd: Use module_nvmem_layout_driver() Miquel Raynal
@ 2023-03-15 10:00 ` Miquel Raynal
  2023-03-15 10:00 ` [PATCH 4/4] nvmem: layouts: onie-tlv: Drop wrong module alias Miquel Raynal
  3 siblings, 0 replies; 7+ messages in thread
From: Miquel Raynal @ 2023-03-15 10:00 UTC (permalink / raw)
  To: Srinivas Kandagatla, Greg Kroah-Hartman, linux-kernel
  Cc: Michael Walle, Rafał Miłecki, Robert Marko,
	Luka Perkov, Thomas Petazzoni, Miquel Raynal

Stop open-coding the module init/exit functions. Use the
module_nvmem_layout_driver() instead.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/nvmem/layouts/onie-tlv.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-tlv.c
index d45b7301a69d..661093de33b4 100644
--- a/drivers/nvmem/layouts/onie-tlv.c
+++ b/drivers/nvmem/layouts/onie-tlv.c
@@ -237,19 +237,7 @@ static struct nvmem_layout onie_tlv_layout = {
 	.of_match_table = onie_tlv_of_match_table,
 	.add_cells = onie_tlv_parse_table,
 };
-
-static int __init onie_tlv_init(void)
-{
-	return nvmem_layout_register(&onie_tlv_layout);
-}
-
-static void __exit onie_tlv_exit(void)
-{
-	nvmem_layout_unregister(&onie_tlv_layout);
-}
-
-module_init(onie_tlv_init);
-module_exit(onie_tlv_exit);
+module_nvmem_layout_driver(onie_tlv_layout);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Miquel Raynal <miquel.raynal@bootlin.com>");
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/4] nvmem: layouts: onie-tlv: Drop wrong module alias
  2023-03-15 10:00 [PATCH 0/4] nvmem: layouts: Create a macro to register drivers Miquel Raynal
                   ` (2 preceding siblings ...)
  2023-03-15 10:00 ` [PATCH 3/4] nvmem: layouts: onie-tlv: " Miquel Raynal
@ 2023-03-15 10:00 ` Miquel Raynal
  3 siblings, 0 replies; 7+ messages in thread
From: Miquel Raynal @ 2023-03-15 10:00 UTC (permalink / raw)
  To: Srinivas Kandagatla, Greg Kroah-Hartman, linux-kernel
  Cc: Michael Walle, Rafał Miłecki, Robert Marko,
	Luka Perkov, Thomas Petazzoni, Miquel Raynal

The MODULE_ALIAS macro is misused here as it carries the
description. There is currently no relevant alias to provide so let's
just drop it.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/nvmem/layouts/onie-tlv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-tlv.c
index 661093de33b4..59fc87ccfcff 100644
--- a/drivers/nvmem/layouts/onie-tlv.c
+++ b/drivers/nvmem/layouts/onie-tlv.c
@@ -242,4 +242,3 @@ module_nvmem_layout_driver(onie_tlv_layout);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Miquel Raynal <miquel.raynal@bootlin.com>");
 MODULE_DESCRIPTION("NVMEM layout driver for Onie TLV table parsing");
-MODULE_ALIAS("NVMEM layout driver for Onie TLV table parsing");
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] nvmem: Add macro to register nvmem layout drivers
  2023-03-15 10:00 ` [PATCH 1/4] nvmem: Add macro to register nvmem layout drivers Miquel Raynal
@ 2023-03-16 16:28   ` Rafał Miłecki
  2023-03-16 16:37     ` Miquel Raynal
  0 siblings, 1 reply; 7+ messages in thread
From: Rafał Miłecki @ 2023-03-16 16:28 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Srinivas Kandagatla, Greg Kroah-Hartman, linux-kernel,
	Michael Walle, Robert Marko, Luka Perkov, Thomas Petazzoni

On 2023-03-15 11:00, Miquel Raynal wrote:
> Provide a module_nvmem_layout_driver() macro at the end of the
> nvmem-provider.h header to reduce the boilerplate when registering 
> nvmem
> layout drivers.

I think you should take care of including <linux/device/driver.h>
instead of depending on module_nvmem_layout_driver() *callers* to do
that.

That would help avoiding errors like:

In file included from drivers/nvmem/layouts/fixed.c:5:
./include/linux/nvmem-provider.h:252:2: warning: data definition has no 
type or storage class
   252 |  module_driver(__layout_driver, nvmem_layout_register, \
       |  ^~~~~~~~~~~~~
./include/linux/nvmem-provider.h:252:2: error: type defaults to 'int' in 
declaration of 'module_driver' [-Werror=implicit-int]
   252 |  module_driver(__layout_driver, nvmem_layout_register, \
       |  ^~~~~~~~~~~~~


> Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  include/linux/nvmem-provider.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/nvmem-provider.h 
> b/include/linux/nvmem-provider.h
> index 0cf9f9490514..a1c668018894 100644
> --- a/include/linux/nvmem-provider.h
> +++ b/include/linux/nvmem-provider.h
> @@ -240,4 +240,9 @@ nvmem_layout_get_match_data(struct nvmem_device 
> *nvmem,
>  }
> 
>  #endif /* CONFIG_NVMEM */
> +
> +#define module_nvmem_layout_driver(__layout_driver)		\
> +	module_driver(__layout_driver, nvmem_layout_register,	\
> +		      nvmem_layout_unregister)
> +
>  #endif  /* ifndef _LINUX_NVMEM_PROVIDER_H */

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] nvmem: Add macro to register nvmem layout drivers
  2023-03-16 16:28   ` Rafał Miłecki
@ 2023-03-16 16:37     ` Miquel Raynal
  0 siblings, 0 replies; 7+ messages in thread
From: Miquel Raynal @ 2023-03-16 16:37 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Srinivas Kandagatla, Greg Kroah-Hartman, linux-kernel,
	Michael Walle, Robert Marko, Luka Perkov, Thomas Petazzoni

Hi Rafał,

rafal@milecki.pl wrote on Thu, 16 Mar 2023 17:28:04 +0100:

> On 2023-03-15 11:00, Miquel Raynal wrote:
> > Provide a module_nvmem_layout_driver() macro at the end of the
> > nvmem-provider.h header to reduce the boilerplate when registering > nvmem
> > layout drivers.  
> 
> I think you should take care of including <linux/device/driver.h>
> instead of depending on module_nvmem_layout_driver() *callers* to do
> that.

Right, I'll do that.

> 
> That would help avoiding errors like:
> 
> In file included from drivers/nvmem/layouts/fixed.c:5:
> ./include/linux/nvmem-provider.h:252:2: warning: data definition has no type or storage class
>    252 |  module_driver(__layout_driver, nvmem_layout_register, \
>        |  ^~~~~~~~~~~~~
> ./include/linux/nvmem-provider.h:252:2: error: type defaults to 'int' in declaration of 'module_driver' [-Werror=implicit-int]
>    252 |  module_driver(__layout_driver, nvmem_layout_register, \
>        |  ^~~~~~~~~~~~~
> 
> 
> > Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> >  include/linux/nvmem-provider.h | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/include/linux/nvmem-provider.h > b/include/linux/nvmem-provider.h
> > index 0cf9f9490514..a1c668018894 100644
> > --- a/include/linux/nvmem-provider.h
> > +++ b/include/linux/nvmem-provider.h
> > @@ -240,4 +240,9 @@ nvmem_layout_get_match_data(struct nvmem_device > *nvmem,
> >  }
> > 
> >  #endif /* CONFIG_NVMEM */
> > +
> > +#define module_nvmem_layout_driver(__layout_driver)		\
> > +	module_driver(__layout_driver, nvmem_layout_register,	\
> > +		      nvmem_layout_unregister)
> > +
> >  #endif  /* ifndef _LINUX_NVMEM_PROVIDER_H */  


Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-16 16:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15 10:00 [PATCH 0/4] nvmem: layouts: Create a macro to register drivers Miquel Raynal
2023-03-15 10:00 ` [PATCH 1/4] nvmem: Add macro to register nvmem layout drivers Miquel Raynal
2023-03-16 16:28   ` Rafał Miłecki
2023-03-16 16:37     ` Miquel Raynal
2023-03-15 10:00 ` [PATCH 2/4] nvmem: layouts: sl28vpd: Use module_nvmem_layout_driver() Miquel Raynal
2023-03-15 10:00 ` [PATCH 3/4] nvmem: layouts: onie-tlv: " Miquel Raynal
2023-03-15 10:00 ` [PATCH 4/4] nvmem: layouts: onie-tlv: Drop wrong module alias Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®