Skip to contentSkip to conversation

media_build: add module_driver and module_i2c_driver macros to compat.h

PATCH New Gianluca Gennari 1 participant 1 message Mar 9, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media_build: add module_driver and module_i2c_driver macros to compat.h

This patch eliminates a lot of warnings like this on old kernels:

media_build/v4l/au8522_decoder.c:842: warning: data definition has no type or storage class media_build/v4l/au8522_decoder.c:842: warning: type defaults to 'int' in declaration of 'module_i2c_driver' media_build/v4l/au8522_decoder.c:842: warning: parameter names (without types) in function declaration media_build/v4l/au8522_decoder.c:832: warning: 'au8522_driver' defined but not used

Tested with 2.6.32 and 3.3-rc6 without problems.

---
 v4l/compat.h |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
v4l/compat.h +20 -0
index 62710c9..acc105c 100644
@@ -898,4 +898,24 @@ module_exit(plat_mod_exit);
 #define DMA_MEM_TO_DEV DMA_TO_DEVICE
 #endif
 
+#ifndef module_driver
+#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
+
+#ifndef module_i2c_driver
+#define module_i2c_driver(__i2c_driver) \
+       module_driver(__i2c_driver, i2c_add_driver, \
+                       i2c_del_driver)
+#endif
+
 #endif /*  _COMPAT_H */
Signature · 1 line
1.7.0.4