summaryrefslogtreecommitdiffstats
path: root/sys/pci/if_pcn.c
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-02-06 21:21:39 +0000
committermdodd <mdodd@FreeBSD.org>2003-02-06 21:21:39 +0000
commitfc6ee6491112206cafef5f50351894a6b3ca8d51 (patch)
tree9b009b7da4957ff4c2bf5fa3dc151088da6b64ef /sys/pci/if_pcn.c
parentef9c55f6aa8970f1833d65113815de16489916d3 (diff)
downloadFreeBSD-src-fc6ee6491112206cafef5f50351894a6b3ca8d51.zip
FreeBSD-src-fc6ee6491112206cafef5f50351894a6b3ca8d51.tar.gz
Consolidate resource release code on error condition.
Diffstat (limited to 'sys/pci/if_pcn.c')
-rw-r--r--sys/pci/if_pcn.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/pci/if_pcn.c b/sys/pci/if_pcn.c
index 009fe46..e6f3dd7 100644
--- a/sys/pci/if_pcn.c
+++ b/sys/pci/if_pcn.c
@@ -588,7 +588,6 @@ pcn_attach(dev)
if (sc->pcn_irq == NULL) {
printf("pcn%d: couldn't map interrupt\n", unit);
- bus_release_resource(dev, PCN_RES, PCN_RID, sc->pcn_res);
error = ENXIO;
goto fail;
}
@@ -597,8 +596,6 @@ pcn_attach(dev)
pcn_intr, sc, &sc->pcn_intrhand);
if (error) {
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->pcn_res);
- bus_release_resource(dev, PCN_RES, PCN_RID, sc->pcn_res);
printf("pcn%d: couldn't set up irq\n", unit);
goto fail;
}
@@ -627,9 +624,6 @@ pcn_attach(dev)
if (sc->pcn_ldata == NULL) {
printf("pcn%d: no memory for list buffers!\n", unit);
- bus_teardown_intr(dev, sc->pcn_irq, sc->pcn_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->pcn_irq);
- bus_release_resource(dev, PCN_RES, PCN_RID, sc->pcn_res);
error = ENXIO;
goto fail;
}
@@ -655,9 +649,6 @@ pcn_attach(dev)
if (mii_phy_probe(dev, &sc->pcn_miibus,
pcn_ifmedia_upd, pcn_ifmedia_sts)) {
printf("pcn%d: MII without any PHY!\n", sc->pcn_unit);
- bus_teardown_intr(dev, sc->pcn_irq, sc->pcn_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->pcn_irq);
- bus_release_resource(dev, PCN_RES, PCN_RID, sc->pcn_res);
error = ENXIO;
goto fail;
}
@@ -672,6 +663,14 @@ pcn_attach(dev)
fail:
PCN_UNLOCK(sc);
+
+ if (sc->pcn_intrhand)
+ bus_teardown_intr(dev, sc->pcn_irq, sc->pcn_intrhand);
+ if (sc->pcn_irq)
+ bus_release_resource(dev, SYS_RES_IRQ, 0, sc->pcn_irq);
+ if (sc->pcn_res)
+ bus_release_resource(dev, PCN_RES, PCN_RID, sc->pcn_res);
+
mtx_destroy(&sc->pcn_mtx);
return(error);
OpenPOWER on IntegriCloud