mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
drivercore: Generalize module_platform_driver
This patch generalizes the module_platform_driver macro and introduces a new module_driver macro. The module_driver macro takes a driver name, a register and a unregister function for this driver type. Using these it construct the module init and exit sections which register and unregister the driver. Since such init/exit sections are commonly found in drivers this macro can be used to eliminate a lot of boilerplate code. The macro is not intended to be used by driver modules directly, instead it should be used to generate bus specific macros for registering drivers like the module_platform_driver macro. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Jonathan Cameron <jic23@kernel.org> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
377195c438
commit
907d0ed1c8
2 changed files with 23 additions and 10 deletions
|
@ -196,16 +196,8 @@ static inline void platform_set_drvdata(struct platform_device *pdev, void *data
|
|||
* 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);
|
||||
module_driver(__platform_driver, platform_driver_register, \
|
||||
platform_driver_unregister)
|
||||
|
||||
extern struct platform_device *platform_create_bundle(struct platform_driver *driver,
|
||||
int (*probe)(struct platform_device *),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue