summaryrefslogtreecommitdiffstats
path: root/sys/dev/bktr
diff options
context:
space:
mode:
authorroger <roger@FreeBSD.org>2000-08-24 14:17:06 +0000
committerroger <roger@FreeBSD.org>2000-08-24 14:17:06 +0000
commitf234fce050713400cc0e6419a59b0f6df01a2501 (patch)
treee204d99278acb43976a9a83aee09c637341932b3 /sys/dev/bktr
parent577040fe3ebc25295f49d5d7119a3f7af256d384 (diff)
downloadFreeBSD-src-f234fce050713400cc0e6419a59b0f6df01a2501.zip
FreeBSD-src-f234fce050713400cc0e6419a59b0f6df01a2501.tar.gz
Fix newbus resource allocations
PR: kern/18744 Submitted by: Alexander Langer <alex@cichlids.com>
Diffstat (limited to 'sys/dev/bktr')
-rw-r--r--sys/dev/bktr/bktr_os.c24
-rw-r--r--sys/dev/bktr/bktr_reg.h2
2 files changed, 16 insertions, 10 deletions
diff --git a/sys/dev/bktr/bktr_os.c b/sys/dev/bktr/bktr_os.c
index 45ff376..6dd3ba9 100644
--- a/sys/dev/bktr/bktr_os.c
+++ b/sys/dev/bktr/bktr_os.c
@@ -292,7 +292,6 @@ bktr_attach( device_t dev )
unsigned int rev;
unsigned int unit;
int error = 0;
- int rid;
#ifdef BROOKTREE_IRQ
u_long old_irq, new_irq;
#endif
@@ -314,9 +313,10 @@ bktr_attach( device_t dev )
/*
* Map control/status registers.
*/
- rid = PCIR_MAPS;
- bktr->res_mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
- 0, ~0, 1, RF_ACTIVE);
+ bktr->mem_rid = PCIR_MAPS;
+ bktr->res_mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &bktr->mem_rid,
+ 0, ~0, 1, RF_ACTIVE);
+
if (!bktr->res_mem) {
device_printf(dev, "could not map memory\n");
@@ -345,9 +345,9 @@ bktr_attach( device_t dev )
/*
* Allocate our interrupt.
*/
- rid = 0;
- bktr->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
+ bktr->irq_rid = 0;
+ bktr->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &bktr->irq_rid,
+ 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE);
if (bktr->res_irq == NULL) {
device_printf(dev, "could not map interrupt\n");
error = ENXIO;
@@ -426,6 +426,10 @@ bktr_attach( device_t dev )
return 0;
fail:
+ if (bktr->res_irq)
+ bus_release_resource(dev, SYS_RES_IRQ, bktr->irq_rid, bktr->res_irq);
+ if (bktr->res_mem)
+ bus_release_resource(dev, SYS_RES_IRQ, bktr->mem_rid, bktr->res_mem);
return error;
}
@@ -448,9 +452,9 @@ bktr_detach( device_t dev )
* Deallocate resources.
*/
bus_teardown_intr(dev, bktr->res_irq, bktr->res_ih);
- bus_release_resource(dev, SYS_RES_IRQ, 0, bktr->res_irq);
- bus_release_resource(dev, SYS_RES_MEMORY, PCIR_MAPS, bktr->res_mem);
-
+ bus_release_resource(dev, SYS_RES_IRQ, bktr->irq_rid, bktr->res_irq);
+ bus_release_resource(dev, SYS_RES_MEMORY, bktr->mem_rid, bktr->res_mem);
+
return 0;
}
diff --git a/sys/dev/bktr/bktr_reg.h b/sys/dev/bktr/bktr_reg.h
index 81bf8da..038af09 100644
--- a/sys/dev/bktr/bktr_reg.h
+++ b/sys/dev/bktr/bktr_reg.h
@@ -527,7 +527,9 @@ struct bktr_softc {
pcici_t tag; /* 2.x PCI tag, for doing PCI commands */
#endif
#if (__FreeBSD_version >= 400000)
+ int mem_rid; /* 4.x resource id */
struct resource *res_mem; /* 4.x resource descriptor for registers */
+ int irq_rid; /* 4.x resource id */
struct resource *res_irq; /* 4.x resource descriptor for interrupt */
void *res_ih; /* 4.x newbus interrupt handler cookie */
#endif
OpenPOWER on IntegriCloud