[kernel] generic-2.6/2.6.30: gets rid of the length limitation on the name in the mips_machine stuff

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@15930 3c298f89-4303-0410-b956-a3cf2f4a3e73
master
Gabor Juhos 2009-05-20 08:35:01 +00:00
parent 30751997c5
commit abde2c42e5
1 changed files with 24 additions and 13 deletions

View File

@ -1,8 +1,8 @@
--- /dev/null --- /dev/null
+++ b/include/asm-mips/mips_machine.h +++ b/include/asm-mips/mips_machine.h
@@ -0,0 +1,47 @@ @@ -0,0 +1,46 @@
+/* +/*
+ * Copyright (C) 2008 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 + * 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 + * under the terms of the GNU General Public License version 2 as published
@ -16,25 +16,24 @@
+#include <linux/init.h> +#include <linux/init.h>
+#include <linux/list.h> +#include <linux/list.h>
+ +
+#define MIPS_MACHINE_NAME_LEN 64
+
+struct mips_machine { +struct mips_machine {
+ unsigned long mach_type; + unsigned long mach_type;
+ void (*mach_setup)(void); + void (*mach_setup)(void);
+ unsigned char mach_name[MIPS_MACHINE_NAME_LEN]; + char *mach_name;
+ struct list_head list; + struct list_head list;
+}; +};
+ +
+void mips_machine_register(struct mips_machine *) __init; +void mips_machine_register(struct mips_machine *) __init;
+void mips_machine_setup(unsigned long machtype) __init; +void mips_machine_setup(unsigned long machtype) __init;
+ +
+extern unsigned char mips_machine_name[MIPS_MACHINE_NAME_LEN]; +extern char *mips_machine_name;
+ +
+#define MIPS_MACHINE(_type, _name, _setup) \ +#define MIPS_MACHINE(_type, _name, _setup) \
+static char machine_name_##_type[] __initdata = _name; \
+static struct mips_machine machine_##_type __initdata = \ +static struct mips_machine machine_##_type __initdata = \
+{ \ +{ \
+ .mach_type = _type, \ + .mach_type = _type, \
+ .mach_name = _name, \ + .mach_name = machine_name_##_type, \
+ .mach_setup = _setup, \ + .mach_setup = _setup, \
+}; \ +}; \
+ \ + \
@ -50,15 +49,16 @@
+ +
--- /dev/null --- /dev/null
+++ b/arch/mips/kernel/mips_machine.c +++ b/arch/mips/kernel/mips_machine.c
@@ -0,0 +1,58 @@ @@ -0,0 +1,70 @@
+/* +/*
+ * Copyright (C) 2008 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 + * 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 + * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation. + * by the Free Software Foundation.
+ * + *
+ */ + */
+#include <linux/mm.h>
+ +
+#include <asm/mips_machine.h> +#include <asm/mips_machine.h>
+#include <asm/bootinfo.h> +#include <asm/bootinfo.h>
@ -66,7 +66,7 @@
+static struct list_head mips_machines __initdata = +static struct list_head mips_machines __initdata =
+ LIST_HEAD_INIT(mips_machines); + LIST_HEAD_INIT(mips_machines);
+ +
+unsigned char mips_machine_name[MIPS_MACHINE_NAME_LEN] = "Unknown"; +char *mips_machine_name = "Unknown";
+ +
+static struct mips_machine * __init mips_machine_find(unsigned long machtype) +static struct mips_machine * __init mips_machine_find(unsigned long machtype)
+{ +{
@ -99,9 +99,20 @@
+ return; + return;
+ } + }
+ +
+ if (mach->mach_name[0]) + if (mach->mach_name) {
+ strncpy(mips_machine_name, mach->mach_name, + char *name;
+ MIPS_MACHINE_NAME_LEN); + unsigned int len;
+
+ len = strlen(mach->mach_name);
+ name = kmalloc(len + 1, GFP_KERNEL);
+ if (name) {
+ strncpy(name, mach->mach_name,len);
+ name[len] = '\0';
+ mips_machine_name = name;
+ } else {
+ printk(KERN_WARNING "MIPS: no memory for machine_name\n");
+ }
+ }
+ +
+ printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name); + printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
+ +