linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] add module_sdio_driver and enable a few users
@ 2019-03-13 21:01 sean.wang
  2019-03-13 21:01 ` [PATCH v1 1/3] mmc: sdio: Add helper macro for sdio_driver boilerplate sean.wang
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: sean.wang @ 2019-03-13 21:01 UTC (permalink / raw)
  To: marcel, johan.hedberg, ulf.hansson
  Cc: linux-bluetooth, linux-mediatek, linux-mmc, linux-kernel, Sean Wang

From: Sean Wang <sean.wang@mediatek.com>

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


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

* [PATCH v1 1/3] mmc: sdio: Add helper macro for sdio_driver boilerplate
  2019-03-13 21:01 [PATCH v1 0/3] add module_sdio_driver and enable a few users sean.wang
@ 2019-03-13 21:01 ` sean.wang
  2019-03-13 21:01 ` [PATCH v1 2/3] Bluetooth: mediatek: Use module_sdio_driver helper sean.wang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: sean.wang @ 2019-03-13 21:01 UTC (permalink / raw)
  To: marcel, johan.hedberg, ulf.hansson
  Cc: linux-bluetooth, linux-mediatek, linux-mmc, linux-kernel, Sean Wang

From: Sean Wang <sean.wang@mediatek.com>

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 <ulf.hansson@linaro.org>
Suggested-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 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


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

* [PATCH v1 2/3] Bluetooth: mediatek: Use module_sdio_driver helper
  2019-03-13 21:01 [PATCH v1 0/3] add module_sdio_driver and enable a few users sean.wang
  2019-03-13 21:01 ` [PATCH v1 1/3] mmc: sdio: Add helper macro for sdio_driver boilerplate sean.wang
@ 2019-03-13 21:01 ` sean.wang
  2019-03-13 21:02 ` [PATCH v1 3/3] Bluetooth: btsdio: " sean.wang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: sean.wang @ 2019-03-13 21:01 UTC (permalink / raw)
  To: marcel, johan.hedberg, ulf.hansson
  Cc: linux-bluetooth, linux-mediatek, linux-mmc, linux-kernel, Sean Wang

From: Sean Wang <sean.wang@mediatek.com>

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 <ulf.hansson@linaro.org>
Suggested-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 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 <sean.wang@mediatek.com>");
 MODULE_DESCRIPTION("MediaTek Bluetooth SDIO driver ver " VERSION);
-- 
2.18.0


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

* [PATCH v1 3/3] Bluetooth: btsdio: Use module_sdio_driver helper
  2019-03-13 21:01 [PATCH v1 0/3] add module_sdio_driver and enable a few users sean.wang
  2019-03-13 21:01 ` [PATCH v1 1/3] mmc: sdio: Add helper macro for sdio_driver boilerplate sean.wang
  2019-03-13 21:01 ` [PATCH v1 2/3] Bluetooth: mediatek: Use module_sdio_driver helper sean.wang
@ 2019-03-13 21:02 ` sean.wang
  2019-03-18 10:26 ` [PATCH v1 0/3] add module_sdio_driver and enable a few users Ulf Hansson
  2019-03-18 17:17 ` Marcel Holtmann
  4 siblings, 0 replies; 6+ messages in thread
From: sean.wang @ 2019-03-13 21:02 UTC (permalink / raw)
  To: marcel, johan.hedberg, ulf.hansson
  Cc: linux-bluetooth, linux-mediatek, linux-mmc, linux-kernel, Sean Wang

From: Sean Wang <sean.wang@mediatek.com>

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 <marcel@holtmann.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 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 <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Generic Bluetooth SDIO driver ver " VERSION);
-- 
2.18.0


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

* Re: [PATCH v1 0/3] add module_sdio_driver and enable a few users
  2019-03-13 21:01 [PATCH v1 0/3] add module_sdio_driver and enable a few users sean.wang
                   ` (2 preceding siblings ...)
  2019-03-13 21:02 ` [PATCH v1 3/3] Bluetooth: btsdio: " sean.wang
@ 2019-03-18 10:26 ` Ulf Hansson
  2019-03-18 17:17 ` Marcel Holtmann
  4 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2019-03-18 10:26 UTC (permalink / raw)
  To: Sean Wang
  Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-mediatek,
	linux-mmc, Linux Kernel Mailing List

On Wed, 13 Mar 2019 at 22:02, <sean.wang@mediatek.com> wrote:
>
> From: Sean Wang <sean.wang@mediatek.com>
>
> 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 <ulf.hansson@linaro.org>

Kind regards
Uffe

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

* Re: [PATCH v1 0/3] add module_sdio_driver and enable a few users
  2019-03-13 21:01 [PATCH v1 0/3] add module_sdio_driver and enable a few users sean.wang
                   ` (3 preceding siblings ...)
  2019-03-18 10:26 ` [PATCH v1 0/3] add module_sdio_driver and enable a few users Ulf Hansson
@ 2019-03-18 17:17 ` Marcel Holtmann
  4 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2019-03-18 17:17 UTC (permalink / raw)
  To: sean.wang
  Cc: Johan Hedberg, ulf.hansson, linux-bluetooth, linux-mediatek,
	linux-mmc, linux-kernel

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


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

end of thread, other threads:[~2019-03-18 17:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 21:01 [PATCH v1 0/3] add module_sdio_driver and enable a few users sean.wang
2019-03-13 21:01 ` [PATCH v1 1/3] mmc: sdio: Add helper macro for sdio_driver boilerplate sean.wang
2019-03-13 21:01 ` [PATCH v1 2/3] Bluetooth: mediatek: Use module_sdio_driver helper sean.wang
2019-03-13 21:02 ` [PATCH v1 3/3] Bluetooth: btsdio: " sean.wang
2019-03-18 10:26 ` [PATCH v1 0/3] add module_sdio_driver and enable a few users Ulf Hansson
2019-03-18 17:17 ` Marcel Holtmann

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