summaryrefslogtreecommitdiffstats
path: root/sys/dev/ep/if_ep.c
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-03-29 21:44:46 +0000
committermdodd <mdodd@FreeBSD.org>2003-03-29 21:44:46 +0000
commit69599b7cf6d34034513d579e54a174262ac93d39 (patch)
tree659d70beaef943197e4a69f5bddce46afd064a32 /sys/dev/ep/if_ep.c
parentf932a709c1ab4f02d50cfaef926ad44c6bb48597 (diff)
downloadFreeBSD-src-69599b7cf6d34034513d579e54a174262ac93d39.zip
FreeBSD-src-69599b7cf6d34034513d579e54a174262ac93d39.tar.gz
- Return error status instead of value in get_e().
- Modify ep_get_macaddr() to return an error status. - Reverse the return value logic of eeprom_rdy().
Diffstat (limited to 'sys/dev/ep/if_ep.c')
-rw-r--r--sys/dev/ep/if_ep.c62
1 files changed, 44 insertions, 18 deletions
diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c
index 749fa58..7d49e76 100644
--- a/sys/dev/ep/if_ep.c
+++ b/sys/dev/ep/if_ep.c
@@ -123,42 +123,54 @@ eeprom_rdy(sc)
}
if (i >= MAX_EEPROMBUSY) {
printf("ep%d: eeprom failed to come ready.\n", sc->unit);
- return (0);
+ return (ENXIO);
}
- return (1);
+ return (0);
}
/*
* get_e: gets a 16 bits word from the EEPROM. we must have set the window
* before
*/
-u_int16_t
-get_e(sc, offset)
- struct ep_softc *sc;
- u_int16_t offset;
+int
+get_e(sc, offset, result)
+ struct ep_softc *sc;
+ u_int16_t offset;
+ u_int16_t *result;
{
- if (!eeprom_rdy(sc))
- return (0);
- outw(BASE + EP_W0_EEPROM_COMMAND, (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
- if (!eeprom_rdy(sc))
+
+ if (eeprom_rdy(sc))
+ return (ENXIO);
+ outw(BASE + EP_W0_EEPROM_COMMAND,
+ (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
+ if (eeprom_rdy(sc))
+ return (ENXIO);
+ (*result) = inw(BASE + EP_W0_EEPROM_DATA);
+
return (0);
- return (inw(BASE + EP_W0_EEPROM_DATA));
}
-void
+int
ep_get_macaddr(sc, addr)
struct ep_softc * sc;
u_char * addr;
{
int i;
- u_int16_t * macaddr = (u_int16_t *)addr;
+ u_int16_t result;
+ int error;
+ u_int16_t * macaddr;
+
+ macaddr = (u_int16_t *)addr;
GO_WINDOW(0);
for(i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) {
- macaddr[i] = htons(get_e(sc, i));
+ error = get_e(sc, i, &result);
+ if (error)
+ return (error);
+ macaddr[i] = htons(result);
}
- return;
+ return (0);
}
int
@@ -167,6 +179,7 @@ ep_alloc(device_t dev)
struct ep_softc * sc = device_get_softc(dev);
int rid;
int error = 0;
+ u_int16_t result;
rid = 0;
sc->iobase = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
@@ -200,8 +213,16 @@ ep_alloc(device_t dev)
GO_WINDOW(0);
sc->epb.cmd_off = 0;
- sc->epb.prod_id = get_e(sc, EEPROM_PROD_ID);
- sc->epb.res_cfg = get_e(sc, EEPROM_RESOURCE_CFG);
+
+ error = get_e(sc, EEPROM_PROD_ID, &result);
+ if (error)
+ goto bad;
+ sc->epb.prod_id = result;
+
+ error = get_e(sc, EEPROM_RESOURCE_CFG, &result);
+ if (error)
+ goto bad;
+ sc->epb.res_cfg = result;
bad:
return (error);
@@ -259,10 +280,15 @@ ep_attach(sc)
u_short * p;
int i;
int attached;
+ int error;
sc->gone = 0;
- ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);
+ error = ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);
+ if (error) {
+ device_printf(sc->dev, "Unable to retrieve Ethernet address!\n");
+ return (ENXIO);
+ }
/*
* Setup the station address
OpenPOWER on IntegriCloud