Skip to contentSkip to conversation

add module_sdio_driver and enable a few users

PATCH In review [email protected] 3 participants 6 messages Mar 13, 2019 – Mar 18, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover add module_sdio_driver and enable a few users

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(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/3 mmc: sdio: Add helper macro for sdio_driver boilerplate

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.

---
 include/linux/mmc/sdio_func.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/linux/mmc/sdio_func.h +12 -0
index 97ca105347a6..5685805533b5 100644
@@ -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
  */
Signature · 1 line
2.18.0
#2 lore raw

PATCH 2/3 Bluetooth: mediatek: Use module_sdio_driver helper

In reply to [email protected]

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.

---
 drivers/bluetooth/btmtksdio.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/bluetooth/btmtksdio.c +1 -14
index 23cf63888bac..ca7f28f439da 100644
@@ -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);
Signature · 1 line
2.18.0
#3 lore raw

PATCH 3/3 Bluetooth: btsdio: Use module_sdio_driver helper

In reply to [email protected]

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]>
---
 drivers/bluetooth/btsdio.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/bluetooth/btsdio.c +1 -14
index 282d1af1d3ba..4cfa9abe03c8 100644
@@ -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);
Signature · 1 line
2.18.0
Acked-by on the v1 series
#4 lore raw
In reply to [email protected]
Quoted 12 lines · 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

Quoted 8 lines
 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:

Kind regards
Uffe

maintainer
#5 lore raw
In reply to [email protected]

Hi Sean,

Quoted 9 lines

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

Quoted 4 lines
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