From 240cd2856d8d48d893f2322f69eb6f0bde90fa78 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 16 Nov 2011 10:13:35 +0100 Subject: [PATCH] --- yaml --- r: 280027 b: refs/heads/master c: 907d0ed1c84114d4e8dafd66af982515d3739c90 h: refs/heads/master i: 280025: e403142e229e6073ce01b3af3904e6592f2b5429 280023: 02391ba67fc479971a360fac41c5a8d3c8c4df1b v: v3 --- [refs] | 2 +- trunk/include/linux/device.h | 21 +++++++++++++++++++++ trunk/include/linux/platform_device.h | 12 ++---------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/[refs] b/[refs] index 4f505b506850..e9ba70982b75 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 377195c438fc5e9e4ca59e69382c10771d817d6a +refs/heads/master: 907d0ed1c84114d4e8dafd66af982515d3739c90 diff --git a/trunk/include/linux/device.h b/trunk/include/linux/device.h index c6335982774c..341fb740d851 100644 --- a/trunk/include/linux/device.h +++ b/trunk/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_ */ diff --git a/trunk/include/linux/platform_device.h b/trunk/include/linux/platform_device.h index 2a23f7d1a825..165a8d175370 100644 --- a/trunk/include/linux/platform_device.h +++ b/trunk/include/linux/platform_device.h @@ -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 *),