Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'module-builtin_driver-v4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux

Pull module_platform_driver replacement from Paul Gortmaker:
"Replace module_platform_driver with builtin_platform driver in non
modules.

We see an increasing number of non-modular drivers using
modular_driver() type register functions. There are several downsides
to letting this continue unchecked:

- The code can appear modular to a reader of the code, and they won't
know if the code really is modular without checking the Makefile
and Kconfig to see if compilation is governed by a bool or
tristate.

- Coders of drivers may be tempted to code up an __exit function that
is never used, just in order to satisfy the required three args of
the modular registration function.

- Non-modular code ends up including the <module.h> which increases
CPP overhead that they don't need.

- It hinders us from performing better separation of the module init
code and the generic init code.

So here we introduce similar macros for builtin drivers. Then we
convert builtin drivers (controlled by a bool Kconfig) by making the
following type of mapping:

module_platform_driver() ---> builtin_platform_driver()
module_platform_driver_probe() ---> builtin_platform_driver_probe().

The set of drivers that are converted here are just the ones that
showed up as relying on an implicit include of <module.h> during a
pending header cleanup. So we convert them here vs adding an include
of <module.h> to non-modular code to avoid compile fails. Additonal
conversions can be done asynchronously at any time.

Once again, an unused module_exit function that is removed here
appears in the diffstat as an outlier wrt all the other changes"

* tag 'module-builtin_driver-v4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux:
drivers/clk: convert sunxi/clk-mod0.c to use builtin_platform_driver
drivers/power: Convert non-modular syscon-reboot to use builtin_platform_driver
drivers/soc: Convert non-modular soc-realview to use builtin_platform_driver
drivers/soc: Convert non-modular tegra/pmc to use builtin_platform_driver
drivers/cpufreq: Convert non-modular s5pv210-cpufreq.c to use builtin_platform_driver
drivers/cpuidle: Convert non-modular drivers to use builtin_platform_driver
drivers/platform: Convert non-modular pdev_bus to use builtin_platform_driver
platform_device: better support builtin boilerplate avoidance

+54 -22
+1 -1
drivers/clk/sunxi/clk-mod0.c
··· 128 128 }, 129 129 .probe = sun4i_a10_mod0_clk_probe, 130 130 }; 131 - module_platform_driver(sun4i_a10_mod0_clk_driver); 131 + builtin_platform_driver(sun4i_a10_mod0_clk_driver); 132 132 133 133 static const struct factors_data sun9i_a80_mod0_data __initconst = { 134 134 .enable = 31,
+1 -1
drivers/cpufreq/s5pv210-cpufreq.c
··· 659 659 }, 660 660 .probe = s5pv210_cpufreq_probe, 661 661 }; 662 - module_platform_driver(s5pv210_cpufreq_platdrv); 662 + builtin_platform_driver(s5pv210_cpufreq_platdrv);
+1 -2
drivers/cpuidle/cpuidle-at91.c
··· 62 62 }, 63 63 .probe = at91_cpuidle_probe, 64 64 }; 65 - 66 - module_platform_driver(at91_cpuidle_driver); 65 + builtin_platform_driver(at91_cpuidle_driver);
+1 -2
drivers/cpuidle/cpuidle-calxeda.c
··· 75 75 }, 76 76 .probe = calxeda_cpuidle_probe, 77 77 }; 78 - 79 - module_platform_driver(calxeda_cpuidle_plat_driver); 78 + builtin_platform_driver(calxeda_cpuidle_plat_driver);
+1 -2
drivers/cpuidle/cpuidle-zynq.c
··· 73 73 }, 74 74 .probe = zynq_cpuidle_probe, 75 75 }; 76 - 77 - module_platform_driver(zynq_cpuidle_driver); 76 + builtin_platform_driver(zynq_cpuidle_driver);
+1 -11
drivers/platform/goldfish/pdev_bus.c
··· 220 220 return ret; 221 221 } 222 222 223 - static int goldfish_pdev_bus_remove(struct platform_device *pdev) 224 - { 225 - iounmap(pdev_bus_base); 226 - free_irq(pdev_bus_irq, pdev); 227 - release_mem_region(pdev_bus_addr, pdev_bus_len); 228 - return 0; 229 - } 230 - 231 223 static struct platform_driver goldfish_pdev_bus_driver = { 232 224 .probe = goldfish_pdev_bus_probe, 233 - .remove = goldfish_pdev_bus_remove, 234 225 .driver = { 235 226 .name = "goldfish_pdev_bus" 236 227 } 237 228 }; 238 - 239 - module_platform_driver(goldfish_pdev_bus_driver); 229 + builtin_platform_driver(goldfish_pdev_bus_driver);
+1 -1
drivers/power/reset/syscon-reboot.c
··· 88 88 .of_match_table = syscon_reboot_of_match, 89 89 }, 90 90 }; 91 - module_platform_driver(syscon_reboot_driver); 91 + builtin_platform_driver(syscon_reboot_driver);
+1 -1
drivers/soc/tegra/pmc.c
··· 1021 1021 }, 1022 1022 .probe = tegra_pmc_probe, 1023 1023 }; 1024 - module_platform_driver(tegra_pmc_driver); 1024 + builtin_platform_driver(tegra_pmc_driver); 1025 1025 1026 1026 /* 1027 1027 * Early initialization to allow access to registers in the very early boot
+1 -1
drivers/soc/versatile/soc-realview.c
··· 142 142 .of_match_table = realview_soc_of_match, 143 143 }, 144 144 }; 145 - module_platform_driver(realview_soc_driver); 145 + builtin_platform_driver(realview_soc_driver);
+22
include/linux/device.h
··· 1300 1300 } \ 1301 1301 module_exit(__driver##_exit); 1302 1302 1303 + /** 1304 + * builtin_driver() - Helper macro for drivers that don't do anything 1305 + * special in init and have no exit. This eliminates some boilerplate. 1306 + * Each driver may only use this macro once, and calling it replaces 1307 + * device_initcall (or in some cases, the legacy __initcall). This is 1308 + * meant to be a direct parallel of module_driver() above but without 1309 + * the __exit stuff that is not used for builtin cases. 1310 + * 1311 + * @__driver: driver name 1312 + * @__register: register function for this driver type 1313 + * @...: Additional arguments to be passed to __register 1314 + * 1315 + * Use this macro to construct bus specific macros for registering 1316 + * drivers, and do not use it on its own. 1317 + */ 1318 + #define builtin_driver(__driver, __register, ...) \ 1319 + static int __init __driver##_init(void) \ 1320 + { \ 1321 + return __register(&(__driver) , ##__VA_ARGS__); \ 1322 + } \ 1323 + device_initcall(__driver##_init); 1324 + 1303 1325 #endif /* _DEVICE_H_ */
+23
include/linux/platform_device.h
··· 222 222 module_driver(__platform_driver, platform_driver_register, \ 223 223 platform_driver_unregister) 224 224 225 + /* builtin_platform_driver() - Helper macro for builtin drivers that 226 + * don't do anything special in driver init. This eliminates some 227 + * boilerplate. Each driver may only use this macro once, and 228 + * calling it replaces device_initcall(). Note this is meant to be 229 + * a parallel of module_platform_driver() above, but w/o _exit stuff. 230 + */ 231 + #define builtin_platform_driver(__platform_driver) \ 232 + builtin_driver(__platform_driver, platform_driver_register) 233 + 225 234 /* module_platform_driver_probe() - Helper macro for drivers that don't do 226 235 * anything special in module init/exit. This eliminates a lot of 227 236 * boilerplate. Each module may only use this macro once, and ··· 248 239 platform_driver_unregister(&(__platform_driver)); \ 249 240 } \ 250 241 module_exit(__platform_driver##_exit); 242 + 243 + /* builtin_platform_driver_probe() - Helper macro for drivers that don't do 244 + * anything special in device init. This eliminates some boilerplate. Each 245 + * driver may only use this macro once, and using it replaces device_initcall. 246 + * This is meant to be a parallel of module_platform_driver_probe above, but 247 + * without the __exit parts. 248 + */ 249 + #define builtin_platform_driver_probe(__platform_driver, __platform_probe) \ 250 + static int __init __platform_driver##_init(void) \ 251 + { \ 252 + return platform_driver_probe(&(__platform_driver), \ 253 + __platform_probe); \ 254 + } \ 255 + device_initcall(__platform_driver##_init); \ 251 256 252 257 #define platform_create_bundle(driver, probe, res, n_res, data, size) \ 253 258 __platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE)