linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* siox: driver init boilerplate reduction v2
@ 2019-06-18 10:40 Enrico Weigelt, metux IT consult
  2019-06-18 10:40 ` [PATCH v2 1/2] include: linux: siox: more for declaring siox drivers Enrico Weigelt, metux IT consult
  2019-06-18 10:40 ` [PATCH v2 2/2] drivers: gpio: siox: use module_siox_driver() Enrico Weigelt, metux IT consult
  0 siblings, 2 replies; 6+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-18 10:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel, linus.walleij, bgolaszewski, linux-gpio

Hi folks,


this is v2 of my siox/gpio series from yesterday.

v2: fixed the typos pointed out by Uwe.


--mtx


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

* [PATCH v2 1/2] include: linux: siox: more for declaring siox drivers
  2019-06-18 10:40 siox: driver init boilerplate reduction v2 Enrico Weigelt, metux IT consult
@ 2019-06-18 10:40 ` Enrico Weigelt, metux IT consult
  2019-06-18 16:17   ` Uwe Kleine-König
  2019-06-18 10:40 ` [PATCH v2 2/2] drivers: gpio: siox: use module_siox_driver() Enrico Weigelt, metux IT consult
  1 sibling, 1 reply; 6+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-18 10:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel, linus.walleij, bgolaszewski, linux-gpio

From: Enrico Weigelt <info@metux.net>

Add more helper macros for trivial driver init cases, similar to the
already existing module_platform_driver() or module_i2c_driver().

This helps to reduce driver init boilerplate.

Signed-off-by: Enrico Weigelt <info@metux.net>
---
 include/linux/siox.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/linux/siox.h b/include/linux/siox.h
index d79624e..d53b2b2 100644
--- a/include/linux/siox.h
+++ b/include/linux/siox.h
@@ -75,3 +75,12 @@ static inline void siox_driver_unregister(struct siox_driver *sdriver)
 {
 	return driver_unregister(&sdriver->driver);
 }
+
+/* module_siox_driver() - Helper macro for drivers that don't do
+ * anything special in module init/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_siox_driver(__siox_driver) \
+	module_driver(__siox_driver, siox_driver_register, \
+			siox_driver_unregister)
-- 
1.9.1


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

* [PATCH v2 2/2] drivers: gpio: siox: use module_siox_driver()
  2019-06-18 10:40 siox: driver init boilerplate reduction v2 Enrico Weigelt, metux IT consult
  2019-06-18 10:40 ` [PATCH v2 1/2] include: linux: siox: more for declaring siox drivers Enrico Weigelt, metux IT consult
@ 2019-06-18 10:40 ` Enrico Weigelt, metux IT consult
  2019-06-18 16:13   ` Uwe Kleine-König
  1 sibling, 1 reply; 6+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-18 10:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel, linus.walleij, bgolaszewski, linux-gpio

From: Enrico Weigelt <info@metux.net>

Reduce driver init boilerplate by using the new
module_siox_driver() macro.

Signed-off-by: Enrico Weigelt <info@metux.net>
---
 drivers/gpio/gpio-siox.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
index 571b2a8..fb4e318 100644
--- a/drivers/gpio/gpio-siox.c
+++ b/drivers/gpio/gpio-siox.c
@@ -275,18 +275,7 @@ static int gpio_siox_remove(struct siox_device *sdevice)
 		.name = "gpio-siox",
 	},
 };
-
-static int __init gpio_siox_init(void)
-{
-	return siox_driver_register(&gpio_siox_driver);
-}
-module_init(gpio_siox_init);
-
-static void __exit gpio_siox_exit(void)
-{
-	siox_driver_unregister(&gpio_siox_driver);
-}
-module_exit(gpio_siox_exit);
+module_siox_driver(gpio_siox_driver);
 
 MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>");
 MODULE_DESCRIPTION("SIOX gpio driver");
-- 
1.9.1


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

* Re: [PATCH v2 2/2] drivers: gpio: siox: use module_siox_driver()
  2019-06-18 10:40 ` [PATCH v2 2/2] drivers: gpio: siox: use module_siox_driver() Enrico Weigelt, metux IT consult
@ 2019-06-18 16:13   ` Uwe Kleine-König
  0 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2019-06-18 16:13 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: linux-kernel, bgolaszewski, linus.walleij, kernel, linux-gpio

On Tue, Jun 18, 2019 at 12:40:27PM +0200, Enrico Weigelt, metux IT consult wrote:
> From: Enrico Weigelt <info@metux.net>
> 
> Reduce driver init boilerplate by using the new
> module_siox_driver() macro.
> 
> Signed-off-by: Enrico Weigelt <info@metux.net>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks,
Uwe


-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH v2 1/2] include: linux: siox: more for declaring siox drivers
  2019-06-18 10:40 ` [PATCH v2 1/2] include: linux: siox: more for declaring siox drivers Enrico Weigelt, metux IT consult
@ 2019-06-18 16:17   ` Uwe Kleine-König
  2019-06-24  5:33     ` Enrico Weigelt, metux IT consult
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2019-06-18 16:17 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: linux-kernel, bgolaszewski, linus.walleij, kernel, linux-gpio, t.scherer

Hello,

Cc: += Thorsten Scherer

On Tue, Jun 18, 2019 at 12:40:26PM +0200, Enrico Weigelt, metux IT consult wrote:
> From: Enrico Weigelt <info@metux.net>
> 
> Add more helper macros for trivial driver init cases, similar to the
> already existing module_platform_driver() or module_i2c_driver().
> 
> This helps to reduce driver init boilerplate.
> 
> Signed-off-by: Enrico Weigelt <info@metux.net>

I like the change. Just noticed that the Subject line is a bit strange
though. if "more for" is proper English then it's news to me. I'd write:

	siox: add helper macro to simplify driver registration

> ---
>  include/linux/siox.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/linux/siox.h b/include/linux/siox.h
> index d79624e..d53b2b2 100644
> --- a/include/linux/siox.h
> +++ b/include/linux/siox.h
> @@ -75,3 +75,12 @@ static inline void siox_driver_unregister(struct siox_driver *sdriver)
>  {
>  	return driver_unregister(&sdriver->driver);
>  }
> +
> +/* module_siox_driver() - Helper macro for drivers that don't do

I'd prefer /* on a separate line as documented in
Documentation/process/coding-style.rst (for non-net code).

> + * anything special in module init/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_siox_driver(__siox_driver) \
> +	module_driver(__siox_driver, siox_driver_register, \
> +			siox_driver_unregister)
> -- 

Sorry I didn't notice these two things in the first round already.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH v2 1/2] include: linux: siox: more for declaring siox drivers
  2019-06-18 16:17   ` Uwe Kleine-König
@ 2019-06-24  5:33     ` Enrico Weigelt, metux IT consult
  0 siblings, 0 replies; 6+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-24  5:33 UTC (permalink / raw)
  To: Uwe Kleine-König, Enrico Weigelt, metux IT consult
  Cc: linux-kernel, bgolaszewski, linus.walleij, kernel, linux-gpio, t.scherer

On 18.06.19 18:17, Uwe Kleine-König wrote:

Hi,

> I like the change. Just noticed that the Subject line is a bit strange> though. if "more for" is proper English then it's news to me. I'd
write:> > 	siox: add helper macro to simplify driver registration
Good point, seems I've must have been totally under-coffeined, and
some words on nasty phone interrupts :o

I'll fix that.

<snip>

>> diff --git a/include/linux/siox.h b/include/linux/siox.h>> index d79624e..d53b2b2 100644>> --- a/include/linux/siox.h>> +++
b/include/linux/siox.h>> @@ -75,3 +75,12 @@ static inline void
siox_driver_unregister(struct siox_driver *sdriver)>>  {>>  	return
driver_unregister(&sdriver->driver);>>  }>> +>> +/* module_siox_driver()
- Helper macro for drivers that don't do> > I'd prefer /* on a separate
line as documented in> Documentation/process/coding-style.rst (for
non-net code).
Done.

Do we have a tool to check for that ? checkpatch doesn't seem to care
about it.

>> + * anything special in module init/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_siox_driver(__siox_driver) \>> +	module_driver(__siox_driver,
siox_driver_register, \>> +			siox_driver_unregister)>> -- > > Sorry I
didn't notice these two things in the first round already.
No problem, that's why we have multiple rounds :)


I'll send v3 in a few minutes ...


--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

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

end of thread, other threads:[~2019-06-24  5:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 10:40 siox: driver init boilerplate reduction v2 Enrico Weigelt, metux IT consult
2019-06-18 10:40 ` [PATCH v2 1/2] include: linux: siox: more for declaring siox drivers Enrico Weigelt, metux IT consult
2019-06-18 16:17   ` Uwe Kleine-König
2019-06-24  5:33     ` Enrico Weigelt, metux IT consult
2019-06-18 10:40 ` [PATCH v2 2/2] drivers: gpio: siox: use module_siox_driver() Enrico Weigelt, metux IT consult
2019-06-18 16:13   ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).