diff options
Diffstat (limited to 'include/linux/device.h')
| -rw-r--r-- | include/linux/device.h | 21 | 
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index c6335982774..341fb740d85 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -922,4 +922,25 @@ extern long sysfs_deprecated;  #define sysfs_deprecated 0  #endif +/** + * module_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(). + * + * Use this macro to construct bus specific macros for registering + * drivers, and do not use it on its own. + */ +#define module_driver(__driver, __register, __unregister) \ +static int __init __driver##_init(void) \ +{ \ +	return __register(&(__driver)); \ +} \ +module_init(__driver##_init); \ +static void __exit __driver##_exit(void) \ +{ \ +	__unregister(&(__driver)); \ +} \ +module_exit(__driver##_exit); +  #endif /* _DEVICE_H_ */  |