aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/ar7/platform.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-05 11:53:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-05 11:53:20 -0400
commitc3d1f1746b966907ba5ad2f75ddca24db8b21147 (patch)
tree548a25e104d8bdb906030b8d3bf78fbfde0e5817 /arch/mips/ar7/platform.c
parent66eddbfcc1f6610fa7c73c8d20a57eaf8e284e2f (diff)
parent0d365753d0b7c26043fdfa97790411606fb40112 (diff)
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/upstream-linus
* 'upstream' of git://git.linux-mips.org/pub/scm/upstream-linus: (150 commits) MIPS: PowerTV: Separate PowerTV USB support from non-USB code MIPS: strip the un-needed sections of vmlinuz MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS MIPS: Clean up arch/mips/boot/compressed/decompress.c MIPS: Clean up arch/mips/boot/compressed/ld.script MIPS: Unify the suffix of compressed vmlinux.bin MIPS: PowerTV: Add Gaia platform definitions. MIPS: BCM47xx: Fix nvram_getenv return value. MIPS: Octeon: Allow more than 3.75GB of memory with PCIe MIPS: Clean up notify_die() usage. MIPS: Remove unused task_struct.trap_no field. Documentation: Mention that KProbes is supported on MIPS SAMPLES: kprobe_example: Make it print something on MIPS. MIPS: kprobe: Add support. MIPS: Add instrunction format for BREAK and SYSCALL MIPS: kprobes: Define regs_return_value() MIPS: Ritually kill stupid printk. MIPS: Octeon: Disallow MSI-X interrupt and fall back to MSI interrupts. MIPS: Octeon: Support 256 MSI on PCIe MIPS: Decode core number for R2 CPUs. ...
Diffstat (limited to 'arch/mips/ar7/platform.c')
-rw-r--r--arch/mips/ar7/platform.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
index 8f31d1d5968..0da5b2b8dd8 100644
--- a/arch/mips/ar7/platform.c
+++ b/arch/mips/ar7/platform.c
@@ -292,40 +292,28 @@ static struct platform_device cpmac_high = {
292 .num_resources = ARRAY_SIZE(cpmac_high_res), 292 .num_resources = ARRAY_SIZE(cpmac_high_res),
293}; 293};
294 294
295static inline unsigned char char2hex(char h) 295static void __init cpmac_get_mac(int instance, unsigned char *dev_addr)
296{ 296{
297 switch (h) { 297 char name[5], *mac;
298 case '0': case '1': case '2': case '3': case '4':
299 case '5': case '6': case '7': case '8': case '9':
300 return h - '0';
301 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
302 return h - 'A' + 10;
303 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
304 return h - 'a' + 10;
305 default:
306 return 0;
307 }
308}
309
310static void cpmac_get_mac(int instance, unsigned char *dev_addr)
311{
312 int i;
313 char name[5], default_mac[ETH_ALEN], *mac;
314 298
315 mac = NULL;
316 sprintf(name, "mac%c", 'a' + instance); 299 sprintf(name, "mac%c", 'a' + instance);
317 mac = prom_getenv(name); 300 mac = prom_getenv(name);
318 if (!mac) { 301 if (!mac && instance) {
319 sprintf(name, "mac%c", 'a'); 302 sprintf(name, "mac%c", 'a');
320 mac = prom_getenv(name); 303 mac = prom_getenv(name);
321 } 304 }
322 if (!mac) { 305
323 random_ether_addr(default_mac); 306 if (mac) {
324 mac = default_mac; 307 if (sscanf(mac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
325 } 308 &dev_addr[0], &dev_addr[1],
326 for (i = 0; i < 6; i++) 309 &dev_addr[2], &dev_addr[3],
327 dev_addr[i] = (char2hex(mac[i * 3]) << 4) + 310 &dev_addr[4], &dev_addr[5]) != 6) {
328 char2hex(mac[i * 3 + 1]); 311 pr_warning("cannot parse mac address, "
312 "using random address\n");
313 random_ether_addr(dev_addr);
314 }
315 } else
316 random_ether_addr(dev_addr);
329} 317}
330 318
331/***************************************************************************** 319/*****************************************************************************