diff options
author | imp <imp@FreeBSD.org> | 2005-06-26 04:19:45 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2005-06-26 04:19:45 +0000 |
commit | 77c5d7a36d189d1c4f1b1d55847443a0cc46a001 (patch) | |
tree | 5035c08dd3f927e7b0ee6df0b81b0ebc2a05b11e /sys/dev/ep | |
parent | 991a0a96327d5811129df168ecd42872b043cd28 (diff) | |
download | FreeBSD-src-77c5d7a36d189d1c4f1b1d55847443a0cc46a001.zip FreeBSD-src-77c5d7a36d189d1c4f1b1d55847443a0cc46a001.tar.gz |
o When calling ep_get_macaddr(), provide it a local buffer. Add a comment
that says why we do this (or rather, explains that it is some voodoo magic
that's poorly understood). The local buffer fixes the crash on attach.
o Rename get_e() to ep_get_e() to avoid namespace pollution.
Submitted by: mux
Approved by: re (scottl)
Diffstat (limited to 'sys/dev/ep')
-rw-r--r-- | sys/dev/ep/if_ep.c | 8 | ||||
-rw-r--r-- | sys/dev/ep/if_ep_isa.c | 4 | ||||
-rw-r--r-- | sys/dev/ep/if_ep_pccard.c | 27 | ||||
-rw-r--r-- | sys/dev/ep/if_epvar.h | 2 |
4 files changed, 22 insertions, 19 deletions
diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c index 3fa7dc9..ee1e946 100644 --- a/sys/dev/ep/if_ep.c +++ b/sys/dev/ep/if_ep.c @@ -129,7 +129,7 @@ eeprom_rdy(struct ep_softc *sc) * before */ int -get_e(struct ep_softc *sc, uint16_t offset, uint16_t *result) +ep_get_e(struct ep_softc *sc, uint16_t offset, uint16_t *result) { if (eeprom_rdy(sc)) @@ -158,7 +158,7 @@ ep_get_macaddr(struct ep_softc *sc, u_char *addr) GO_WINDOW(sc, 0); for (i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) { - error = get_e(sc, i, &result); + error = ep_get_e(sc, i, &result); if (error) return (error); macaddr[i] = htons(result); @@ -203,12 +203,12 @@ ep_alloc(device_t dev) GO_WINDOW(sc, 0); sc->epb.cmd_off = 0; - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); if (error) goto bad; sc->epb.prod_id = result; - error = get_e(sc, EEPROM_RESOURCE_CFG, &result); + error = ep_get_e(sc, EEPROM_RESOURCE_CFG, &result); if (error) goto bad; sc->epb.res_cfg = result; diff --git a/sys/dev/ep/if_ep_isa.c b/sys/dev/ep/if_ep_isa.c index 407b689..03e051a 100644 --- a/sys/dev/ep/if_ep_isa.c +++ b/sys/dev/ep/if_ep_isa.c @@ -361,13 +361,13 @@ ep_eeprom_cksum(struct ep_softc *sc) uint8_t cksum_high = 0; uint8_t cksum_low = 0; - error = get_e(sc, 0x0f, &val); + error = ep_get_e(sc, 0x0f, &val); if (error) return (ENXIO); cksum = val; for (i = 0; i < 0x0f; i++) { - error = get_e(sc, i, &val); + error = ep_get_e(sc, i, &val); if (error) return (ENXIO); switch (i) { diff --git a/sys/dev/ep/if_ep_pccard.c b/sys/dev/ep/if_ep_pccard.c index f86fe61..3e5e6a7 100644 --- a/sys/dev/ep/if_ep_pccard.c +++ b/sys/dev/ep/if_ep_pccard.c @@ -73,6 +73,7 @@ ep_pccard_probe(device_t dev) struct ep_board *epb = &sc->epb; const char *desc; uint16_t result; + uint8_t enaddr[6]; int error; error = ep_alloc(dev); @@ -96,7 +97,7 @@ ep_pccard_probe(device_t dev) epb->cmd_off = 0; /* XXX check return */ - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); epb->prod_id = result; if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) { @@ -105,7 +106,7 @@ ep_pccard_probe(device_t dev) "failed (nonfatal) id 0x%x\n", epb->prod_id); epb->cmd_off = 2; /* XXX check return */ - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); epb->prod_id = result; if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) { device_printf(dev, "Unit failed to come ready or " @@ -114,14 +115,16 @@ ep_pccard_probe(device_t dev) return (ENXIO); } } - device_set_desc(dev, desc); - /* - * Newer cards supported by this device need to have their - * MAC address set. + * For reasons unknown, getting the MAC address here makes the + * 3C574 and 3C556 families get the right MAC address later. + * otherwise, the ID field is used for each of the words of the + * MAC address instead of the proper one. It is unclear why + * ep_get_macaddr would have this side effect, or even what + * that side effect really is. */ - error = ep_get_macaddr(sc, (u_char *)&IFP2ENADDR(sc->ifp)); - + ep_get_macaddr(sc, enaddr); + device_set_desc(dev, desc); ep_free(dev); return (0); } @@ -189,14 +192,14 @@ ep_pccard_attach(device_t dev) sc->epb.cmd_off = 0; /* XXX check return */ - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); sc->epb.prod_id = result; if (!ep_pccard_card_attach(&sc->epb)) { sc->epb.cmd_off = 2; - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); sc->epb.prod_id = result; - error = get_e(sc, EEPROM_RESOURCE_CFG, &result); + error = ep_get_e(sc, EEPROM_RESOURCE_CFG, &result); sc->epb.res_cfg = result; if (!ep_pccard_card_attach(&sc->epb)) { device_printf(dev, @@ -205,7 +208,7 @@ ep_pccard_attach(device_t dev) goto bad; } } - error = get_e(sc, EEPROM_ADDR_CFG, &result); + error = ep_get_e(sc, EEPROM_ADDR_CFG, &result); /* ROM size = 0, ROM base = 0 */ /* For now, ignore AUTO SELECT feature of 3C589B and later. */ diff --git a/sys/dev/ep/if_epvar.h b/sys/dev/ep/if_epvar.h index 231d4ed..31ff786 100644 --- a/sys/dev/ep/if_epvar.h +++ b/sys/dev/ep/if_epvar.h @@ -79,7 +79,7 @@ int ep_detach(device_t); void ep_get_media(struct ep_softc *); int ep_attach(struct ep_softc *); void ep_intr(void *); -int get_e(struct ep_softc *, uint16_t, uint16_t *); +int ep_get_e(struct ep_softc *, uint16_t, uint16_t *); int ep_get_macaddr(struct ep_softc *, u_char *); #define CSR_READ_1(sc, off) (bus_space_read_1((sc)->bst, (sc)->bsh, off)) |