From: Lars-Peter Clausen Date: Wed, 16 Nov 2011 09:13:36 +0000 (+0100) Subject: I2C: Add helper macro for i2c_driver boilerplate X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7c92784a546d2945b6d6973a30f7134be78eb7a4;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git I2C: Add helper macro for i2c_driver boilerplate This patch introduces the module_i2c_driver macro which is a convenience macro for I2C driver modules similar to module_platform_driver. It is intended to be used by drivers which init/exit section does nothing but register/unregister the I2C driver. By using this macro it is possible to eliminate a few lines of boilerplate code per I2C driver. Signed-off-by: Lars-Peter Clausen Acked-by: Grant Likely Acked-by: Jonathan Cameron Acked-by: Wolfram Sang Acked-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- diff --git a/include/linux/i2c.h b/include/linux/i2c.h index a81bf6d23b3e..7e92854fe9cc 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -485,6 +485,19 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap) { return adap->nr; } + +/** + * module_i2c_driver() - Helper macro for registering a I2C driver + * @__i2c_driver: i2c_driver struct + * + * Helper macro for I2C drivers which do not 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_i2c_driver(__i2c_driver) \ + module_driver(__i2c_driver, i2c_add_driver, \ + i2c_del_driver) + #endif /* I2C */ #endif /* __KERNEL__ */