adm5120: convert to use the new mips multimachine stuff

SVN-Revision: 21680
owl
Gabor Juhos 2010-06-05 18:26:40 +00:00
parent b61dce0a9b
commit ac8b72c8c9
28 changed files with 55 additions and 747 deletions

View File

@ -33,4 +33,5 @@ static void __init cas771_setup(void)
adm5120_pci_set_irq_map(ARRAY_SIZE(cas771_pci_irqs), cas771_pci_irqs);
}
MIPS_MACHINE(MACH_ADM5120_CAS771, "Cellvision CAS-771/771W", cas771_setup);
MIPS_MACHINE(MACH_ADM5120_CAS771, "CAS-771", "Cellvision CAS-771/771W",
cas771_setup);

View File

@ -131,8 +131,10 @@ void __init cas6xx_setup(void)
adm5120_add_device_switch(1, NULL);
}
MIPS_MACHINE(MACH_ADM5120_CAS630, "Cellvision CAS-630/630W", cas6xx_setup);
MIPS_MACHINE(MACH_ADM5120_CAS670, "Cellvision CAS-670/670W", cas6xx_setup);
MIPS_MACHINE(MACH_ADM5120_CAS630, "CAS-630", "Cellvision CAS-630/630W",
cas6xx_setup);
MIPS_MACHINE(MACH_ADM5120_CAS670, "CAS-670", "Cellvision CAS-670/670W",
cas6xx_setup);
void __init cas7xx_setup(void)
{
@ -143,8 +145,9 @@ void __init cas7xx_setup(void)
adm5120_add_device_switch(1, NULL);
}
#if 0
MIPS_MACHINE(MACH_ADM5120_CAS700, "Cellvision CAS-700/700W", cas7xx_setup);
MIPS_MACHINE(MACH_ADM5120_CAS790, "Cellvision CAS-790", cas7xx_setup);
MIPS_MACHINE(MACH_ADM5120_CAS861, "Cellvision CAS-861/861W", cas7xx_setup);
#endif
MIPS_MACHINE(MACH_ADM5120_CAS700, "CAS-700", "Cellvision CAS-700/700W",
cas7xx_setup);
MIPS_MACHINE(MACH_ADM5120_CAS790, "CAS-790", "Cellvision CAS-790",
cas7xx_setup);
MIPS_MACHINE(MACH_ADM5120_CAS861, "CAS-861", "Cellvision CAS-861/861W",
cas7xx_setup);

View File

@ -43,4 +43,5 @@ static void __init nfs101_setup(void)
nfs101_pci_irqs);
}
MIPS_MACHINE(MACH_ADM5120_NFS101U, "Cellvision NFS-101U/101WU", nfs101_setup);
MIPS_MACHINE(MACH_ADM5120_NFS101U, "NFS-101U", "Cellvision NFS-101U/101WU",
nfs101_setup);

View File

@ -107,7 +107,7 @@ static int __init adm5120_board_setup(void)
{
adm5120_gpio_init();
mips_machine_setup(mips_machtype);
mips_machine_setup();
return 0;
}
@ -122,5 +122,5 @@ static void __init adm5120_generic_board_setup(void)
adm5120_add_device_switch(6, NULL);
}
MIPS_MACHINE(MACH_ADM5120_GENERIC, "Generic ADM5120 board",
adm5120_generic_board_setup);
MIPS_MACHINE(MACH_ADM5120_GENERIC, "Generic", "Generic ADM5120 board",
adm5120_generic_board_setup);

View File

@ -25,4 +25,4 @@ static void __init np27g_setup(void)
/* TODO: add PCI IRQ map */
}
MIPS_MACHINE(MACH_ADM5120_NP27G, "Compex NetPassage 27G", np27g_setup);
MIPS_MACHINE(MACH_ADM5120_NP27G, "NP27G", "Compex NetPassage 27G", np27g_setup);

View File

@ -60,4 +60,4 @@ static void __init np28g_setup(void)
adm5120_pci_set_irq_map(ARRAY_SIZE(np28g_pci_irqs), np28g_pci_irqs);
}
MIPS_MACHINE(MACH_ADM5120_NP28G, "Compex NetPassage 28G", np28g_setup);
MIPS_MACHINE(MACH_ADM5120_NP28G, "NP28G", "Compex NetPassage 28G", np28g_setup);

View File

@ -79,7 +79,7 @@ static void __init wp54_setup(void)
adm5120_pci_set_irq_map(ARRAY_SIZE(wp54_pci_irqs), wp54_pci_irqs);
}
MIPS_MACHINE(MACH_ADM5120_WP54, "Compex WP54 family", wp54_setup);
MIPS_MACHINE(MACH_ADM5120_WP54, "WP54", "Compex WP54 family", wp54_setup);
static void __init wp54_wrt_setup(void)
{
@ -91,4 +91,5 @@ static void __init wp54_wrt_setup(void)
wp54_setup();
}
MIPS_MACHINE(MACH_ADM5120_WP54G_WRT, "Compex WP54G-WRT", wp54_wrt_setup);
MIPS_MACHINE(MACH_ADM5120_WP54G_WRT, "WP54G-WRT", "Compex WP54G-WRT",
wp54_wrt_setup);

View File

@ -32,4 +32,5 @@ static void __init br6104k_setup(void)
br6104k_gpio_leds);
}
MIPS_MACHINE(MACH_ADM5120_BR6104K, "Edimax BR-6104K", br6104k_setup);
MIPS_MACHINE(MACH_ADM5120_BR6104K, "BR-6104K", "Edimax BR-6104K",
br6104k_setup);

View File

@ -35,4 +35,5 @@ static void __init br6104kp_setup(void)
adm5120_add_device_usb();
}
MIPS_MACHINE(MACH_ADM5120_BR6104KP, "Edimax BR-6104KP", br6104kp_setup);
MIPS_MACHINE(MACH_ADM5120_BR6104KP, "BR-6104KP", "Edimax BR-6104KP",
br6104kp_setup);

View File

@ -39,4 +39,5 @@ static void __init br61x4wg_setup(void)
br61x4wg_pci_irqs);
}
MIPS_MACHINE(MACH_ADM5120_BR61X4WG, "Edimax BR-6104WG/6114WG", br61x4wg_setup);
MIPS_MACHINE(MACH_ADM5120_BR61X4WG, "BR-6104WG", "Edimax BR-6104WG/6114WG",
br61x4wg_setup);

View File

@ -44,6 +44,5 @@ static void __init easy5120_rt_setup(void)
easy5120_rt_pci_irqs);
}
MIPS_MACHINE(MACH_ADM5120_EASY5120RT,
"Infineon EASY 5120-RT Reference Board",
easy5120_rt_setup);
MIPS_MACHINE(MACH_ADM5120_EASY5120RT, "EASY5120-RT",
"Infineon EASY 5120-RT Reference Board", easy5120_rt_setup);

View File

@ -20,6 +20,5 @@ static void __init easy5120wvoip_setup(void)
/* TODO: setup PCI IRQ map */
}
MIPS_MACHINE(MACH_ADM5120_EASY5120WVOIP,
"Infineon EASY 5120-WVoIP Reference Board",
easy5120wvoip_setup);
MIPS_MACHINE(MACH_ADM5120_EASY5120WVOIP, "EASY5120WVoIP",
"Infineon EASY 5120-WVoIP Reference Board", easy5120wvoip_setup);

View File

@ -18,6 +18,5 @@ static void __init easy5120pata_setup(void)
adm5120_add_device_switch(6, NULL);
}
MIPS_MACHINE(MACH_ADM5120_EASY5120PATA,
"Infineon EASY 5120P-ATA Reference Board",
easy5120pata_setup);
MIPS_MACHINE(MACH_ADM5120_EASY5120PATA, "EASY5120P-ATA",
"Infineon EASY 5120P-ATA Reference Board", easy5120pata_setup);

View File

@ -19,6 +19,5 @@ static void __init easy83000_setup(void)
/* TODO: add VINAX device */
}
MIPS_MACHINE(MACH_ADM5120_EASY83000,
"Infineon EASY 83000 Reference Board",
easy83000_setup);
MIPS_MACHINE(MACH_ADM5120_EASY83000, "EASY8300",
"Infineon EASY 83000 Reference Board", easy83000_setup);

View File

@ -32,4 +32,5 @@ static void __init rb11x_setup(void)
rb11x_gpio_leds);
}
MIPS_MACHINE(MACH_ADM5120_RB_11X, "Mikrotik RouterBOARD 111/112", rb11x_setup);
MIPS_MACHINE(MACH_ADM5120_RB_11X, "11x", "Mikrotik RouterBOARD 111/112",
rb11x_setup);

View File

@ -37,4 +37,5 @@ static void __init rb133_setup(void)
rb133_gpio_leds);
}
MIPS_MACHINE(MACH_ADM5120_RB_133, "Mikrotik RouterBOARD 133", rb133_setup);
MIPS_MACHINE(MACH_ADM5120_RB_133, "133", "Mikrotik RouterBOARD 133",
rb133_setup);

View File

@ -33,4 +33,5 @@ static void __init rb133c_setup(void)
rb133c_gpio_leds);
}
MIPS_MACHINE(MACH_ADM5120_RB_133C, "Mikrotik RouterBOARD 133C", rb133c_setup);
MIPS_MACHINE(MACH_ADM5120_RB_133C, "133C", "Mikrotik RouterBOARD 133C",
rb133c_setup);

View File

@ -133,4 +133,5 @@ static void __init rb150_setup(void)
adm5120_add_device_switch(5, rb150_vlans);
}
MIPS_MACHINE(MACH_ADM5120_RB_150, "Mikrotik RouterBOARD 150", rb150_setup);
MIPS_MACHINE(MACH_ADM5120_RB_150, "miniROUTER", "Mikrotik RouterBOARD 150",
rb150_setup);

View File

@ -71,4 +71,5 @@ static void __init rb153_setup(void)
adm5120_add_device_switch(5, rb153_vlans);
}
MIPS_MACHINE(MACH_ADM5120_RB_153, "Mikrotik RouterBOARD 153", rb153_setup);
MIPS_MACHINE(MACH_ADM5120_RB_153, "150", "Mikrotik RouterBOARD 153",
rb153_setup);

View File

@ -24,4 +24,5 @@ static void __init rb192_setup(void)
adm5120_add_device_switch(6, rb192_vlans);
}
MIPS_MACHINE(MACH_ADM5120_RB_192, "Mikrotik RouterBOARD 192", rb192_setup);
MIPS_MACHINE(MACH_ADM5120_RB_192, "192", "Mikrotik RouterBOARD 192",
rb192_setup);

View File

@ -96,6 +96,5 @@ void __init pmugw_setup(void)
adm5120_add_device_switch(5, pmugw_vlans);
}
MIPS_MACHINE(MACH_ADM5120_PMUGW,
"Motorola Powerline MU Gateway",
pmugw_setup);
MIPS_MACHINE(MACH_ADM5120_PMUGW, "PMUGW", "Motorola Powerline MU Gateway",
pmugw_setup);

View File

@ -71,5 +71,5 @@ static void __init osbridge_5gxi_setup(void)
osbridge_5gxi_pci_irqs);
}
MIPS_MACHINE(MACH_ADM5120_5GXI, "OSBRiDGE 5GXi/5XLi board",
MIPS_MACHINE(MACH_ADM5120_5GXI, "5GXi", "OSBRiDGE 5GXi/5XLi board",
osbridge_5gxi_setup);

View File

@ -30,4 +30,5 @@ static void __init p334wt_setup(void)
p334wt_gpio_leds);
}
MIPS_MACHINE(MACH_ADM5120_P334WT, "ZyXEL Prestige 334WT", p334wt_setup);
MIPS_MACHINE(MACH_ADM5120_P334WT, "P-334WT" "ZyXEL Prestige 334WT",
p334wt_setup);

View File

@ -17,4 +17,5 @@ static void __init p335_setup(void)
adm5120_add_device_usb();
}
MIPS_MACHINE(MACH_ADM5120_P335, "ZyXEL Prestige 335/335WT", p335_setup);
MIPS_MACHINE(MACH_ADM5120_P335, "P-335", "ZyXEL Prestige 335/335WT",
p335_setup);

View File

@ -1,231 +0,0 @@
--- a/arch/mips/include/asm/mips_machine.h
+++ b/arch/mips/include/asm/mips_machine.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
@@ -13,42 +13,35 @@
#include <linux/init.h>
#include <linux/list.h>
-#include <asm/bootinfo.h>
-
struct mips_machine {
unsigned long mach_type;
- const char *mach_id;
- const char *mach_name;
void (*mach_setup)(void);
+ char *mach_name;
+ struct list_head list;
};
-#define MIPS_MACHINE(_type, _id, _name, _setup) \
-static const char machine_name_##_type[] __initconst \
- __aligned(1) = _name; \
-static const char machine_id_##_type[] __initconst \
- __aligned(1) = _id; \
-static struct mips_machine machine_##_type \
- __used __section(.mips.machines.init) = \
+void mips_machine_register(struct mips_machine *) __init;
+void mips_machine_setup(unsigned long machtype) __init;
+void mips_machine_set_name(char *name) __init;
+
+extern char *mips_machine_name;
+
+#define MIPS_MACHINE(_type, _name, _setup) \
+static char machine_name_##_type[] __initdata = _name; \
+static struct mips_machine machine_##_type __initdata = \
{ \
.mach_type = _type, \
- .mach_id = machine_id_##_type, \
.mach_name = machine_name_##_type, \
.mach_setup = _setup, \
-};
-
-extern long __mips_machines_start;
-extern long __mips_machines_end;
-
-#ifdef CONFIG_MIPS_MACHINE
-int mips_machtype_setup(char *id) __init;
-void mips_machine_setup(void) __init;
-void mips_set_machine_name(const char *name) __init;
-char *mips_get_machine_name(void);
-#else
-static inline int mips_machtype_setup(char *id) { return 1; }
-static inline void mips_machine_setup(void) { }
-static inline void mips_set_machine_name(const char *name) { }
-static inline char *mips_get_machine_name(void) { return NULL; }
-#endif /* CONFIG_MIPS_MACHINE */
+}; \
+ \
+static int __init register_machine_##_type(void) \
+{ \
+ mips_machine_register(&machine_##_type); \
+ return 0; \
+} \
+ \
+pure_initcall(register_machine_##_type)
#endif /* __ASM_MIPS_MACHINE_H */
+
--- a/arch/mips/kernel/mips_machine.c
+++ b/arch/mips/kernel/mips_machine.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
@@ -7,77 +7,68 @@
*
*/
#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/slab.h>
#include <asm/mips_machine.h>
+#include <asm/bootinfo.h>
-static struct mips_machine *mips_machine __initdata;
-static char *mips_machine_name = "Unknown";
+static struct list_head mips_machines __initdata =
+ LIST_HEAD_INIT(mips_machines);
-#define for_each_machine(mach) \
- for ((mach) = (struct mips_machine *)&__mips_machines_start; \
- (mach) && \
- (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
- (mach)++)
+char *mips_machine_name = "Unknown";
-__init void mips_set_machine_name(const char *name)
+static struct mips_machine * __init mips_machine_find(unsigned long machtype)
{
- char *p;
+ struct list_head *this;
- if (name == NULL)
- return;
+ list_for_each(this, &mips_machines) {
+ struct mips_machine *mach;
- p = kstrdup(name, GFP_KERNEL);
- if (!p)
- pr_err("MIPS: no memory for machine_name\n");
+ mach = list_entry(this, struct mips_machine, list);
+ if (mach->mach_type == machtype)
+ return mach;
+ }
- mips_machine_name = p;
+ return NULL;
}
-char *mips_get_machine_name(void)
+void __init mips_machine_register(struct mips_machine *mach)
{
- return mips_machine_name;
+ list_add_tail(&mach->list, &mips_machines);
}
-__init int mips_machtype_setup(char *id)
+void __init mips_machine_set_name(char *name)
{
- struct mips_machine *mach;
+ unsigned int len;
+ char *p;
- for_each_machine(mach) {
- if (mach->mach_id == NULL)
- continue;
-
- if (strcmp(mach->mach_id, id) == 0) {
- mips_machine = mach;
- break;
- }
- }
+ if (name == NULL)
+ return;
- if (!mips_machine) {
- pr_err("MIPS: no machine found for id '%s', supported machines:\n",
- id);
- pr_err("%32s %s\n", "id", "name");
- for_each_machine(mach)
- pr_err("%32s %s\n", mach->mach_id, mach->mach_name);
- return 1;
+ len = strlen(name);
+ p = kmalloc(len + 1, GFP_KERNEL);
+ if (p) {
+ strncpy(p, name, len);
+ p[len] = '\0';
+ mips_machine_name = p;
+ } else {
+ printk(KERN_WARNING "MIPS: no memory for machine_name\n");
}
-
- mips_machtype = mips_machine->mach_type;
-
- return 0;
}
-__setup("machtype=", mips_machtype_setup);
-
-__init void mips_machine_setup(void)
+void __init mips_machine_setup(unsigned long machtype)
{
- if (!mips_machine)
+ struct mips_machine *mach;
+
+ mach = mips_machine_find(machtype);
+ if (!mach) {
+ printk(KERN_ALERT "MIPS: no machine registered for "
+ "machtype %lu\n", machtype);
return;
+ }
- mips_set_machine_name(mips_machine->mach_name);
- pr_info("MIPS: machine is %s\n", mips_machine_name);
+ mips_machine_set_name(mach->mach_name);
+ printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
- if (mips_machine->mach_setup)
- mips_machine->mach_setup();
+ if (mach->mach_setup)
+ mach->mach_setup();
}
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -34,9 +34,9 @@ static int show_cpuinfo(struct seq_file
*/
if (n == 0) {
seq_printf(m, "system type\t\t: %s\n", get_system_type());
- if (mips_get_machine_name())
- seq_printf(m, "machine\t\t\t: %s\n",
- mips_get_machine_name());
+#ifdef CONFIG_MIPS_MACHINE
+ seq_printf(m, "machine\t\t\t: %s\n", mips_machine_name);
+#endif
}
seq_printf(m, "processor\t\t: %ld\n", n);
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -97,13 +97,6 @@ SECTIONS
INIT_TEXT_SECTION(PAGE_SIZE)
INIT_DATA_SECTION(16)
- . = ALIGN(4);
- .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
- __mips_machines_start = .;
- *(.mips.machines.init)
- __mips_machines_end = .;
- }
-
/* .exit.text is discarded at runtime, not link time, to deal with
* references from .rodata
*/

View File

@ -1,231 +0,0 @@
--- a/arch/mips/include/asm/mips_machine.h
+++ b/arch/mips/include/asm/mips_machine.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
@@ -13,42 +13,35 @@
#include <linux/init.h>
#include <linux/list.h>
-#include <asm/bootinfo.h>
-
struct mips_machine {
unsigned long mach_type;
- const char *mach_id;
- const char *mach_name;
void (*mach_setup)(void);
+ char *mach_name;
+ struct list_head list;
};
-#define MIPS_MACHINE(_type, _id, _name, _setup) \
-static const char machine_name_##_type[] __initconst \
- __aligned(1) = _name; \
-static const char machine_id_##_type[] __initconst \
- __aligned(1) = _id; \
-static struct mips_machine machine_##_type \
- __used __section(.mips.machines.init) = \
+void mips_machine_register(struct mips_machine *) __init;
+void mips_machine_setup(unsigned long machtype) __init;
+void mips_machine_set_name(char *name) __init;
+
+extern char *mips_machine_name;
+
+#define MIPS_MACHINE(_type, _name, _setup) \
+static char machine_name_##_type[] __initdata = _name; \
+static struct mips_machine machine_##_type __initdata = \
{ \
.mach_type = _type, \
- .mach_id = machine_id_##_type, \
.mach_name = machine_name_##_type, \
.mach_setup = _setup, \
-};
-
-extern long __mips_machines_start;
-extern long __mips_machines_end;
-
-#ifdef CONFIG_MIPS_MACHINE
-int mips_machtype_setup(char *id) __init;
-void mips_machine_setup(void) __init;
-void mips_set_machine_name(const char *name) __init;
-char *mips_get_machine_name(void);
-#else
-static inline int mips_machtype_setup(char *id) { return 1; }
-static inline void mips_machine_setup(void) { }
-static inline void mips_set_machine_name(const char *name) { }
-static inline char *mips_get_machine_name(void) { return NULL; }
-#endif /* CONFIG_MIPS_MACHINE */
+}; \
+ \
+static int __init register_machine_##_type(void) \
+{ \
+ mips_machine_register(&machine_##_type); \
+ return 0; \
+} \
+ \
+pure_initcall(register_machine_##_type)
#endif /* __ASM_MIPS_MACHINE_H */
+
--- a/arch/mips/kernel/mips_machine.c
+++ b/arch/mips/kernel/mips_machine.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
@@ -7,77 +7,68 @@
*
*/
#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/slab.h>
#include <asm/mips_machine.h>
+#include <asm/bootinfo.h>
-static struct mips_machine *mips_machine __initdata;
-static char *mips_machine_name = "Unknown";
+static struct list_head mips_machines __initdata =
+ LIST_HEAD_INIT(mips_machines);
-#define for_each_machine(mach) \
- for ((mach) = (struct mips_machine *)&__mips_machines_start; \
- (mach) && \
- (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
- (mach)++)
+char *mips_machine_name = "Unknown";
-__init void mips_set_machine_name(const char *name)
+static struct mips_machine * __init mips_machine_find(unsigned long machtype)
{
- char *p;
+ struct list_head *this;
- if (name == NULL)
- return;
+ list_for_each(this, &mips_machines) {
+ struct mips_machine *mach;
- p = kstrdup(name, GFP_KERNEL);
- if (!p)
- pr_err("MIPS: no memory for machine_name\n");
+ mach = list_entry(this, struct mips_machine, list);
+ if (mach->mach_type == machtype)
+ return mach;
+ }
- mips_machine_name = p;
+ return NULL;
}
-char *mips_get_machine_name(void)
+void __init mips_machine_register(struct mips_machine *mach)
{
- return mips_machine_name;
+ list_add_tail(&mach->list, &mips_machines);
}
-__init int mips_machtype_setup(char *id)
+void __init mips_machine_set_name(char *name)
{
- struct mips_machine *mach;
+ unsigned int len;
+ char *p;
- for_each_machine(mach) {
- if (mach->mach_id == NULL)
- continue;
-
- if (strcmp(mach->mach_id, id) == 0) {
- mips_machine = mach;
- break;
- }
- }
+ if (name == NULL)
+ return;
- if (!mips_machine) {
- pr_err("MIPS: no machine found for id '%s', supported machines:\n",
- id);
- pr_err("%32s %s\n", "id", "name");
- for_each_machine(mach)
- pr_err("%32s %s\n", mach->mach_id, mach->mach_name);
- return 1;
+ len = strlen(name);
+ p = kmalloc(len + 1, GFP_KERNEL);
+ if (p) {
+ strncpy(p, name, len);
+ p[len] = '\0';
+ mips_machine_name = p;
+ } else {
+ printk(KERN_WARNING "MIPS: no memory for machine_name\n");
}
-
- mips_machtype = mips_machine->mach_type;
-
- return 0;
}
-__setup("machtype=", mips_machtype_setup);
-
-__init void mips_machine_setup(void)
+void __init mips_machine_setup(unsigned long machtype)
{
- if (!mips_machine)
+ struct mips_machine *mach;
+
+ mach = mips_machine_find(machtype);
+ if (!mach) {
+ printk(KERN_ALERT "MIPS: no machine registered for "
+ "machtype %lu\n", machtype);
return;
+ }
- mips_set_machine_name(mips_machine->mach_name);
- pr_info("MIPS: machine is %s\n", mips_machine_name);
+ mips_machine_set_name(mach->mach_name);
+ printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
- if (mips_machine->mach_setup)
- mips_machine->mach_setup();
+ if (mach->mach_setup)
+ mach->mach_setup();
}
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -34,9 +34,9 @@ static int show_cpuinfo(struct seq_file
*/
if (n == 0) {
seq_printf(m, "system type\t\t: %s\n", get_system_type());
- if (mips_get_machine_name())
- seq_printf(m, "machine\t\t\t: %s\n",
- mips_get_machine_name());
+#ifdef CONFIG_MIPS_MACHINE
+ seq_printf(m, "machine\t\t\t: %s\n", mips_machine_name);
+#endif
}
seq_printf(m, "processor\t\t: %ld\n", n);
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -98,13 +98,6 @@ SECTIONS
INIT_TEXT_SECTION(PAGE_SIZE)
INIT_DATA_SECTION(16)
- . = ALIGN(4);
- .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
- __mips_machines_start = .;
- *(.mips.machines.init)
- __mips_machines_end = .;
- }
-
/* .exit.text is discarded at runtime, not link time, to deal with
* references from .rodata
*/

View File

@ -1,231 +0,0 @@
--- a/arch/mips/include/asm/mips_machine.h
+++ b/arch/mips/include/asm/mips_machine.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
@@ -13,42 +13,35 @@
#include <linux/init.h>
#include <linux/list.h>
-#include <asm/bootinfo.h>
-
struct mips_machine {
unsigned long mach_type;
- const char *mach_id;
- const char *mach_name;
void (*mach_setup)(void);
+ char *mach_name;
+ struct list_head list;
};
-#define MIPS_MACHINE(_type, _id, _name, _setup) \
-static const char machine_name_##_type[] __initconst \
- __aligned(1) = _name; \
-static const char machine_id_##_type[] __initconst \
- __aligned(1) = _id; \
-static struct mips_machine machine_##_type \
- __used __section(.mips.machines.init) = \
+void mips_machine_register(struct mips_machine *) __init;
+void mips_machine_setup(unsigned long machtype) __init;
+void mips_machine_set_name(char *name) __init;
+
+extern char *mips_machine_name;
+
+#define MIPS_MACHINE(_type, _name, _setup) \
+static char machine_name_##_type[] __initdata = _name; \
+static struct mips_machine machine_##_type __initdata = \
{ \
.mach_type = _type, \
- .mach_id = machine_id_##_type, \
.mach_name = machine_name_##_type, \
.mach_setup = _setup, \
-};
-
-extern long __mips_machines_start;
-extern long __mips_machines_end;
-
-#ifdef CONFIG_MIPS_MACHINE
-int mips_machtype_setup(char *id) __init;
-void mips_machine_setup(void) __init;
-void mips_set_machine_name(const char *name) __init;
-char *mips_get_machine_name(void);
-#else
-static inline int mips_machtype_setup(char *id) { return 1; }
-static inline void mips_machine_setup(void) { }
-static inline void mips_set_machine_name(const char *name) { }
-static inline char *mips_get_machine_name(void) { return NULL; }
-#endif /* CONFIG_MIPS_MACHINE */
+}; \
+ \
+static int __init register_machine_##_type(void) \
+{ \
+ mips_machine_register(&machine_##_type); \
+ return 0; \
+} \
+ \
+pure_initcall(register_machine_##_type)
#endif /* __ASM_MIPS_MACHINE_H */
+
--- a/arch/mips/kernel/mips_machine.c
+++ b/arch/mips/kernel/mips_machine.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
@@ -7,77 +7,68 @@
*
*/
#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/slab.h>
#include <asm/mips_machine.h>
+#include <asm/bootinfo.h>
-static struct mips_machine *mips_machine __initdata;
-static char *mips_machine_name = "Unknown";
+static struct list_head mips_machines __initdata =
+ LIST_HEAD_INIT(mips_machines);
-#define for_each_machine(mach) \
- for ((mach) = (struct mips_machine *)&__mips_machines_start; \
- (mach) && \
- (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
- (mach)++)
+char *mips_machine_name = "Unknown";
-__init void mips_set_machine_name(const char *name)
+static struct mips_machine * __init mips_machine_find(unsigned long machtype)
{
- char *p;
+ struct list_head *this;
- if (name == NULL)
- return;
+ list_for_each(this, &mips_machines) {
+ struct mips_machine *mach;
- p = kstrdup(name, GFP_KERNEL);
- if (!p)
- pr_err("MIPS: no memory for machine_name\n");
+ mach = list_entry(this, struct mips_machine, list);
+ if (mach->mach_type == machtype)
+ return mach;
+ }
- mips_machine_name = p;
+ return NULL;
}
-char *mips_get_machine_name(void)
+void __init mips_machine_register(struct mips_machine *mach)
{
- return mips_machine_name;
+ list_add_tail(&mach->list, &mips_machines);
}
-__init int mips_machtype_setup(char *id)
+void __init mips_machine_set_name(char *name)
{
- struct mips_machine *mach;
+ unsigned int len;
+ char *p;
- for_each_machine(mach) {
- if (mach->mach_id == NULL)
- continue;
-
- if (strcmp(mach->mach_id, id) == 0) {
- mips_machine = mach;
- break;
- }
- }
+ if (name == NULL)
+ return;
- if (!mips_machine) {
- pr_err("MIPS: no machine found for id '%s', supported machines:\n",
- id);
- pr_err("%32s %s\n", "id", "name");
- for_each_machine(mach)
- pr_err("%32s %s\n", mach->mach_id, mach->mach_name);
- return 1;
+ len = strlen(name);
+ p = kmalloc(len + 1, GFP_KERNEL);
+ if (p) {
+ strncpy(p, name, len);
+ p[len] = '\0';
+ mips_machine_name = p;
+ } else {
+ printk(KERN_WARNING "MIPS: no memory for machine_name\n");
}
-
- mips_machtype = mips_machine->mach_type;
-
- return 0;
}
-__setup("machtype=", mips_machtype_setup);
-
-__init void mips_machine_setup(void)
+void __init mips_machine_setup(unsigned long machtype)
{
- if (!mips_machine)
+ struct mips_machine *mach;
+
+ mach = mips_machine_find(machtype);
+ if (!mach) {
+ printk(KERN_ALERT "MIPS: no machine registered for "
+ "machtype %lu\n", machtype);
return;
+ }
- mips_set_machine_name(mips_machine->mach_name);
- pr_info("MIPS: machine is %s\n", mips_machine_name);
+ mips_machine_set_name(mach->mach_name);
+ printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
- if (mips_machine->mach_setup)
- mips_machine->mach_setup();
+ if (mach->mach_setup)
+ mach->mach_setup();
}
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -34,9 +34,9 @@ static int show_cpuinfo(struct seq_file
*/
if (n == 0) {
seq_printf(m, "system type\t\t: %s\n", get_system_type());
- if (mips_get_machine_name())
- seq_printf(m, "machine\t\t\t: %s\n",
- mips_get_machine_name());
+#ifdef CONFIG_MIPS_MACHINE
+ seq_printf(m, "machine\t\t\t: %s\n", mips_machine_name);
+#endif
}
seq_printf(m, "processor\t\t: %ld\n", n);
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -98,13 +98,6 @@ SECTIONS
INIT_TEXT_SECTION(PAGE_SIZE)
INIT_DATA_SECTION(16)
- . = ALIGN(4);
- .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
- __mips_machines_start = .;
- *(.mips.machines.init)
- __mips_machines_end = .;
- }
-
/* .exit.text is discarded at runtime, not link time, to deal with
* references from .rodata
*/

View File

@ -1,11 +0,0 @@
--- a/arch/mips/kernel/mips_machine.c
+++ b/arch/mips/kernel/mips_machine.c
@@ -6,7 +6,7 @@
* by the Free Software Foundation.
*
*/
-#include <linux/mm.h>
+#include <linux/slab.h>
#include <asm/mips_machine.h>
#include <asm/bootinfo.h>