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)
This commit is contained in:
imp 2005-06-26 04:19:45 +00:00
parent 991a0a9632
commit 77c5d7a36d
4 changed files with 22 additions and 19 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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. */

View File

@ -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))