MIPS: Create a helper function for DT setup
authorKevin Cernekee <cernekee@gmail.com>
Tue, 21 Oct 2014 04:28:02 +0000 (21:28 -0700)
committerRalf Baechle <ralf@linux-mips.org>
Mon, 24 Nov 2014 06:45:12 +0000 (07:45 +0100)
A couple of platforms register two buses and call of_platform_populate().
Move this into a common function to reduce duplication.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Cc: f.fainelli@gmail.com
Cc: mbizon@freebox.fr
Cc: jogo@openwrt.org
Cc: jfraser@broadcom.com
Cc: linux-mips@linux-mips.org
Cc: devicetree@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/8167/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/prom.h
arch/mips/kernel/prom.c
arch/mips/lantiq/prom.c
arch/mips/ralink/of.c

index a9494c0141fbce811027c96b9b7c1455ea6b9635..eaa26270a5e574bae3db56202a22434c4c4b930f 100644 (file)
@@ -22,6 +22,7 @@ extern void device_tree_init(void);
 struct boot_param_header;
 
 extern void __dt_setup_arch(void *bph);
+extern int __dt_register_buses(const char *bus0, const char *bus1);
 
 #define dt_setup_arch(sym)                                             \
 ({                                                                     \
index 5d39bb85bf35a76d7e31f9dad47aecb909ae30fb..452d4350ce424bd19f07896a61df1d6da22a342c 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/debugfs.h>
 #include <linux/of.h>
 #include <linux/of_fdt.h>
+#include <linux/of_platform.h>
 
 #include <asm/page.h>
 #include <asm/prom.h>
@@ -54,4 +55,21 @@ void __init __dt_setup_arch(void *bph)
 
        mips_set_machine_name(of_flat_dt_get_machine_name());
 }
+
+int __init __dt_register_buses(const char *bus0, const char *bus1)
+{
+       static struct of_device_id of_ids[3];
+
+       if (!of_have_populated_dt())
+               panic("device tree not present");
+
+       strlcpy(of_ids[0].compatible, bus0, sizeof(of_ids[0].compatible));
+       strlcpy(of_ids[1].compatible, bus1, sizeof(of_ids[1].compatible));
+
+       if (of_platform_populate(NULL, of_ids, NULL, NULL))
+               panic("failed to populate DT");
+
+       return 0;
+}
+
 #endif
index 7447d322d14ef62aabe8b98982f60c0a872dbee6..758970e3815b7296073444641a5b8a036dd49281 100644 (file)
@@ -97,16 +97,7 @@ void __init prom_init(void)
 
 int __init plat_of_setup(void)
 {
-       static struct of_device_id of_ids[3];
-
-       if (!of_have_populated_dt())
-               panic("device tree not present");
-
-       strlcpy(of_ids[0].compatible, soc_info.compatible,
-               sizeof(of_ids[0].compatible));
-       strncpy(of_ids[1].compatible, "simple-bus",
-               sizeof(of_ids[1].compatible));
-       return of_platform_populate(NULL, of_ids, NULL, NULL);
+       return __dt_register_buses(soc_info.compatible, "simple-bus");
 }
 
 arch_initcall(plat_of_setup);
index 7c4598cb6de89874801aaa2bb41eb0822807bae7..f68115fd98ef2b9ddc2f81baa5281296636b9c90 100644 (file)
@@ -74,19 +74,9 @@ void __init plat_mem_setup(void)
 
 static int __init plat_of_setup(void)
 {
-       static struct of_device_id of_ids[3];
-       int len = sizeof(of_ids[0].compatible);
+       __dt_register_buses(soc_info.compatible, "palmbus");
 
-       if (!of_have_populated_dt())
-               panic("device tree not present");
-
-       strlcpy(of_ids[0].compatible, soc_info.compatible, len);
-       strlcpy(of_ids[1].compatible, "palmbus", len);
-
-       if (of_platform_populate(NULL, of_ids, NULL, NULL))
-               panic("failed to populate DT");
-
-       /* make sure ithat the reset controller is setup early */
+       /* make sure that the reset controller is setup early */
        ralink_rst_init();
 
        return 0;