Make sure to read the last byte of EEPROM descriptor. Previously
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 27 Dec 2008 06:10:01 +0000 (14:10 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 27 Dec 2008 06:10:56 +0000 (14:10 +0800)
the last byte of the ethernet address was not read which in turn
resulted in getting 5 out of the 6 bytes of ethernet address and
always returned ENOENT.

Obtained-from: FreeBSD

sys/dev/netif/jme/if_jme.c

index 12096c8..fe16ce0 100644 (file)
@@ -544,11 +544,8 @@ jme_eeprom_macaddr(struct jme_softc *sc, uint8_t eaddr[])
        do {
                if (jme_eeprom_read_byte(sc, offset, &fup) != 0)
                        break;
-               /* Check for the end of EEPROM descriptor. */
-               if ((fup & JME_EEPROM_DESC_END) == JME_EEPROM_DESC_END)
-                       break;
-               if ((uint8_t)JME_EEPROM_MKDESC(JME_EEPROM_FUNC0,
-                   JME_EEPROM_PAGE_BAR1) == fup) {
+               if (JME_EEPROM_MKDESC(JME_EEPROM_FUNC0, JME_EEPROM_PAGE_BAR1) ==
+                   (fup & (JME_EEPROM_FUNC_MASK | JME_EEPROM_PAGE_MASK))) {
                        if (jme_eeprom_read_byte(sc, offset + 1, &reg) != 0)
                                break;
                        if (reg >= JME_PAR0 &&
@@ -560,6 +557,9 @@ jme_eeprom_macaddr(struct jme_softc *sc, uint8_t eaddr[])
                                match++;
                        }
                }
+               /* Check for the end of EEPROM descriptor. */
+               if ((fup & JME_EEPROM_DESC_END) == JME_EEPROM_DESC_END)
+                       break;
                /* Try next eeprom descriptor. */
                offset += JME_EEPROM_DESC_BYTES;
        } while (match != ETHER_ADDR_LEN && offset < JME_EEPROM_END);