From: Sean Wang <[email protected]>
Add module_sdio_driver exactly like the function module_usb_drivear offers to
and enable a few users to eliminate a few lines of boilerplate code per SDIO
driver.
Sean Wang (3):
mmc: sdio: Add helper macro for sdio_driver boilerplate
Bluetooth: mediatek: Use module_sdio_driver helper
Bluetooth: btsdio: Use module_sdio_driver helper
drivers/bluetooth/btmtksdio.c | 15 +--------------
drivers/bluetooth/btsdio.c | 15 +--------------
include/linux/mmc/sdio_func.h | 12 ++++++++++++
3 files changed, 14 insertions(+), 28 deletions(-)
--
2.18.0
From: Sean Wang <[email protected]>
Macro module_sdio_driver is used for drivers whose init and exit paths
only register and unregister to SDIO API. So remove boilerplate code to
make code simpler by using module_sdio_driver.
Cc: Marcel Holtmann <[email protected]>
Cc: Ulf Hansson <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/bluetooth/btsdio.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c
index 282d1af1d3ba..4cfa9abe03c8 100644
--- a/drivers/bluetooth/btsdio.c
+++ b/drivers/bluetooth/btsdio.c
@@ -376,20 +376,7 @@ static struct sdio_driver btsdio_driver = {
.id_table = btsdio_table,
};
-static int __init btsdio_init(void)
-{
- BT_INFO("Generic Bluetooth SDIO driver ver %s", VERSION);
-
- return sdio_register_driver(&btsdio_driver);
-}
-
-static void __exit btsdio_exit(void)
-{
- sdio_unregister_driver(&btsdio_driver);
-}
-
-module_init(btsdio_init);
-module_exit(btsdio_exit);
+module_sdio_driver(btsdio_driver);
MODULE_AUTHOR("Marcel Holtmann <[email protected]>");
MODULE_DESCRIPTION("Generic Bluetooth SDIO driver ver " VERSION);
--
2.18.0
From: Sean Wang <[email protected]>
This patch introduces the module_sdio_driver macro which is a convenience
macro for SDIO driver modules similar to module_usb_driver. It is intended
to be used by drivers which init/exit section does nothing but register/
unregister the SDIO driver. By using this macro it is possible to eliminate
a few lines of boilerplate code per SDIO driver.
Cc: Ulf Hansson <[email protected]>
Suggested-by: Marcel Holtmann <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
include/linux/mmc/sdio_func.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
index 97ca105347a6..5685805533b5 100644
--- a/include/linux/mmc/sdio_func.h
+++ b/include/linux/mmc/sdio_func.h
@@ -111,6 +111,18 @@ struct sdio_driver {
extern int sdio_register_driver(struct sdio_driver *);
extern void sdio_unregister_driver(struct sdio_driver *);
+/**
+ * module_sdio_driver() - Helper macro for registering a SDIO driver
+ * @__sdio_driver: sdio_driver struct
+ *
+ * Helper macro for SDIO drivers which do not 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_sdio_driver(__sdio_driver) \
+ module_driver(__sdio_driver, sdio_register_driver, \
+ sdio_unregister_driver)
+
/*
* SDIO I/O operations
*/
--
2.18.0
From: Sean Wang <[email protected]>
Macro module_sdio_driver is used for drivers whose init and exit paths
only register and unregister to SDIO API. So remove boilerplate code to
make code simpler by using module_sdio_driver.
Cc: Ulf Hansson <[email protected]>
Suggested-by: Marcel Holtmann <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/bluetooth/btmtksdio.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index 23cf63888bac..ca7f28f439da 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -956,20 +956,7 @@ static struct sdio_driver btmtksdio_driver = {
.id_table = btmtksdio_table,
};
-static int __init btmtksdio_init(void)
-{
- BT_INFO("MediaTek Bluetooth SDIO driver ver %s", VERSION);
-
- return sdio_register_driver(&btmtksdio_driver);
-}
-
-static void __exit btmtksdio_exit(void)
-{
- sdio_unregister_driver(&btmtksdio_driver);
-}
-
-module_init(btmtksdio_init);
-module_exit(btmtksdio_exit);
+module_sdio_driver(btmtksdio_driver);
MODULE_AUTHOR("Sean Wang <[email protected]>");
MODULE_DESCRIPTION("MediaTek Bluetooth SDIO driver ver " VERSION);
--
2.18.0
On Wed, 13 Mar 2019 at 22:02, <[email protected]> wrote:
>
> From: Sean Wang <[email protected]>
>
> Add module_sdio_driver exactly like the function module_usb_drivear offers to
> and enable a few users to eliminate a few lines of boilerplate code per SDIO
> driver.
>
> Sean Wang (3):
> mmc: sdio: Add helper macro for sdio_driver boilerplate
> Bluetooth: mediatek: Use module_sdio_driver helper
> Bluetooth: btsdio: Use module_sdio_driver helper
>
> drivers/bluetooth/btmtksdio.c | 15 +--------------
> drivers/bluetooth/btsdio.c | 15 +--------------
> include/linux/mmc/sdio_func.h | 12 ++++++++++++
> 3 files changed, 14 insertions(+), 28 deletions(-)
>
> --
> 2.18.0
>
For series:
Acked-by: Ulf Hansson <[email protected]>
Kind regards
Uffe
Hi Sean,
> Add module_sdio_driver exactly like the function module_usb_drivear offers to
> and enable a few users to eliminate a few lines of boilerplate code per SDIO
> driver.
>
> Sean Wang (3):
> mmc: sdio: Add helper macro for sdio_driver boilerplate
> Bluetooth: mediatek: Use module_sdio_driver helper
> Bluetooth: btsdio: Use module_sdio_driver helper
>
> drivers/bluetooth/btmtksdio.c | 15 +--------------
> drivers/bluetooth/btsdio.c | 15 +--------------
> include/linux/mmc/sdio_func.h | 12 ++++++++++++
> 3 files changed, 14 insertions(+), 28 deletions(-)
all 3 patches have been applied to bluetooth-next tree.
Regards
Marcel