aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-07-02 13:42:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-07-02 13:42:13 -0400
commit75462c8a87ec229e6796df5075318d824df31ead (patch)
tree04ba446d94b0dbb7eb673b4b91deca252bd00cb8
parent9d90f035310654bff86ccbccd8ccc7e0e313216d (diff)
parent77459a0feca4ae8757a905fd1791f039479e8e1e (diff)
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
-rw-r--r--drivers/clk/sunxi/clk-mod0.c2
-rw-r--r--drivers/cpufreq/s5pv210-cpufreq.c2
-rw-r--r--drivers/cpuidle/cpuidle-at91.c3
-rw-r--r--drivers/cpuidle/cpuidle-calxeda.c3
-rw-r--r--drivers/cpuidle/cpuidle-zynq.c3
-rw-r--r--drivers/platform/goldfish/pdev_bus.c12
-rw-r--r--drivers/power/reset/syscon-reboot.c2
-rw-r--r--drivers/soc/tegra/pmc.c2
-rw-r--r--drivers/soc/versatile/soc-realview.c2
-rw-r--r--include/linux/device.h22
-rw-r--r--include/linux/platform_device.h23
11 files changed, 54 insertions, 22 deletions
diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c
index ec8f5a1fca09..9d028aec58e5 100644
--- a/drivers/clk/sunxi/clk-mod0.c
+++ b/drivers/clk/sunxi/clk-mod0.c
@@ -128,7 +128,7 @@ static struct platform_driver sun4i_a10_mod0_clk_driver = {
128 }, 128 },
129 .probe = sun4i_a10_mod0_clk_probe, 129 .probe = sun4i_a10_mod0_clk_probe,
130}; 130};
131module_platform_driver(sun4i_a10_mod0_clk_driver); 131builtin_platform_driver(sun4i_a10_mod0_clk_driver);
132 132
133static const struct factors_data sun9i_a80_mod0_data __initconst = { 133static const struct factors_data sun9i_a80_mod0_data __initconst = {
134 .enable = 31, 134 .enable = 31,
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index b0dac7d6ba31..9e231f52150c 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -659,4 +659,4 @@ static struct platform_driver s5pv210_cpufreq_platdrv = {
659 }, 659 },
660 .probe = s5pv210_cpufreq_probe, 660 .probe = s5pv210_cpufreq_probe,
661}; 661};
662module_platform_driver(s5pv210_cpufreq_platdrv); 662builtin_platform_driver(s5pv210_cpufreq_platdrv);
diff --git a/drivers/cpuidle/cpuidle-at91.c b/drivers/cpuidle/cpuidle-at91.c
index f2446c78d87c..9c5853b6ca4a 100644
--- a/drivers/cpuidle/cpuidle-at91.c
+++ b/drivers/cpuidle/cpuidle-at91.c
@@ -62,5 +62,4 @@ static struct platform_driver at91_cpuidle_driver = {
62 }, 62 },
63 .probe = at91_cpuidle_probe, 63 .probe = at91_cpuidle_probe,
64}; 64};
65 65builtin_platform_driver(at91_cpuidle_driver);
66module_platform_driver(at91_cpuidle_driver);
diff --git a/drivers/cpuidle/cpuidle-calxeda.c b/drivers/cpuidle/cpuidle-calxeda.c
index 9445e6cc02be..c13feec89ea1 100644
--- a/drivers/cpuidle/cpuidle-calxeda.c
+++ b/drivers/cpuidle/cpuidle-calxeda.c
@@ -75,5 +75,4 @@ static struct platform_driver calxeda_cpuidle_plat_driver = {
75 }, 75 },
76 .probe = calxeda_cpuidle_probe, 76 .probe = calxeda_cpuidle_probe,
77}; 77};
78 78builtin_platform_driver(calxeda_cpuidle_plat_driver);
79module_platform_driver(calxeda_cpuidle_plat_driver);
diff --git a/drivers/cpuidle/cpuidle-zynq.c b/drivers/cpuidle/cpuidle-zynq.c
index 543292b1d38e..6f4257fc56e5 100644
--- a/drivers/cpuidle/cpuidle-zynq.c
+++ b/drivers/cpuidle/cpuidle-zynq.c
@@ -73,5 +73,4 @@ static struct platform_driver zynq_cpuidle_driver = {
73 }, 73 },
74 .probe = zynq_cpuidle_probe, 74 .probe = zynq_cpuidle_probe,
75}; 75};
76 76builtin_platform_driver(zynq_cpuidle_driver);
77module_platform_driver(zynq_cpuidle_driver);
diff --git a/drivers/platform/goldfish/pdev_bus.c b/drivers/platform/goldfish/pdev_bus.c
index 8c43589c3edb..1f52462f4cdd 100644
--- a/drivers/platform/goldfish/pdev_bus.c
+++ b/drivers/platform/goldfish/pdev_bus.c
@@ -220,20 +220,10 @@ free_resources:
220 return ret; 220 return ret;
221} 221}
222 222
223static 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
231static struct platform_driver goldfish_pdev_bus_driver = { 223static struct platform_driver goldfish_pdev_bus_driver = {
232 .probe = goldfish_pdev_bus_probe, 224 .probe = goldfish_pdev_bus_probe,
233 .remove = goldfish_pdev_bus_remove,
234 .driver = { 225 .driver = {
235 .name = "goldfish_pdev_bus" 226 .name = "goldfish_pdev_bus"
236 } 227 }
237}; 228};
238 229builtin_platform_driver(goldfish_pdev_bus_driver);
239module_platform_driver(goldfish_pdev_bus_driver);
diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c
index d3c7d245ae63..7d0d269a0837 100644
--- a/drivers/power/reset/syscon-reboot.c
+++ b/drivers/power/reset/syscon-reboot.c
@@ -88,4 +88,4 @@ static struct platform_driver syscon_reboot_driver = {
88 .of_match_table = syscon_reboot_of_match, 88 .of_match_table = syscon_reboot_of_match,
89 }, 89 },
90}; 90};
91module_platform_driver(syscon_reboot_driver); 91builtin_platform_driver(syscon_reboot_driver);
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index cc119d15dd16..75d0457a77b7 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -1021,7 +1021,7 @@ static struct platform_driver tegra_pmc_driver = {
1021 }, 1021 },
1022 .probe = tegra_pmc_probe, 1022 .probe = tegra_pmc_probe,
1023}; 1023};
1024module_platform_driver(tegra_pmc_driver); 1024builtin_platform_driver(tegra_pmc_driver);
1025 1025
1026/* 1026/*
1027 * Early initialization to allow access to registers in the very early boot 1027 * Early initialization to allow access to registers in the very early boot
diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c
index 1a07bf540fec..e642c4540dda 100644
--- a/drivers/soc/versatile/soc-realview.c
+++ b/drivers/soc/versatile/soc-realview.c
@@ -142,4 +142,4 @@ static struct platform_driver realview_soc_driver = {
142 .of_match_table = realview_soc_of_match, 142 .of_match_table = realview_soc_of_match,
143 }, 143 },
144}; 144};
145module_platform_driver(realview_soc_driver); 145builtin_platform_driver(realview_soc_driver);
diff --git a/include/linux/device.h b/include/linux/device.h
index 00ac57c26615..5a31bf3a4024 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1300,4 +1300,26 @@ static void __exit __driver##_exit(void) \
1300} \ 1300} \
1301module_exit(__driver##_exit); 1301module_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, ...) \
1319static int __init __driver##_init(void) \
1320{ \
1321 return __register(&(__driver) , ##__VA_ARGS__); \
1322} \
1323device_initcall(__driver##_init);
1324
1303#endif /* _DEVICE_H_ */ 1325#endif /* _DEVICE_H_ */
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 58f1e75ba105..bba08f44cc97 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -222,6 +222,15 @@ static inline void platform_set_drvdata(struct platform_device *pdev,
222 module_driver(__platform_driver, platform_driver_register, \ 222 module_driver(__platform_driver, platform_driver_register, \
223 platform_driver_unregister) 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/* module_platform_driver_probe() - Helper macro for drivers that don't do 234/* module_platform_driver_probe() - Helper macro for drivers that don't do
226 * anything special in module init/exit. This eliminates a lot of 235 * anything special in module init/exit. This eliminates a lot of
227 * boilerplate. Each module may only use this macro once, and 236 * boilerplate. Each module may only use this macro once, and
@@ -240,6 +249,20 @@ static void __exit __platform_driver##_exit(void) \
240} \ 249} \
241module_exit(__platform_driver##_exit); 250module_exit(__platform_driver##_exit);
242 251
252/* builtin_platform_driver_probe() - Helper macro for drivers that don't do
253 * anything special in device init. This eliminates some boilerplate. Each
254 * driver may only use this macro once, and using it replaces device_initcall.
255 * This is meant to be a parallel of module_platform_driver_probe above, but
256 * without the __exit parts.
257 */
258#define builtin_platform_driver_probe(__platform_driver, __platform_probe) \
259static int __init __platform_driver##_init(void) \
260{ \
261 return platform_driver_probe(&(__platform_driver), \
262 __platform_probe); \
263} \
264device_initcall(__platform_driver##_init); \
265
243#define platform_create_bundle(driver, probe, res, n_res, data, size) \ 266#define platform_create_bundle(driver, probe, res, n_res, data, size) \
244 __platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE) 267 __platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE)
245extern struct platform_device *__platform_create_bundle( 268extern struct platform_device *__platform_create_bundle(