]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ppc32: MBX MAC address fix
authorAndrew Morton <akpm@osdl.org>
Sat, 31 Jan 2004 04:22:51 +0000 (20:22 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Sat, 31 Jan 2004 04:22:51 +0000 (20:22 -0800)
From Tom Rini <trini@kernel.crashing.org>

On the MBX the kernel made an assumption about where the MAC address would
be in the VPD (Vital Product Data).  However, the documentation for the
firmware (EPPC-Bug) describes the format of the VPD and makes no
guarrantees about the location of any VPD record.  It does however describe
the format of each record type and the MAC address record will be of type
'08' and of size 6.  This changes the code so that instead of assuming a
position, it searches for the record, which I assume is also what EPPC-Bug
does.

arch/ppc/boot/simple/embed_config.c

index 8b0c82bbefb6ae41fb501caeb42375ee29402122..3c3b31c9881900e44b7e63225a4d226d7bb78386 100644 (file)
@@ -50,7 +50,7 @@ embed_config(bd_t **bdp)
 {
        u_char  *mp;
        u_char  eebuf[128];
-       int i;
+       int i = 8;
        bd_t    *bd;
 
        bd = *bdp;
@@ -62,11 +62,21 @@ embed_config(bd_t **bdp)
 
        /* All we are looking for is the Ethernet MAC address.  The
         * first 8 bytes are 'MOTOROLA', so check for part of that.
+        * Next, the VPD describes a MAC 'packet' as being of type 08
+        * and size 06.  So we look for that and the MAC must follow.
+        * If there are more than one, we still only care about the first.
         * If it's there, assume we have a valid MAC address.  If not,
         * grab our default one.
         */
-       if ((*(uint *)eebuf) == 0x4d4f544f)
-               mp = &eebuf[0x4c];
+       if ((*(uint *)eebuf) == 0x4d4f544f) {
+               while (i < 127 && !(eebuf[i] == 0x08 && eebuf[i + 1] == 0x06))
+                        i += eebuf[i + 1] + 2;  /* skip this packet */
+
+               if (i == 127)   /* Couldn't find. */
+                       mp = (u_char *)def_enet_addr;
+               else
+                       mp = &eebuf[i + 2];
+       }
        else
                mp = (u_char *)def_enet_addr;