All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro
@ 2021-02-16 11:07 Andy Shevchenko
  2021-02-16 11:07 ` [PATCH v2 2/3] spi: butterfly: Switch to use module_parport_driver() Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Andy Shevchenko @ 2021-02-16 11:07 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, Sudip Mukherjee, linux-spi, linux-kernel

Introduce module_parport_driver() helper macro to reduce boilerplate
in the existing and new code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: fixed typo in the macro
 include/linux/parport.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/linux/parport.h b/include/linux/parport.h
index 1fb508c19e83..54539b80021e 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -301,9 +301,19 @@ int __must_check __parport_register_driver(struct parport_driver *,
 	__parport_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
 
 /* Unregister a high-level driver. */
-extern void parport_unregister_driver (struct parport_driver *);
 void parport_unregister_driver(struct parport_driver *);
 
+/**
+ * module_parport_driver() - Helper macro for registering a modular parport driver
+ * @__parport_driver: struct parport_driver to be used
+ *
+ * Helper macro for parport drivers which do not do anything special in module
+ * init and exit. This eliminates a lot of boilerplate. Each module may only
+ * use this macro once, and calling it replaces module_init() and module_exit().
+ */
+#define module_parport_driver(__parport_driver) \
+	module_driver(__parport_driver, parport_register_driver, parport_unregister_driver)
+
 /* If parport_register_driver doesn't fit your needs, perhaps
  * parport_find_xxx does. */
 extern struct parport *parport_find_number (int);
-- 
2.30.0


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

* [PATCH v2 2/3] spi: butterfly: Switch to use module_parport_driver()
  2021-02-16 11:07 [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro Andy Shevchenko
@ 2021-02-16 11:07 ` Andy Shevchenko
  2021-02-16 11:07 ` [PATCH v2 3/3] spi: lm70llp: " Andy Shevchenko
  2021-02-26 17:03 ` [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro Andy Shevchenko
  2 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2021-02-16 11:07 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, Sudip Mukherjee, linux-spi, linux-kernel

Switch to use module_parport_driver() to reduce boilerplate code.
Note, device_initcall() is a default for module_init().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
---
v2: added Ack (Mark)
 drivers/spi/spi-butterfly.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/spi/spi-butterfly.c b/drivers/spi/spi-butterfly.c
index 7e71a351f3b7..cceae816cebc 100644
--- a/drivers/spi/spi-butterfly.c
+++ b/drivers/spi/spi-butterfly.c
@@ -317,18 +317,7 @@ static struct parport_driver butterfly_driver = {
 	.detach =	butterfly_detach,
 	.devmodel = true,
 };
-
-static int __init butterfly_init(void)
-{
-	return parport_register_driver(&butterfly_driver);
-}
-device_initcall(butterfly_init);
-
-static void __exit butterfly_exit(void)
-{
-	parport_unregister_driver(&butterfly_driver);
-}
-module_exit(butterfly_exit);
+module_parport_driver(butterfly_driver);
 
 MODULE_DESCRIPTION("Parport Adapter driver for AVR Butterfly");
 MODULE_LICENSE("GPL");
-- 
2.30.0


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

* [PATCH v2 3/3] spi: lm70llp: Switch to use module_parport_driver()
  2021-02-16 11:07 [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro Andy Shevchenko
  2021-02-16 11:07 ` [PATCH v2 2/3] spi: butterfly: Switch to use module_parport_driver() Andy Shevchenko
@ 2021-02-16 11:07 ` Andy Shevchenko
  2021-02-26 17:03 ` [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro Andy Shevchenko
  2 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2021-02-16 11:07 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, Sudip Mukherjee, linux-spi, linux-kernel

Switch to use module_parport_driver() to reduce boilerplate code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
---
v2: added Ack (Mark), drop unneeded note from the commit message
 drivers/spi/spi-lm70llp.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/spi/spi-lm70llp.c b/drivers/spi/spi-lm70llp.c
index 174dba29b1dd..f914b8d2043e 100644
--- a/drivers/spi/spi-lm70llp.c
+++ b/drivers/spi/spi-lm70llp.c
@@ -320,18 +320,7 @@ static struct parport_driver spi_lm70llp_drv = {
 	.detach =	spi_lm70llp_detach,
 	.devmodel =	true,
 };
-
-static int __init init_spi_lm70llp(void)
-{
-	return parport_register_driver(&spi_lm70llp_drv);
-}
-module_init(init_spi_lm70llp);
-
-static void __exit cleanup_spi_lm70llp(void)
-{
-	parport_unregister_driver(&spi_lm70llp_drv);
-}
-module_exit(cleanup_spi_lm70llp);
+module_parport_driver(spi_lm70llp_drv);
 
 MODULE_AUTHOR("Kaiwan N Billimoria <kaiwan@designergraphix.com>");
 MODULE_DESCRIPTION(
-- 
2.30.0


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

* Re: [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro
  2021-02-16 11:07 [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro Andy Shevchenko
  2021-02-16 11:07 ` [PATCH v2 2/3] spi: butterfly: Switch to use module_parport_driver() Andy Shevchenko
  2021-02-16 11:07 ` [PATCH v2 3/3] spi: lm70llp: " Andy Shevchenko
@ 2021-02-26 17:03 ` Andy Shevchenko
  2021-02-28 23:27   ` Sudip Mukherjee
  2 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2021-02-26 17:03 UTC (permalink / raw)
  To: Mark Brown, Sudip Mukherjee, linux-spi, linux-kernel

On Tue, Feb 16, 2021 at 01:07:39PM +0200, Andy Shevchenko wrote:
> Introduce module_parport_driver() helper macro to reduce boilerplate
> in the existing and new code.

Sudip, any comments on this?

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: fixed typo in the macro
>  include/linux/parport.h | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/parport.h b/include/linux/parport.h
> index 1fb508c19e83..54539b80021e 100644
> --- a/include/linux/parport.h
> +++ b/include/linux/parport.h
> @@ -301,9 +301,19 @@ int __must_check __parport_register_driver(struct parport_driver *,
>  	__parport_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
>  
>  /* Unregister a high-level driver. */
> -extern void parport_unregister_driver (struct parport_driver *);
>  void parport_unregister_driver(struct parport_driver *);
>  
> +/**
> + * module_parport_driver() - Helper macro for registering a modular parport driver
> + * @__parport_driver: struct parport_driver to be used
> + *
> + * Helper macro for parport drivers which do not do anything special in module
> + * init and exit. This eliminates a lot of boilerplate. Each module may only
> + * use this macro once, and calling it replaces module_init() and module_exit().
> + */
> +#define module_parport_driver(__parport_driver) \
> +	module_driver(__parport_driver, parport_register_driver, parport_unregister_driver)
> +
>  /* If parport_register_driver doesn't fit your needs, perhaps
>   * parport_find_xxx does. */
>  extern struct parport *parport_find_number (int);
> -- 
> 2.30.0
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro
  2021-02-26 17:03 ` [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro Andy Shevchenko
@ 2021-02-28 23:27   ` Sudip Mukherjee
  2021-03-01 12:11     ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Sudip Mukherjee @ 2021-02-28 23:27 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Mark Brown, linux-spi, linux-kernel

Hi Andy,

On Fri, Feb 26, 2021 at 07:03:09PM +0200, Andy Shevchenko wrote:
> On Tue, Feb 16, 2021 at 01:07:39PM +0200, Andy Shevchenko wrote:
> > Introduce module_parport_driver() helper macro to reduce boilerplate
> > in the existing and new code.
> 
> Sudip, any comments on this?

Sorry for the delay in reply.
lgtm. I think there are few more drivers which can also use this new helper.
Will you like to do them also?

Acked-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>


--
Regards
Sudip

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

* Re: [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro
  2021-02-28 23:27   ` Sudip Mukherjee
@ 2021-03-01 12:11     ` Andy Shevchenko
  2021-03-02 14:51       ` Sudip Mukherjee
  0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2021-03-01 12:11 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: Mark Brown, linux-spi, linux-kernel

On Sun, Feb 28, 2021 at 11:27:10PM +0000, Sudip Mukherjee wrote:
> On Fri, Feb 26, 2021 at 07:03:09PM +0200, Andy Shevchenko wrote:
> > On Tue, Feb 16, 2021 at 01:07:39PM +0200, Andy Shevchenko wrote:
> > > Introduce module_parport_driver() helper macro to reduce boilerplate
> > > in the existing and new code.
> > 
> > Sudip, any comments on this?
> 
> Sorry for the delay in reply.
> lgtm. I think there are few more drivers which can also use this new helper.
> Will you like to do them also?

Yes, that's the (slow going) plan.

> Acked-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>

Thanks! I considered that you take it thru parport tree. Do you have something
else in mind?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro
  2021-03-01 12:11     ` Andy Shevchenko
@ 2021-03-02 14:51       ` Sudip Mukherjee
  2021-03-02 15:06         ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Sudip Mukherjee @ 2021-03-02 14:51 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman; +Cc: Mark Brown, linux-spi, linux-kernel

On Mon, Mar 1, 2021 at 12:12 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Sun, Feb 28, 2021 at 11:27:10PM +0000, Sudip Mukherjee wrote:
> > On Fri, Feb 26, 2021 at 07:03:09PM +0200, Andy Shevchenko wrote:
> > > On Tue, Feb 16, 2021 at 01:07:39PM +0200, Andy Shevchenko wrote:
> > > > Introduce module_parport_driver() helper macro to reduce boilerplate
> > > > in the existing and new code.
> > >
> > > Sudip, any comments on this?
> >
> > Sorry for the delay in reply.
> > lgtm. I think there are few more drivers which can also use this new helper.
> > Will you like to do them also?
>
> Yes, that's the (slow going) plan.
>
> > Acked-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
>
> Thanks! I considered that you take it thru parport tree. Do you have something
> else in mind?

I dont have a separate parport tree (parport is not under active
development to have a separate tree). I send everything parport
related to Greg and then he adds it to his tree.
I guess in this case if Greg agrees it can go via Mark's tree as the
series will also have SPI related patches.


--
Regards
Sudip

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

* Re: [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro
  2021-03-02 14:51       ` Sudip Mukherjee
@ 2021-03-02 15:06         ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2021-03-02 15:06 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: Greg Kroah-Hartman, Mark Brown, linux-spi, linux-kernel

On Tue, Mar 02, 2021 at 02:51:45PM +0000, Sudip Mukherjee wrote:
> On Mon, Mar 1, 2021 at 12:12 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Sun, Feb 28, 2021 at 11:27:10PM +0000, Sudip Mukherjee wrote:
> > > On Fri, Feb 26, 2021 at 07:03:09PM +0200, Andy Shevchenko wrote:
> > > > On Tue, Feb 16, 2021 at 01:07:39PM +0200, Andy Shevchenko wrote:
> > > > > Introduce module_parport_driver() helper macro to reduce boilerplate
> > > > > in the existing and new code.
> > > >
> > > > Sudip, any comments on this?
> > >
> > > Sorry for the delay in reply.
> > > lgtm. I think there are few more drivers which can also use this new helper.
> > > Will you like to do them also?
> >
> > Yes, that's the (slow going) plan.
> >
> > > Acked-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> >
> > Thanks! I considered that you take it thru parport tree. Do you have something
> > else in mind?
> 
> I dont have a separate parport tree (parport is not under active
> development to have a separate tree). I send everything parport
> related to Greg and then he adds it to his tree.

MAINTAINERS doesn't show this. But good to know.

> I guess in this case if Greg agrees it can go via Mark's tree as the
> series will also have SPI related patches.

Okay, if Greg wants to handle this himself, I think I have to resend (he wasn't
in the Cc list). Otherwise Mark can also apply this if Greg is okay (but sounds
like I have to resend anyway to let him understand what's going on here).

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2021-03-02 19:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 11:07 [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro Andy Shevchenko
2021-02-16 11:07 ` [PATCH v2 2/3] spi: butterfly: Switch to use module_parport_driver() Andy Shevchenko
2021-02-16 11:07 ` [PATCH v2 3/3] spi: lm70llp: " Andy Shevchenko
2021-02-26 17:03 ` [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro Andy Shevchenko
2021-02-28 23:27   ` Sudip Mukherjee
2021-03-01 12:11     ` Andy Shevchenko
2021-03-02 14:51       ` Sudip Mukherjee
2021-03-02 15:06         ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.