- Only call txp_release_resources() once if attach fails.

- Set errno to ENXIO instead of 0 in several attach failure cases.
- Setup the interrupt handler at the very end of txp_attach() after
  ether_ifattach().
- Various whitespace fixes in function prototypes.
This commit is contained in:
John Baldwin 2005-08-31 18:09:54 +00:00
parent 7afed9d69a
commit 7b7b9810bd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=149678

View File

@ -251,23 +251,12 @@ txp_attach(dev)
if (sc->sc_irq == NULL) {
device_printf(dev, "couldn't map interrupt\n");
txp_release_resources(sc);
error = ENXIO;
goto fail;
}
error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET,
txp_intr, sc, &sc->sc_intrhand);
if (error) {
txp_release_resources(sc);
device_printf(dev, "couldn't set up irq\n");
goto fail;
}
if (txp_chip_init(sc)) {
txp_release_resources(sc);
/* XXX: set error to ??? */
error = ENXIO;
goto fail;
}
@ -277,32 +266,27 @@ txp_attach(dev)
contigfree(sc->sc_fwbuf, 32768, M_DEVBUF);
sc->sc_fwbuf = NULL;
if (error) {
txp_release_resources(sc);
if (error)
goto fail;
}
sc->sc_ldata = contigmalloc(sizeof(struct txp_ldata), M_DEVBUF,
M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
bzero(sc->sc_ldata, sizeof(struct txp_ldata));
if (txp_alloc_rings(sc)) {
txp_release_resources(sc);
/* XXX: set error to ??? */
error = ENXIO;
goto fail;
}
if (txp_command(sc, TXP_CMD_MAX_PKT_SIZE_WRITE, TXP_MAX_PKTLEN, 0, 0,
NULL, NULL, NULL, 1)) {
txp_release_resources(sc);
/* XXX: set error to ??? */
error = ENXIO;
goto fail;
}
if (txp_command(sc, TXP_CMD_STATION_ADDRESS_READ, 0, 0, 0,
&p1, &p2, NULL, 1)) {
txp_release_resources(sc);
/* XXX: set error to ??? */
error = ENXIO;
goto fail;
}
@ -333,7 +317,6 @@ txp_attach(dev)
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
txp_release_resources(sc);
device_printf(dev, "couldn't set up irq\n");
error = ENOSPC;
goto fail;
@ -357,6 +340,16 @@ txp_attach(dev)
*/
ether_ifattach(ifp, eaddr);
callout_handle_init(&sc->sc_tick);
error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET,
txp_intr, sc, &sc->sc_intrhand);
if (error) {
ether_ifdetach(ifp);
device_printf(dev, "couldn't set up irq\n");
goto fail;
}
return(0);
fail: