diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2011-10-05 21:29:49 +0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-10-25 02:35:47 +0400 |
commit | 940ab88962bc1aff3273a8356d64577a6e386736 (patch) | |
tree | 3d96d0cb30fd3c6e1b17b2a2d264f4d44258a3bb /include/linux | |
parent | 38ada214fad79ff5ebbed58932c5f0c9969d9c91 (diff) | |
download | linux-940ab88962bc1aff3273a8356d64577a6e386736.tar.xz |
drivercore: Add helper macro for platform_driver 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(),
which replaces the module_init()/module_exit() registrations with
template functions.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Reviewed-by: Magnus Damm <magnus.damm@gmail.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/platform_device.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 27bb05aae70d..08de528afd66 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -146,6 +146,23 @@ static inline void platform_set_drvdata(struct platform_device *pdev, void *data dev_set_drvdata(&pdev->dev, data); } +/* module_platform_driver() - 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(__platform_driver) \ +static int __init __platform_driver##_init(void) \ +{ \ + return platform_driver_register(&(__platform_driver)); \ +} \ +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, |