summaryrefslogtreecommitdiffstats
path: root/include/linux/platform_device.h
diff options
context:
space:
mode:
authorFabio Porcedda <fabio.porcedda@gmail.com>2013-01-09 12:15:26 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-17 17:39:33 -0800
commitbab734fcdf2c690371e6749ce484b17653b3cb0e (patch)
tree752e2e5191d657a7cebb25cbeb7b313792ced093 /include/linux/platform_device.h
parent53a9c87e7e02abf3575be98c9fb2018fa30a61b9 (diff)
downloadop-kernel-dev-bab734fcdf2c690371e6749ce484b17653b3cb0e.zip
op-kernel-dev-bab734fcdf2c690371e6749ce484b17653b3cb0e.tar.gz
driver core: add helper macro for platform_driver_probe() boilerplate
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/platform_device.h')
-rw-r--r--include/linux/platform_device.h18
1 files changed, 18 insertions, 0 deletions
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,
OpenPOWER on IntegriCloud