linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Add and use new macro module_platform_driver_probe()
@ 2013-01-09 11:15 Fabio Porcedda
  2013-01-09 11:15 ` [PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate Fabio Porcedda
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Fabio Porcedda @ 2013-01-09 11:15 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-watchdog, linux-usb

For simple modules that contain a single platform_driver without any
additional setup code then ends up being a block of duplicated
boilerplate.  This patch adds a new macro,
module_platform_driver_probe(), which replaces the
module_init()/module_exit() registrations with template functions.
    
This macro use the same idea of module_platform_driver().
    
This macro is useful to stop the misuse of module_platform_driver() for
removing the platform_driver_probe() boilerplate.

Convert drivers/usb/* and drivers/watchdog/* to use
module_platform_driver_probe().

Best regards

Fabio Porcedda (3):
  driver core: add helper macro for platform_driver_probe() boilerplate
  watchdog: convert drivers/watchdog/* to use
    module_platform_driver_probe
  usb: converto drivers/usb/* to use module_platform_driver_probe()

 drivers/usb/gadget/at91_udc.c       | 12 +-----------
 drivers/usb/gadget/atmel_usba_udc.c | 12 +-----------
 drivers/usb/gadget/fusb300_udc.c    | 13 +------------
 drivers/usb/gadget/imx_udc.c        | 12 +-----------
 drivers/usb/gadget/lpc32xx_udc.c    | 12 +-----------
 drivers/usb/gadget/m66592-udc.c     | 12 +-----------
 drivers/usb/gadget/pxa25x_udc.c     | 15 +++------------
 drivers/usb/gadget/r8a66597-udc.c   | 15 ++-------------
 drivers/usb/otg/gpio_vbus.c         | 12 +-----------
 drivers/usb/otg/msm_otg.c           | 13 +------------
 drivers/watchdog/at32ap700x_wdt.c   | 12 +-----------
 drivers/watchdog/at91sam9_wdt.c     | 13 +------------
 drivers/watchdog/coh901327_wdt.c    | 12 +-----------
 drivers/watchdog/imx2_wdt.c         | 12 +-----------
 drivers/watchdog/txx9wdt.c          | 13 +------------
 include/linux/platform_device.h     | 18 ++++++++++++++++++
 16 files changed, 36 insertions(+), 172 deletions(-)

-- 
1.8.0.3


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

* [PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate
  2013-01-09 11:15 [PATCH 0/3] Add and use new macro module_platform_driver_probe() Fabio Porcedda
@ 2013-01-09 11:15 ` Fabio Porcedda
  2013-01-10 12:50   ` Fabio Porcedda
  2013-01-09 11:15 ` [PATCH 2/3] watchdog: convert drivers/watchdog/* to use module_platform_driver_probe Fabio Porcedda
  2013-01-09 11:15 ` [PATCH 3/3] usb: converto drivers/usb/* to use module_platform_driver_probe() Fabio Porcedda
  2 siblings, 1 reply; 5+ messages in thread
From: Fabio Porcedda @ 2013-01-09 11:15 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-watchdog, linux-usb
  Cc: Greg Kroah-Hartman

For simple modules that contain a single platform_driver without any
additional setup code then ends up being a block of duplicated
boilerplate.  This patch adds a new macro,
module_platform_driver_probe(), which replaces the
module_init()/module_exit() registrations with template functions.

This macro use the same idea of module_platform_driver().

This macro is useful to stop the misuse of module_platform_driver() for
removing the platform_driver_probe() boilerplate.

Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
 include/linux/platform_device.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index a9ded9a..c082c71 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -204,6 +204,24 @@ static inline void platform_set_drvdata(struct platform_device *pdev, void *data
 	module_driver(__platform_driver, platform_driver_register, \
 			platform_driver_unregister)
 
+/* module_platform_driver_probe() - 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_platform_driver_probe(__platform_driver, __platform_probe) \
+static int __init __platform_driver##_init(void) \
+{ \
+	return platform_driver_probe(&(__platform_driver), \
+				     __platform_probe);    \
+} \
+module_init(__platform_driver##_init); \
+static void __exit __platform_driver##_exit(void) \
+{ \
+	platform_driver_unregister(&(__platform_driver)); \
+} \
+module_exit(__platform_driver##_exit);
+
 extern struct platform_device *platform_create_bundle(struct platform_driver *driver,
 					int (*probe)(struct platform_device *),
 					struct resource *res, unsigned int n_res,
-- 
1.8.0.3


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

* [PATCH 2/3] watchdog: convert drivers/watchdog/* to use module_platform_driver_probe
  2013-01-09 11:15 [PATCH 0/3] Add and use new macro module_platform_driver_probe() Fabio Porcedda
  2013-01-09 11:15 ` [PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate Fabio Porcedda
@ 2013-01-09 11:15 ` Fabio Porcedda
  2013-01-09 11:15 ` [PATCH 3/3] usb: converto drivers/usb/* to use module_platform_driver_probe() Fabio Porcedda
  2 siblings, 0 replies; 5+ messages in thread
From: Fabio Porcedda @ 2013-01-09 11:15 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-watchdog, linux-usb
  Cc: Wim Van Sebroeck, Linus Walleij

This makes the code a bit smaller by getting rid of
some boilerplate code.

Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
Cc: linux-watchdog@vger.kernel.org
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/watchdog/at32ap700x_wdt.c | 12 +-----------
 drivers/watchdog/at91sam9_wdt.c   | 13 +------------
 drivers/watchdog/coh901327_wdt.c  | 12 +-----------
 drivers/watchdog/imx2_wdt.c       | 12 +-----------
 drivers/watchdog/txx9wdt.c        | 13 +------------
 5 files changed, 5 insertions(+), 57 deletions(-)

diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c
index 2896430..7a715e3 100644
--- a/drivers/watchdog/at32ap700x_wdt.c
+++ b/drivers/watchdog/at32ap700x_wdt.c
@@ -436,17 +436,7 @@ static struct platform_driver at32_wdt_driver = {
 	.shutdown	= at32_wdt_shutdown,
 };
 
-static int __init at32_wdt_init(void)
-{
-	return platform_driver_probe(&at32_wdt_driver, at32_wdt_probe);
-}
-module_init(at32_wdt_init);
-
-static void __exit at32_wdt_exit(void)
-{
-	platform_driver_unregister(&at32_wdt_driver);
-}
-module_exit(at32_wdt_exit);
+module_platform_driver_probe(at32_wdt_driver, at32_wdt_probe);
 
 MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>");
 MODULE_DESCRIPTION("Watchdog driver for Atmel AT32AP700X");
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index d864dc4..60bc700 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -331,18 +331,7 @@ static struct platform_driver at91wdt_driver = {
 	},
 };
 
-static int __init at91sam_wdt_init(void)
-{
-	return platform_driver_probe(&at91wdt_driver, at91wdt_probe);
-}
-
-static void __exit at91sam_wdt_exit(void)
-{
-	platform_driver_unregister(&at91wdt_driver);
-}
-
-module_init(at91sam_wdt_init);
-module_exit(at91sam_wdt_exit);
+module_platform_driver_probe(at91wdt_driver, at91wdt_probe);
 
 MODULE_AUTHOR("Renaud CERRATO <r.cerrato@til-technologies.fr>");
 MODULE_DESCRIPTION("Watchdog driver for Atmel AT91SAM9x processors");
diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index cb5da5c..b9b8a8b 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -451,17 +451,7 @@ static struct platform_driver coh901327_driver = {
 	.resume		= coh901327_resume,
 };
 
-static int __init coh901327_init(void)
-{
-	return platform_driver_probe(&coh901327_driver, coh901327_probe);
-}
-module_init(coh901327_init);
-
-static void __exit coh901327_exit(void)
-{
-	platform_driver_unregister(&coh901327_driver);
-}
-module_exit(coh901327_exit);
+module_platform_driver_probe(coh901327_driver, coh901327_probe);
 
 MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
 MODULE_DESCRIPTION("COH 901 327 Watchdog");
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index 9a45d029..bc17dec 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -342,17 +342,7 @@ static struct platform_driver imx2_wdt_driver = {
 	},
 };
 
-static int __init imx2_wdt_init(void)
-{
-	return platform_driver_probe(&imx2_wdt_driver, imx2_wdt_probe);
-}
-module_init(imx2_wdt_init);
-
-static void __exit imx2_wdt_exit(void)
-{
-	platform_driver_unregister(&imx2_wdt_driver);
-}
-module_exit(imx2_wdt_exit);
+module_platform_driver_probe(imx2_wdt_driver, imx2_wdt_probe);
 
 MODULE_AUTHOR("Wolfram Sang");
 MODULE_DESCRIPTION("Watchdog driver for IMX2 and later");
diff --git a/drivers/watchdog/txx9wdt.c b/drivers/watchdog/txx9wdt.c
index 98e1637..b04c92b 100644
--- a/drivers/watchdog/txx9wdt.c
+++ b/drivers/watchdog/txx9wdt.c
@@ -172,18 +172,7 @@ static struct platform_driver txx9wdt_driver = {
 	},
 };
 
-static int __init watchdog_init(void)
-{
-	return platform_driver_probe(&txx9wdt_driver, txx9wdt_probe);
-}
-
-static void __exit watchdog_exit(void)
-{
-	platform_driver_unregister(&txx9wdt_driver);
-}
-
-module_init(watchdog_init);
-module_exit(watchdog_exit);
+module_platform_driver_probe(txx9wdt_driver, txx9wdt_probe);
 
 MODULE_DESCRIPTION("TXx9 Watchdog Driver");
 MODULE_LICENSE("GPL");
-- 
1.8.0.3

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

* [PATCH 3/3] usb: converto drivers/usb/* to use module_platform_driver_probe()
  2013-01-09 11:15 [PATCH 0/3] Add and use new macro module_platform_driver_probe() Fabio Porcedda
  2013-01-09 11:15 ` [PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate Fabio Porcedda
  2013-01-09 11:15 ` [PATCH 2/3] watchdog: convert drivers/watchdog/* to use module_platform_driver_probe Fabio Porcedda
@ 2013-01-09 11:15 ` Fabio Porcedda
  2 siblings, 0 replies; 5+ messages in thread
From: Fabio Porcedda @ 2013-01-09 11:15 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-watchdog, linux-usb
  Cc: Greg Kroah-Hartman, Felipe Balbi, Nicolas Ferre, Eric Miao,
	Russell King, Haojian Zhuang

This patch converts the drivers in drivers/usb/* to use the
module_platform_driver_probe() macro which makes the code smaller and
a bit simpler.

Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
Cc: linux-usb@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
---
 drivers/usb/gadget/at91_udc.c       | 12 +-----------
 drivers/usb/gadget/atmel_usba_udc.c | 12 +-----------
 drivers/usb/gadget/fusb300_udc.c    | 13 +------------
 drivers/usb/gadget/imx_udc.c        | 12 +-----------
 drivers/usb/gadget/lpc32xx_udc.c    | 12 +-----------
 drivers/usb/gadget/m66592-udc.c     | 12 +-----------
 drivers/usb/gadget/pxa25x_udc.c     | 15 +++------------
 drivers/usb/gadget/r8a66597-udc.c   | 15 ++-------------
 drivers/usb/otg/gpio_vbus.c         | 12 +-----------
 drivers/usb/otg/msm_otg.c           | 13 +------------
 10 files changed, 13 insertions(+), 115 deletions(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index f4a21f6..0143ffa 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1982,17 +1982,7 @@ static struct platform_driver at91_udc_driver = {
 	},
 };
 
-static int __init udc_init_module(void)
-{
-	return platform_driver_probe(&at91_udc_driver, at91udc_probe);
-}
-module_init(udc_init_module);
-
-static void __exit udc_exit_module(void)
-{
-	platform_driver_unregister(&at91_udc_driver);
-}
-module_exit(udc_exit_module);
+module_platform_driver_probe(at91_udc_driver, at91udc_probe);
 
 MODULE_DESCRIPTION("AT91 udc driver");
 MODULE_AUTHOR("Thomas Rathbone, David Brownell");
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index a7aed84..bc19496 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -2066,17 +2066,7 @@ static struct platform_driver udc_driver = {
 	},
 };
 
-static int __init udc_init(void)
-{
-	return platform_driver_probe(&udc_driver, usba_udc_probe);
-}
-module_init(udc_init);
-
-static void __exit udc_exit(void)
-{
-	platform_driver_unregister(&udc_driver);
-}
-module_exit(udc_exit);
+module_platform_driver_probe(udc_driver, usba_udc_probe);
 
 MODULE_DESCRIPTION("Atmel USBA UDC driver");
 MODULE_AUTHOR("Haavard Skinnemoen (Atmel)");
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c
index 72cd5e6..fc7cb09 100644
--- a/drivers/usb/gadget/fusb300_udc.c
+++ b/drivers/usb/gadget/fusb300_udc.c
@@ -1547,15 +1547,4 @@ static struct platform_driver fusb300_driver = {
 	},
 };
 
-static int __init fusb300_udc_init(void)
-{
-	return platform_driver_probe(&fusb300_driver, fusb300_probe);
-}
-
-module_init(fusb300_udc_init);
-
-static void __exit fusb300_udc_cleanup(void)
-{
-	platform_driver_unregister(&fusb300_driver);
-}
-module_exit(fusb300_udc_cleanup);
+module_platform_driver_probe(fusb300_driver, fusb300_probe);
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c
index a0eb857..8efd755 100644
--- a/drivers/usb/gadget/imx_udc.c
+++ b/drivers/usb/gadget/imx_udc.c
@@ -1556,17 +1556,7 @@ static struct platform_driver udc_driver = {
 	.resume		= imx_udc_resume,
 };
 
-static int __init udc_init(void)
-{
-	return platform_driver_probe(&udc_driver, imx_udc_probe);
-}
-module_init(udc_init);
-
-static void __exit udc_exit(void)
-{
-	platform_driver_unregister(&udc_driver);
-}
-module_exit(udc_exit);
+module_platform_driver_probe(udc_driver, imx_udc_probe);
 
 MODULE_DESCRIPTION("IMX USB Device Controller driver");
 MODULE_AUTHOR("Darius Augulis <augulis.darius@gmail.com>");
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c
index dd1c9b1..aa04089 100644
--- a/drivers/usb/gadget/lpc32xx_udc.c
+++ b/drivers/usb/gadget/lpc32xx_udc.c
@@ -3458,17 +3458,7 @@ static struct platform_driver lpc32xx_udc_driver = {
 	},
 };
 
-static int __init udc_init_module(void)
-{
-	return platform_driver_probe(&lpc32xx_udc_driver, lpc32xx_udc_probe);
-}
-module_init(udc_init_module);
-
-static void __exit udc_exit_module(void)
-{
-	platform_driver_unregister(&lpc32xx_udc_driver);
-}
-module_exit(udc_exit_module);
+module_platform_driver_probe(lpc32xx_udc_driver, lpc32xx_udc_probe);
 
 MODULE_DESCRIPTION("LPC32XX udc driver");
 MODULE_AUTHOR("Kevin Wells <kevin.wells@nxp.com>");
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index b6401f1..dfce0cf 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -1753,14 +1753,4 @@ static struct platform_driver m66592_driver = {
 	},
 };
 
-static int __init m66592_udc_init(void)
-{
-	return platform_driver_probe(&m66592_driver, m66592_probe);
-}
-module_init(m66592_udc_init);
-
-static void __exit m66592_udc_cleanup(void)
-{
-	platform_driver_unregister(&m66592_driver);
-}
-module_exit(m66592_udc_cleanup);
+module_platform_driver_probe(m66592_driver, m66592_probe);
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index d4ca9f1..d52e869 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -2100,6 +2100,8 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
 	int retval, irq;
 	u32 chiprev;
 
+	pr_info("%s: version %s\n", driver_name, DRIVER_VERSION);
+
 	/* insist on Intel/ARM/XScale */
 	asm("mrc%? p15, 0, %0, c0, c0" : "=r" (chiprev));
 	if ((chiprev & CP15R0_VENDOR_MASK) != CP15R0_XSCALE_VALUE) {
@@ -2346,18 +2348,7 @@ static struct platform_driver udc_driver = {
 	},
 };
 
-static int __init udc_init(void)
-{
-	pr_info("%s: version %s\n", driver_name, DRIVER_VERSION);
-	return platform_driver_probe(&udc_driver, pxa25x_udc_probe);
-}
-module_init(udc_init);
-
-static void __exit udc_exit(void)
-{
-	platform_driver_unregister(&udc_driver);
-}
-module_exit(udc_exit);
+module_platform_driver_probe(udc_driver, pxa25x_udc_probe);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR("Frank Becker, Robert Schwebel, David Brownell");
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index 5a80751..9a9fadd 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -2031,21 +2031,10 @@ static struct platform_driver r8a66597_driver = {
 		.name =	(char *) udc_name,
 	},
 };
-MODULE_ALIAS("platform:r8a66597_udc");
-
-static int __init r8a66597_udc_init(void)
-{
-	return platform_driver_probe(&r8a66597_driver, r8a66597_probe);
-}
-module_init(r8a66597_udc_init);
 
-static void __exit r8a66597_udc_cleanup(void)
-{
-	platform_driver_unregister(&r8a66597_driver);
-}
-module_exit(r8a66597_udc_cleanup);
+module_platform_driver_probe(r8a66597_driver, r8a66597_probe);
 
 MODULE_DESCRIPTION("R8A66597 USB gadget driver");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Yoshihiro Shimoda");
-
+MODULE_ALIAS("platform:r8a66597_udc");
diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c
index a67ffe2..a7d4ac5 100644
--- a/drivers/usb/otg/gpio_vbus.c
+++ b/drivers/usb/otg/gpio_vbus.c
@@ -409,17 +409,7 @@ static struct platform_driver gpio_vbus_driver = {
 	.remove  = __exit_p(gpio_vbus_remove),
 };
 
-static int __init gpio_vbus_init(void)
-{
-	return platform_driver_probe(&gpio_vbus_driver, gpio_vbus_probe);
-}
-module_init(gpio_vbus_init);
-
-static void __exit gpio_vbus_exit(void)
-{
-	platform_driver_unregister(&gpio_vbus_driver);
-}
-module_exit(gpio_vbus_exit);
+module_platform_driver_probe(gpio_vbus_driver, gpio_vbus_probe);
 
 MODULE_DESCRIPTION("simple GPIO controlled OTG transceiver driver");
 MODULE_AUTHOR("Philipp Zabel");
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c
index 3b9f0d9..749fbf4 100644
--- a/drivers/usb/otg/msm_otg.c
+++ b/drivers/usb/otg/msm_otg.c
@@ -1756,18 +1756,7 @@ static struct platform_driver msm_otg_driver = {
 	},
 };
 
-static int __init msm_otg_init(void)
-{
-	return platform_driver_probe(&msm_otg_driver, msm_otg_probe);
-}
-
-static void __exit msm_otg_exit(void)
-{
-	platform_driver_unregister(&msm_otg_driver);
-}
-
-module_init(msm_otg_init);
-module_exit(msm_otg_exit);
+module_platform_driver_probe(msm_otg_driver, msm_otg_probe);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("MSM USB transceiver driver");
-- 
1.8.0.3


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

* Re: [PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate
  2013-01-09 11:15 ` [PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate Fabio Porcedda
@ 2013-01-10 12:50   ` Fabio Porcedda
  0 siblings, 0 replies; 5+ messages in thread
From: Fabio Porcedda @ 2013-01-10 12:50 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-watchdog, linux-usb,
	Greg Kroah-Hartman

Hi Greg,
I'm sorry, In the previous email I used your wrong email address,
in this email I've used your correct email address.

Best regards
Fabio Porcedda

On Wed, Jan 9, 2013 at 12:15 PM, Fabio Porcedda
<fabio.porcedda@gmail.com> wrote:
> For simple modules that contain a single platform_driver without any
> additional setup code then ends up being a block of duplicated
> boilerplate.  This patch adds a new macro,
> module_platform_driver_probe(), which replaces the
> module_init()/module_exit() registrations with template functions.
>
> This macro use the same idea of module_platform_driver().
>
> This macro is useful to stop the misuse of module_platform_driver() for
> removing the platform_driver_probe() boilerplate.
>
> Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>

Cc: Greg Kroah-Hartman (linuxfoundation.org)

> ---
>  include/linux/platform_device.h | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index a9ded9a..c082c71 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -204,6 +204,24 @@ static inline void platform_set_drvdata(struct platform_device *pdev, void *data
>         module_driver(__platform_driver, platform_driver_register, \
>                         platform_driver_unregister)
>
> +/* module_platform_driver_probe() - 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_platform_driver_probe(__platform_driver, __platform_probe) \
> +static int __init __platform_driver##_init(void) \
> +{ \
> +       return platform_driver_probe(&(__platform_driver), \
> +                                    __platform_probe);    \
> +} \
> +module_init(__platform_driver##_init); \
> +static void __exit __platform_driver##_exit(void) \
> +{ \
> +       platform_driver_unregister(&(__platform_driver)); \
> +} \
> +module_exit(__platform_driver##_exit);
> +
>  extern struct platform_device *platform_create_bundle(struct platform_driver *driver,
>                                         int (*probe)(struct platform_device *),
>                                         struct resource *res, unsigned int n_res,
> --
> 1.8.0.3
>

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

end of thread, other threads:[~2013-01-10 12:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-09 11:15 [PATCH 0/3] Add and use new macro module_platform_driver_probe() Fabio Porcedda
2013-01-09 11:15 ` [PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate Fabio Porcedda
2013-01-10 12:50   ` Fabio Porcedda
2013-01-09 11:15 ` [PATCH 2/3] watchdog: convert drivers/watchdog/* to use module_platform_driver_probe Fabio Porcedda
2013-01-09 11:15 ` [PATCH 3/3] usb: converto drivers/usb/* to use module_platform_driver_probe() Fabio Porcedda

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