aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/kernel/setup_mm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/m68k/kernel/setup_mm.c')
-rw-r--r--arch/m68k/kernel/setup_mm.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index cff9845708c0..0191485d7b7d 100644
--- a/arch/m68k/kernel/setup_mm.c
+++ b/arch/m68k/kernel/setup_mm.c
@@ -26,6 +26,7 @@
26#include <linux/initrd.h> 26#include <linux/initrd.h>
27 27
28#include <asm/bootinfo.h> 28#include <asm/bootinfo.h>
29#include <asm/byteorder.h>
29#include <asm/sections.h> 30#include <asm/sections.h>
30#include <asm/setup.h> 31#include <asm/setup.h>
31#include <asm/fpu.h> 32#include <asm/fpu.h>
@@ -143,11 +144,14 @@ extern void paging_init(void);
143 144
144static void __init m68k_parse_bootinfo(const struct bi_record *record) 145static void __init m68k_parse_bootinfo(const struct bi_record *record)
145{ 146{
146 while (record->tag != BI_LAST) { 147 uint16_t tag;
148
149 while ((tag = be16_to_cpu(record->tag)) != BI_LAST) {
147 int unknown = 0; 150 int unknown = 0;
148 const unsigned long *data = record->data; 151 const void *data = record->data;
152 uint16_t size = be16_to_cpu(record->size);
149 153
150 switch (record->tag) { 154 switch (tag) {
151 case BI_MACHTYPE: 155 case BI_MACHTYPE:
152 case BI_CPUTYPE: 156 case BI_CPUTYPE:
153 case BI_FPUTYPE: 157 case BI_FPUTYPE:
@@ -157,8 +161,11 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
157 161
158 case BI_MEMCHUNK: 162 case BI_MEMCHUNK:
159 if (m68k_num_memory < NUM_MEMINFO) { 163 if (m68k_num_memory < NUM_MEMINFO) {
160 m68k_memory[m68k_num_memory].addr = data[0]; 164 const struct mem_info *m = data;
161 m68k_memory[m68k_num_memory].size = data[1]; 165 m68k_memory[m68k_num_memory].addr =
166 be32_to_cpu(m->addr);
167 m68k_memory[m68k_num_memory].size =
168 be32_to_cpu(m->size);
162 m68k_num_memory++; 169 m68k_num_memory++;
163 } else 170 } else
164 pr_warn("%s: too many memory chunks\n", 171 pr_warn("%s: too many memory chunks\n",
@@ -166,12 +173,15 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
166 break; 173 break;
167 174
168 case BI_RAMDISK: 175 case BI_RAMDISK:
169 m68k_ramdisk.addr = data[0]; 176 {
170 m68k_ramdisk.size = data[1]; 177 const struct mem_info *m = data;
178 m68k_ramdisk.addr = be32_to_cpu(m->addr);
179 m68k_ramdisk.size = be32_to_cpu(m->size);
180 }
171 break; 181 break;
172 182
173 case BI_COMMAND_LINE: 183 case BI_COMMAND_LINE:
174 strlcpy(m68k_command_line, (const char *)data, 184 strlcpy(m68k_command_line, data,
175 sizeof(m68k_command_line)); 185 sizeof(m68k_command_line));
176 break; 186 break;
177 187
@@ -199,9 +209,8 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
199 } 209 }
200 if (unknown) 210 if (unknown)
201 pr_warn("%s: unknown tag 0x%04x ignored\n", __func__, 211 pr_warn("%s: unknown tag 0x%04x ignored\n", __func__,
202 record->tag); 212 tag);
203 record = (struct bi_record *)((unsigned long)record + 213 record = (struct bi_record *)((unsigned long)record + size);
204 record->size);
205 } 214 }
206 215
207 m68k_realnum_memory = m68k_num_memory; 216 m68k_realnum_memory = m68k_num_memory;