Merge tag 'module-builtin_driver-v4.1-rc8' of git://git.kernel.org/pub/scm/linux...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 2 Jul 2015 17:42:13 +0000 (10:42 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 2 Jul 2015 17:42:13 +0000 (10:42 -0700)
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

drivers/clk/sunxi/clk-mod0.c
drivers/cpufreq/s5pv210-cpufreq.c
drivers/cpuidle/cpuidle-at91.c
drivers/cpuidle/cpuidle-calxeda.c
drivers/cpuidle/cpuidle-zynq.c
drivers/platform/goldfish/pdev_bus.c
drivers/power/reset/syscon-reboot.c
drivers/soc/tegra/pmc.c
drivers/soc/versatile/soc-realview.c
include/linux/device.h
include/linux/platform_device.h

index ec8f5a1fca09f4240c433a1de2ea8207e6e369e5..9d028aec58e5d8addc3a080ced48594db57c1657 100644 (file)
@@ -128,7 +128,7 @@ static struct platform_driver sun4i_a10_mod0_clk_driver = {
        },
        .probe = sun4i_a10_mod0_clk_probe,
 };
-module_platform_driver(sun4i_a10_mod0_clk_driver);
+builtin_platform_driver(sun4i_a10_mod0_clk_driver);
 
 static const struct factors_data sun9i_a80_mod0_data __initconst = {
        .enable = 31,
index b0dac7d6ba31475b9902eefaff8c9dab557f34d2..9e231f52150c404ebd92e6d74ea6a24b5642576a 100644 (file)
@@ -659,4 +659,4 @@ static struct platform_driver s5pv210_cpufreq_platdrv = {
        },
        .probe = s5pv210_cpufreq_probe,
 };
-module_platform_driver(s5pv210_cpufreq_platdrv);
+builtin_platform_driver(s5pv210_cpufreq_platdrv);
index f2446c78d87cf14eda9cec13ab05d9bd0b9198a9..9c5853b6ca4a2f47039dce98ab13e722dfdc05f4 100644 (file)
@@ -62,5 +62,4 @@ static struct platform_driver at91_cpuidle_driver = {
        },
        .probe = at91_cpuidle_probe,
 };
-
-module_platform_driver(at91_cpuidle_driver);
+builtin_platform_driver(at91_cpuidle_driver);
index 9445e6cc02be4336b396d8125d95db5577b0ad13..c13feec89ea1d68c9734553110c56aeee2b812c2 100644 (file)
@@ -75,5 +75,4 @@ static struct platform_driver calxeda_cpuidle_plat_driver = {
         },
         .probe = calxeda_cpuidle_probe,
 };
-
-module_platform_driver(calxeda_cpuidle_plat_driver);
+builtin_platform_driver(calxeda_cpuidle_plat_driver);
index 543292b1d38ea045e9d9504c59d75ba4678a0ce2..6f4257fc56e5192f0b743a00d7bafcbb3b5566c3 100644 (file)
@@ -73,5 +73,4 @@ static struct platform_driver zynq_cpuidle_driver = {
        },
        .probe = zynq_cpuidle_probe,
 };
-
-module_platform_driver(zynq_cpuidle_driver);
+builtin_platform_driver(zynq_cpuidle_driver);
index 8c43589c3edba9248c13760c8e92025b4a5cf599..1f52462f4cdd4b7e1431723ca37b32c267da68a1 100644 (file)
@@ -220,20 +220,10 @@ free_resources:
        return ret;
 }
 
-static int goldfish_pdev_bus_remove(struct platform_device *pdev)
-{
-       iounmap(pdev_bus_base);
-       free_irq(pdev_bus_irq, pdev);
-       release_mem_region(pdev_bus_addr, pdev_bus_len);
-       return 0;
-}
-
 static struct platform_driver goldfish_pdev_bus_driver = {
        .probe = goldfish_pdev_bus_probe,
-       .remove = goldfish_pdev_bus_remove,
        .driver = {
                .name = "goldfish_pdev_bus"
        }
 };
-
-module_platform_driver(goldfish_pdev_bus_driver);
+builtin_platform_driver(goldfish_pdev_bus_driver);
index d3c7d245ae63d93c5ec36617e69331b25f9b570c..7d0d269a0837c0b84e9f72eeabbab354159a3b8e 100644 (file)
@@ -88,4 +88,4 @@ static struct platform_driver syscon_reboot_driver = {
                .of_match_table = syscon_reboot_of_match,
        },
 };
-module_platform_driver(syscon_reboot_driver);
+builtin_platform_driver(syscon_reboot_driver);
index cc119d15dd1616feeef9821ecf98c94fc19ecfec..75d0457a77b72ade791df16e6193662028e35847 100644 (file)
@@ -1021,7 +1021,7 @@ static struct platform_driver tegra_pmc_driver = {
        },
        .probe = tegra_pmc_probe,
 };
-module_platform_driver(tegra_pmc_driver);
+builtin_platform_driver(tegra_pmc_driver);
 
 /*
  * Early initialization to allow access to registers in the very early boot
index 1a07bf540fecc384ef44112e0798c1afd798e9dd..e642c4540dda123a39b9ff42437f34f64f3bad06 100644 (file)
@@ -142,4 +142,4 @@ static struct platform_driver realview_soc_driver = {
                .of_match_table = realview_soc_of_match,
        },
 };
-module_platform_driver(realview_soc_driver);
+builtin_platform_driver(realview_soc_driver);
index 00ac57c26615103b0983040981cac8012c9e2f99..5a31bf3a40243e1faff078fdc509361568143f01 100644 (file)
@@ -1300,4 +1300,26 @@ static void __exit __driver##_exit(void) \
 } \
 module_exit(__driver##_exit);
 
+/**
+ * builtin_driver() - Helper macro for drivers that don't do anything
+ * special in init and have no exit. This eliminates some boilerplate.
+ * Each driver may only use this macro once, and calling it replaces
+ * device_initcall (or in some cases, the legacy __initcall).  This is
+ * meant to be a direct parallel of module_driver() above but without
+ * the __exit stuff that is not used for builtin cases.
+ *
+ * @__driver: driver name
+ * @__register: register function for this driver type
+ * @...: Additional arguments to be passed to __register
+ *
+ * Use this macro to construct bus specific macros for registering
+ * drivers, and do not use it on its own.
+ */
+#define builtin_driver(__driver, __register, ...) \
+static int __init __driver##_init(void) \
+{ \
+       return __register(&(__driver) , ##__VA_ARGS__); \
+} \
+device_initcall(__driver##_init);
+
 #endif /* _DEVICE_H_ */
index 58f1e75ba105ca9096f8fbf1d60b808e08087c03..bba08f44cc97da8f881fba53a9d20c4e80ee2969 100644 (file)
@@ -222,6 +222,15 @@ static inline void platform_set_drvdata(struct platform_device *pdev,
        module_driver(__platform_driver, platform_driver_register, \
                        platform_driver_unregister)
 
+/* builtin_platform_driver() - Helper macro for builtin drivers that
+ * don't do anything special in driver init.  This eliminates some
+ * boilerplate.  Each driver may only use this macro once, and
+ * calling it replaces device_initcall().  Note this is meant to be
+ * a parallel of module_platform_driver() above, but w/o _exit stuff.
+ */
+#define builtin_platform_driver(__platform_driver) \
+       builtin_driver(__platform_driver, platform_driver_register)
+
 /* module_platform_driver_probe() - Helper macro for drivers that don't do
  * anything special in module init/exit.  This eliminates a lot of
  * boilerplate.  Each module may only use this macro once, and
@@ -240,6 +249,20 @@ static void __exit __platform_driver##_exit(void) \
 } \
 module_exit(__platform_driver##_exit);
 
+/* builtin_platform_driver_probe() - Helper macro for drivers that don't do
+ * anything special in device init.  This eliminates some boilerplate.  Each
+ * driver may only use this macro once, and using it replaces device_initcall.
+ * This is meant to be a parallel of module_platform_driver_probe above, but
+ * without the __exit parts.
+ */
+#define builtin_platform_driver_probe(__platform_driver, __platform_probe) \
+static int __init __platform_driver##_init(void) \
+{ \
+       return platform_driver_probe(&(__platform_driver), \
+                                    __platform_probe);    \
+} \
+device_initcall(__platform_driver##_init); \
+
 #define platform_create_bundle(driver, probe, res, n_res, data, size) \
        __platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE)
 extern struct platform_device *__platform_create_bundle(