Subject: [PATCH 1/2] include: linux: siox: more for declaring siox drivers

From: Enrico Weigelt <[email protected]>

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 <[email protected]>
---
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


Subject: [PATCH 2/2] drivers: gpio: pca953x: use module_siox_driver()

From: Enrico Weigelt <[email protected]>

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

Signed-off-by: Enrico Weigelt <[email protected]>
---
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 <[email protected]>");
MODULE_DESCRIPTION("SIOX gpio driver");
--
1.9.1

2019-06-18 06:52:48

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 2/2] drivers: gpio: pca953x: use module_siox_driver()

On Mon, Jun 17, 2019 at 08:21:28PM +0200, Enrico Weigelt, metux IT consult wrote:
> From: Enrico Weigelt <[email protected]>
>
> Reduce driver init boilerplate by using the new
> module_siox_driver() macro.
>
> Signed-off-by: Enrico Weigelt <[email protected]>

The subject is wrong, this isn't about pca953x.

Best regards
Uwe

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

2019-06-18 06:53:35

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 1/2] include: linux: siox: more for declaring siox drivers

On Mon, Jun 17, 2019 at 08:21:27PM +0200, Enrico Weigelt, metux IT consult wrote:
> From: Enrico Weigelt <[email protected]>
>
> Add more helper macros for trivial driver init cases, similar to the
> already existing module_platform_driver or module_i2c_driver().

Inconsistent use of () after macro names.

Other than that (and my remark for patch 2) I'm ok with this series.
Usually Greg (on Cc:) merges siox stuff, but I don't expect anything to
happen which conflicts with this series so I think it's fine if both
patches go in via the gpio tree.

> +
> +/* 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

Given there is only one siox driver in the tree, "a lot" seems bold, but
I don't mind it.

> + * calling it replaces module_init() and module_exit()
> + */
> +#define module_siox_driver(__siox_driver) \
> + module_driver(__siox_driver, siox_driver_register, \
> + siox_driver_unregister)

Best regards
Uwe

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