bus_release_resource is spellt like bus_release_resource not like
bus_delete_resource. Fixes a problem when the probe succeeded, but the attach failed. The release of the resources was done inproperly. Approved by: jkh
This commit is contained in:
parent
73d1eabc26
commit
9a69e6509a
@ -146,7 +146,7 @@ ohci_pci_attach(device_t self)
|
|||||||
ohci_softc_t *sc = device_get_softc(self);
|
ohci_softc_t *sc = device_get_softc(self);
|
||||||
int err;
|
int err;
|
||||||
int rid;
|
int rid;
|
||||||
struct resource *res;
|
struct resource *io_res, *irq_res;
|
||||||
void *ih;
|
void *ih;
|
||||||
int intr;
|
int intr;
|
||||||
|
|
||||||
@ -154,20 +154,20 @@ ohci_pci_attach(device_t self)
|
|||||||
sc->sc_bus.usbrev = USBREV_1_0;
|
sc->sc_bus.usbrev = USBREV_1_0;
|
||||||
|
|
||||||
rid = PCI_CBMEM;
|
rid = PCI_CBMEM;
|
||||||
res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid,
|
io_res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid,
|
||||||
0, ~0, 1, RF_ACTIVE);
|
0, ~0, 1, RF_ACTIVE);
|
||||||
if (!res) {
|
if (!io_res) {
|
||||||
device_printf(self, "could not map memory\n");
|
device_printf(self, "could not map memory\n");
|
||||||
return ENXIO;
|
return ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc->iot = rman_get_bustag(res);
|
sc->iot = rman_get_bustag(io_res);
|
||||||
sc->ioh = rman_get_bushandle(res);
|
sc->ioh = rman_get_bushandle(io_res);
|
||||||
|
|
||||||
rid = 0;
|
rid = 0;
|
||||||
res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
||||||
RF_SHAREABLE | RF_ACTIVE);
|
RF_SHAREABLE | RF_ACTIVE);
|
||||||
if (res == NULL) {
|
if (irq_res == NULL) {
|
||||||
device_printf(self, "could not allocate irq\n");
|
device_printf(self, "could not allocate irq\n");
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
goto bad1;
|
goto bad1;
|
||||||
@ -222,7 +222,7 @@ ohci_pci_attach(device_t self)
|
|||||||
goto bad3;
|
goto bad3;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = BUS_SETUP_INTR(parent, self, res, INTR_TYPE_BIO,
|
err = BUS_SETUP_INTR(parent, self, irq_res, INTR_TYPE_BIO,
|
||||||
(driver_intr_t *) ohci_intr, sc, &ih);
|
(driver_intr_t *) ohci_intr, sc, &ih);
|
||||||
if (err) {
|
if (err) {
|
||||||
device_printf(self, "could not setup irq, %d\n", err);
|
device_printf(self, "could not setup irq, %d\n", err);
|
||||||
@ -247,16 +247,16 @@ ohci_pci_attach(device_t self)
|
|||||||
bus_space_write_4(sc->iot, sc->ioh,
|
bus_space_write_4(sc->iot, sc->ioh,
|
||||||
OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS);
|
OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS);
|
||||||
|
|
||||||
err = BUS_TEARDOWN_INTR(parent, self, res, ih);
|
err = BUS_TEARDOWN_INTR(parent, self, irq_res, ih);
|
||||||
if (err)
|
if (err)
|
||||||
/* XXX or should we panic? */
|
/* XXX or should we panic? */
|
||||||
device_printf(self, "could not tear down irq, %d\n", err);
|
device_printf(self, "could not tear down irq, %d\n", err);
|
||||||
bad3:
|
bad3:
|
||||||
device_delete_child(self, sc->sc_bus.bdev);
|
device_delete_child(self, sc->sc_bus.bdev);
|
||||||
bad2:
|
bad2:
|
||||||
bus_delete_resource(self, SYS_RES_IOPORT, 0);
|
bus_release_resource(self, SYS_RES_IOPORT, 0, irq_res);
|
||||||
bad1:
|
bad1:
|
||||||
bus_delete_resource(self, SYS_RES_MEMORY, PCI_CBMEM);
|
bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM, io_res);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,29 +153,29 @@ uhci_pci_attach(device_t self)
|
|||||||
device_t parent = device_get_parent(self);
|
device_t parent = device_get_parent(self);
|
||||||
int rid;
|
int rid;
|
||||||
void *ih;
|
void *ih;
|
||||||
struct resource *res;
|
struct resource *io_res, *irq_res;
|
||||||
int intr;
|
int intr;
|
||||||
int legsup;
|
int legsup;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
rid = PCI_UHCI_BASE_REG;
|
rid = PCI_UHCI_BASE_REG;
|
||||||
res = bus_alloc_resource(self, SYS_RES_IOPORT, &rid,
|
io_res = bus_alloc_resource(self, SYS_RES_IOPORT, &rid,
|
||||||
0, ~0, 1, RF_ACTIVE);
|
0, ~0, 1, RF_ACTIVE);
|
||||||
if (!res) {
|
if (!io_res) {
|
||||||
device_printf(self, "could not map ports\n");
|
device_printf(self, "could not map ports\n");
|
||||||
return ENXIO;
|
return ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc->iot = rman_get_bustag(res);
|
sc->iot = rman_get_bustag(io_res);
|
||||||
sc->ioh = rman_get_bushandle(res);
|
sc->ioh = rman_get_bushandle(io_res);
|
||||||
|
|
||||||
/* disable interrupts */
|
/* disable interrupts */
|
||||||
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
||||||
|
|
||||||
rid = 0;
|
rid = 0;
|
||||||
res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
||||||
RF_SHAREABLE | RF_ACTIVE);
|
RF_SHAREABLE | RF_ACTIVE);
|
||||||
if (res == NULL) {
|
if (irq_res == NULL) {
|
||||||
device_printf(self, "could not allocate irq\n");
|
device_printf(self, "could not allocate irq\n");
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
goto bad1;
|
goto bad1;
|
||||||
@ -229,7 +229,7 @@ uhci_pci_attach(device_t self)
|
|||||||
goto bad3;
|
goto bad3;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = BUS_SETUP_INTR(parent, self, res, INTR_TYPE_BIO,
|
err = BUS_SETUP_INTR(parent, self, irq_res, INTR_TYPE_BIO,
|
||||||
(driver_intr_t *) uhci_intr, sc, &ih);
|
(driver_intr_t *) uhci_intr, sc, &ih);
|
||||||
if (err) {
|
if (err) {
|
||||||
device_printf(self, "could not setup irq, %d\n", err);
|
device_printf(self, "could not setup irq, %d\n", err);
|
||||||
@ -265,7 +265,7 @@ uhci_pci_attach(device_t self)
|
|||||||
*/
|
*/
|
||||||
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
||||||
|
|
||||||
err = BUS_TEARDOWN_INTR(parent, self, res, ih);
|
err = BUS_TEARDOWN_INTR(parent, self, irq_res, ih);
|
||||||
if (err)
|
if (err)
|
||||||
/* XXX or should we panic? */
|
/* XXX or should we panic? */
|
||||||
device_printf(self, "could not tear down irq, %d\n",
|
device_printf(self, "could not tear down irq, %d\n",
|
||||||
@ -274,9 +274,9 @@ uhci_pci_attach(device_t self)
|
|||||||
bad3:
|
bad3:
|
||||||
device_delete_child(self, sc->sc_bus.bdev);
|
device_delete_child(self, sc->sc_bus.bdev);
|
||||||
bad2:
|
bad2:
|
||||||
bus_delete_resource(self, SYS_RES_IRQ, 0);
|
bus_release_resource(self, SYS_RES_IRQ, 0, irq_res);
|
||||||
bad1:
|
bad1:
|
||||||
bus_delete_resource(self, SYS_RES_IOPORT, PCI_UHCI_BASE_REG);
|
bus_release_resource(self, SYS_RES_IOPORT, PCI_UHCI_BASE_REG, io_res);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ ohci_pci_attach(device_t self)
|
|||||||
ohci_softc_t *sc = device_get_softc(self);
|
ohci_softc_t *sc = device_get_softc(self);
|
||||||
int err;
|
int err;
|
||||||
int rid;
|
int rid;
|
||||||
struct resource *res;
|
struct resource *io_res, *irq_res;
|
||||||
void *ih;
|
void *ih;
|
||||||
int intr;
|
int intr;
|
||||||
|
|
||||||
@ -154,20 +154,20 @@ ohci_pci_attach(device_t self)
|
|||||||
sc->sc_bus.usbrev = USBREV_1_0;
|
sc->sc_bus.usbrev = USBREV_1_0;
|
||||||
|
|
||||||
rid = PCI_CBMEM;
|
rid = PCI_CBMEM;
|
||||||
res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid,
|
io_res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid,
|
||||||
0, ~0, 1, RF_ACTIVE);
|
0, ~0, 1, RF_ACTIVE);
|
||||||
if (!res) {
|
if (!io_res) {
|
||||||
device_printf(self, "could not map memory\n");
|
device_printf(self, "could not map memory\n");
|
||||||
return ENXIO;
|
return ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc->iot = rman_get_bustag(res);
|
sc->iot = rman_get_bustag(io_res);
|
||||||
sc->ioh = rman_get_bushandle(res);
|
sc->ioh = rman_get_bushandle(io_res);
|
||||||
|
|
||||||
rid = 0;
|
rid = 0;
|
||||||
res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
||||||
RF_SHAREABLE | RF_ACTIVE);
|
RF_SHAREABLE | RF_ACTIVE);
|
||||||
if (res == NULL) {
|
if (irq_res == NULL) {
|
||||||
device_printf(self, "could not allocate irq\n");
|
device_printf(self, "could not allocate irq\n");
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
goto bad1;
|
goto bad1;
|
||||||
@ -222,7 +222,7 @@ ohci_pci_attach(device_t self)
|
|||||||
goto bad3;
|
goto bad3;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = BUS_SETUP_INTR(parent, self, res, INTR_TYPE_BIO,
|
err = BUS_SETUP_INTR(parent, self, irq_res, INTR_TYPE_BIO,
|
||||||
(driver_intr_t *) ohci_intr, sc, &ih);
|
(driver_intr_t *) ohci_intr, sc, &ih);
|
||||||
if (err) {
|
if (err) {
|
||||||
device_printf(self, "could not setup irq, %d\n", err);
|
device_printf(self, "could not setup irq, %d\n", err);
|
||||||
@ -247,16 +247,16 @@ ohci_pci_attach(device_t self)
|
|||||||
bus_space_write_4(sc->iot, sc->ioh,
|
bus_space_write_4(sc->iot, sc->ioh,
|
||||||
OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS);
|
OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS);
|
||||||
|
|
||||||
err = BUS_TEARDOWN_INTR(parent, self, res, ih);
|
err = BUS_TEARDOWN_INTR(parent, self, irq_res, ih);
|
||||||
if (err)
|
if (err)
|
||||||
/* XXX or should we panic? */
|
/* XXX or should we panic? */
|
||||||
device_printf(self, "could not tear down irq, %d\n", err);
|
device_printf(self, "could not tear down irq, %d\n", err);
|
||||||
bad3:
|
bad3:
|
||||||
device_delete_child(self, sc->sc_bus.bdev);
|
device_delete_child(self, sc->sc_bus.bdev);
|
||||||
bad2:
|
bad2:
|
||||||
bus_delete_resource(self, SYS_RES_IOPORT, 0);
|
bus_release_resource(self, SYS_RES_IOPORT, 0, irq_res);
|
||||||
bad1:
|
bad1:
|
||||||
bus_delete_resource(self, SYS_RES_MEMORY, PCI_CBMEM);
|
bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM, io_res);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,29 +153,29 @@ uhci_pci_attach(device_t self)
|
|||||||
device_t parent = device_get_parent(self);
|
device_t parent = device_get_parent(self);
|
||||||
int rid;
|
int rid;
|
||||||
void *ih;
|
void *ih;
|
||||||
struct resource *res;
|
struct resource *io_res, *irq_res;
|
||||||
int intr;
|
int intr;
|
||||||
int legsup;
|
int legsup;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
rid = PCI_UHCI_BASE_REG;
|
rid = PCI_UHCI_BASE_REG;
|
||||||
res = bus_alloc_resource(self, SYS_RES_IOPORT, &rid,
|
io_res = bus_alloc_resource(self, SYS_RES_IOPORT, &rid,
|
||||||
0, ~0, 1, RF_ACTIVE);
|
0, ~0, 1, RF_ACTIVE);
|
||||||
if (!res) {
|
if (!io_res) {
|
||||||
device_printf(self, "could not map ports\n");
|
device_printf(self, "could not map ports\n");
|
||||||
return ENXIO;
|
return ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc->iot = rman_get_bustag(res);
|
sc->iot = rman_get_bustag(io_res);
|
||||||
sc->ioh = rman_get_bushandle(res);
|
sc->ioh = rman_get_bushandle(io_res);
|
||||||
|
|
||||||
/* disable interrupts */
|
/* disable interrupts */
|
||||||
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
||||||
|
|
||||||
rid = 0;
|
rid = 0;
|
||||||
res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
||||||
RF_SHAREABLE | RF_ACTIVE);
|
RF_SHAREABLE | RF_ACTIVE);
|
||||||
if (res == NULL) {
|
if (irq_res == NULL) {
|
||||||
device_printf(self, "could not allocate irq\n");
|
device_printf(self, "could not allocate irq\n");
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
goto bad1;
|
goto bad1;
|
||||||
@ -229,7 +229,7 @@ uhci_pci_attach(device_t self)
|
|||||||
goto bad3;
|
goto bad3;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = BUS_SETUP_INTR(parent, self, res, INTR_TYPE_BIO,
|
err = BUS_SETUP_INTR(parent, self, irq_res, INTR_TYPE_BIO,
|
||||||
(driver_intr_t *) uhci_intr, sc, &ih);
|
(driver_intr_t *) uhci_intr, sc, &ih);
|
||||||
if (err) {
|
if (err) {
|
||||||
device_printf(self, "could not setup irq, %d\n", err);
|
device_printf(self, "could not setup irq, %d\n", err);
|
||||||
@ -265,7 +265,7 @@ uhci_pci_attach(device_t self)
|
|||||||
*/
|
*/
|
||||||
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
||||||
|
|
||||||
err = BUS_TEARDOWN_INTR(parent, self, res, ih);
|
err = BUS_TEARDOWN_INTR(parent, self, irq_res, ih);
|
||||||
if (err)
|
if (err)
|
||||||
/* XXX or should we panic? */
|
/* XXX or should we panic? */
|
||||||
device_printf(self, "could not tear down irq, %d\n",
|
device_printf(self, "could not tear down irq, %d\n",
|
||||||
@ -274,9 +274,9 @@ uhci_pci_attach(device_t self)
|
|||||||
bad3:
|
bad3:
|
||||||
device_delete_child(self, sc->sc_bus.bdev);
|
device_delete_child(self, sc->sc_bus.bdev);
|
||||||
bad2:
|
bad2:
|
||||||
bus_delete_resource(self, SYS_RES_IRQ, 0);
|
bus_release_resource(self, SYS_RES_IRQ, 0, irq_res);
|
||||||
bad1:
|
bad1:
|
||||||
bus_delete_resource(self, SYS_RES_IOPORT, PCI_UHCI_BASE_REG);
|
bus_release_resource(self, SYS_RES_IOPORT, PCI_UHCI_BASE_REG, io_res);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user