linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* siox: driver init boilerplate reduction v3
@ 2019-06-24  5:40 Enrico Weigelt, metux IT consult
  2019-06-24  5:40 ` [PATCH 1/2] siox: add helper macro to simplify driver registration Enrico Weigelt, metux IT consult
  2019-06-24  5:40 ` [PATCH 2/2] drivers: gpio: siox: use module_siox_driver() Enrico Weigelt, metux IT consult
  0 siblings, 2 replies; 7+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-24  5:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel, linus.walleij, bgolaszewski, linux-gpio, t.scherer

Hi folks,


this is v3 of my siox/gpio series from last week.

v3: fixed subject and formatting pointed out by Uwe,
    second patch (gpio-siox.c) already acked by him

v2: fixed the typos pointed out by Uwe.


--mtx

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

* [PATCH 1/2] siox: add helper macro to simplify driver registration
  2019-06-24  5:40 siox: driver init boilerplate reduction v3 Enrico Weigelt, metux IT consult
@ 2019-06-24  5:40 ` Enrico Weigelt, metux IT consult
  2019-06-24  6:04   ` Uwe Kleine-König
  2019-06-25  9:26   ` Linus Walleij
  2019-06-24  5:40 ` [PATCH 2/2] drivers: gpio: siox: use module_siox_driver() Enrico Weigelt, metux IT consult
  1 sibling, 2 replies; 7+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-24  5:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel, linus.walleij, bgolaszewski, linux-gpio, t.scherer

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 | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/siox.h b/include/linux/siox.h
index a860cb8..da7225b 100644
--- a/include/linux/siox.h
+++ b/include/linux/siox.h
@@ -72,3 +72,13 @@ 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] 7+ messages in thread

* [PATCH 2/2] drivers: gpio: siox: use module_siox_driver()
  2019-06-24  5:40 siox: driver init boilerplate reduction v3 Enrico Weigelt, metux IT consult
  2019-06-24  5:40 ` [PATCH 1/2] siox: add helper macro to simplify driver registration Enrico Weigelt, metux IT consult
@ 2019-06-24  5:40 ` Enrico Weigelt, metux IT consult
  2019-06-25  9:29   ` Linus Walleij
  1 sibling, 1 reply; 7+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-24  5:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel, linus.walleij, bgolaszewski, linux-gpio, t.scherer

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] 7+ messages in thread

* Re: [PATCH 1/2] siox: add helper macro to simplify driver registration
  2019-06-24  5:40 ` [PATCH 1/2] siox: add helper macro to simplify driver registration Enrico Weigelt, metux IT consult
@ 2019-06-24  6:04   ` Uwe Kleine-König
  2019-06-25  9:26   ` Linus Walleij
  1 sibling, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2019-06-24  6:04 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult, linus.walleij
  Cc: linux-kernel, bgolaszewski, t.scherer, kernel, linux-gpio

On Mon, Jun 24, 2019 at 07:40:33AM +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>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

@Linus: Feel free to apply both patches via your gpio tree.

Best regards
Uwe

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

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

* Re: [PATCH 1/2] siox: add helper macro to simplify driver registration
  2019-06-24  5:40 ` [PATCH 1/2] siox: add helper macro to simplify driver registration Enrico Weigelt, metux IT consult
  2019-06-24  6:04   ` Uwe Kleine-König
@ 2019-06-25  9:26   ` Linus Walleij
  2019-06-26 17:31     ` Enrico Weigelt, metux IT consult
  1 sibling, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2019-06-25  9:26 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: linux-kernel, Sascha Hauer, Bartosz Golaszewski,
	open list:GPIO SUBSYSTEM, t.scherer

On Mon, Jun 24, 2019 at 7:40 AM Enrico Weigelt, metux IT consult
<info@metux.net> 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>

Patch applied with Uwe's ACK.

Yours,
Linus Walleij

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

* Re: [PATCH 2/2] drivers: gpio: siox: use module_siox_driver()
  2019-06-24  5:40 ` [PATCH 2/2] drivers: gpio: siox: use module_siox_driver() Enrico Weigelt, metux IT consult
@ 2019-06-25  9:29   ` Linus Walleij
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2019-06-25  9:29 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: linux-kernel, Sascha Hauer, Bartosz Golaszewski,
	open list:GPIO SUBSYSTEM, t.scherer

On Mon, Jun 24, 2019 at 7:40 AM Enrico Weigelt, metux IT consult
<info@metux.net> 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>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 1/2] siox: add helper macro to simplify driver registration
  2019-06-25  9:26   ` Linus Walleij
@ 2019-06-26 17:31     ` Enrico Weigelt, metux IT consult
  0 siblings, 0 replies; 7+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-26 17:31 UTC (permalink / raw)
  To: Linus Walleij, Enrico Weigelt, metux IT consult
  Cc: linux-kernel, Sascha Hauer, Bartosz Golaszewski,
	open list:GPIO SUBSYSTEM, t.scherer

On 25.06.19 11:26, Linus Walleij wrote:
> On Mon, Jun 24, 2019 at 7:40 AM Enrico Weigelt, metux IT consult
> <info@metux.net> 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>
> 
> Patch applied with Uwe's ACK.

thanks to both of you :)

--mtx

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

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

end of thread, other threads:[~2019-06-26 17:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24  5:40 siox: driver init boilerplate reduction v3 Enrico Weigelt, metux IT consult
2019-06-24  5:40 ` [PATCH 1/2] siox: add helper macro to simplify driver registration Enrico Weigelt, metux IT consult
2019-06-24  6:04   ` Uwe Kleine-König
2019-06-25  9:26   ` Linus Walleij
2019-06-26 17:31     ` Enrico Weigelt, metux IT consult
2019-06-24  5:40 ` [PATCH 2/2] drivers: gpio: siox: use module_siox_driver() Enrico Weigelt, metux IT consult
2019-06-25  9:29   ` Linus Walleij

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).