Lots of device drivers especially for platform/I2C/SPI bus devices, they want to be initialized earlier than other devices, so the driver use initcall such as subsys_initcall for the device initialization.
But for those drivers, lots of them just do nothing special in xxx_initcall/module_exit, and produce lots of boilerplate.
This patch set introduces a helper macro initcall_driver() to eliminate lots of boilerplate just like module_driver() did, and use it for platform/I2C/SPI bus devices.
I use following command under the lastest kernel source code:
$grep -r -E "*_initcall" drivers/ | cut -d":" -f1 |xargs grep -E "return platform_driver_register|return i2c_add_driver|return spi_register_driver" | cut -d":" -f1 | xargs grep "module_exit" | wc -l
and get 205 hits, so if we use helper macro initcall_driver(), we can reduce thousands lines of code.
Hanjun Guo (4): driver core: introduce helper macro initcall_driver() platform device: introduce helper macro initcall_platform_driver() i2c: introduce helper macro initcall_i2c_driver() spi: introduce helper macro initcall_spi_driver()
include/linux/device.h | 27 +++++++++++++++++++++++++++ include/linux/i2c.h | 11 +++++++++++ include/linux/platform_device.h | 11 +++++++++++ include/linux/spi/spi.h | 11 +++++++++++ 4 files changed, 60 insertions(+)