aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/platform_device.h
diff options
context:
space:
mode:
authorFabio Porcedda <fabio.porcedda@gmail.com>2013-01-09 06:15:26 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-17 20:39:33 -0500
commitbab734fcdf2c690371e6749ce484b17653b3cb0e (patch)
tree752e2e5191d657a7cebb25cbeb7b313792ced093 /include/linux/platform_device.h
parent53a9c87e7e02abf3575be98c9fb2018fa30a61b9 (diff)
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 a9ded9a3c175..c082c71f7225 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
204 module_driver(__platform_driver, platform_driver_register, \ 204 module_driver(__platform_driver, platform_driver_register, \
205 platform_driver_unregister) 205 platform_driver_unregister)
206 206
207/* module_platform_driver_probe() - Helper macro for drivers that don't do
208 * anything special in module init/exit. This eliminates a lot of
209 * boilerplate. Each module may only use this macro once, and
210 * calling it replaces module_init() and module_exit()
211 */
212#define module_platform_driver_probe(__platform_driver, __platform_probe) \
213static int __init __platform_driver##_init(void) \
214{ \
215 return platform_driver_probe(&(__platform_driver), \
216 __platform_probe); \
217} \
218module_init(__platform_driver##_init); \
219static void __exit __platform_driver##_exit(void) \
220{ \
221 platform_driver_unregister(&(__platform_driver)); \
222} \
223module_exit(__platform_driver##_exit);
224
207extern struct platform_device *platform_create_bundle(struct platform_driver *driver, 225extern struct platform_device *platform_create_bundle(struct platform_driver *driver,
208 int (*probe)(struct platform_device *), 226 int (*probe)(struct platform_device *),
209 struct resource *res, unsigned int n_res, 227 struct resource *res, unsigned int n_res,