new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE

The public bus_release_resource() API still accepts both forms, but
the internal kobj method no longer passes the arguments.
Implementations which need the rid or type now use rman_get_rid() or
rman_get_type() to fetch the value from the allocated resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44131
This commit is contained in:
John Baldwin 2024-03-13 15:05:54 -07:00
parent 2baed46e85
commit 9dbf5b0e68
67 changed files with 260 additions and 405 deletions

View file

@ -26,7 +26,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd May 18, 2000 .Dd March 13, 2024
.Dt BUS_RELEASE_RESOURCE 9 .Dt BUS_RELEASE_RESOURCE 9
.Os .Os
.Sh NAME .Sh NAME
@ -40,7 +40,7 @@
.In sys/rman.h .In sys/rman.h
.In machine/resource.h .In machine/resource.h
.Ft int .Ft int
.Fn bus_release_resource "device_t dev" "int type" "int rid" "struct resource *r" .Fn bus_release_resource "device_t dev" "struct resource *r"
.Sh DESCRIPTION .Sh DESCRIPTION
Free a resource allocated by Free a resource allocated by
.Xr bus_alloc_resource 9 . .Xr bus_alloc_resource 9 .
@ -53,20 +53,6 @@ for IRQs).
.Fa dev .Fa dev
is the device that owns the resource. is the device that owns the resource.
.It .It
.Fa type
is the type of resource that is released.
It must be of the same type you allocated it as before.
See
.Xr bus_alloc_resource 9
for valid types.
.It
.Fa rid
is the resource ID of the resource.
The
.Fa rid
value must be the same as the one returned by
.Xr bus_alloc_resource 9 .
.It
.Fa r .Fa r
is the pointer to is the pointer to
.Va struct resource , .Va struct resource ,
@ -88,12 +74,10 @@ The kernel will panic, if it cannot release the resource.
bus_teardown_intr(dev, foosoftc->irqres, foosoftc->irqid); bus_teardown_intr(dev, foosoftc->irqres, foosoftc->irqid);
/* release IRQ resource */ /* release IRQ resource */
bus_release_resource(dev, SYS_RES_IRQ, foosoftc->irqid, bus_release_resource(dev, foosoftc->irqres);
foosoftc->irqres);
/* release I/O port resource */ /* release I/O port resource */
bus_release_resource(dev, SYS_RES_IOPORT, foosoftc->portid, bus_release_resource(dev, foosoftc->portres);
foosoftc->portres);
.Ed .Ed
.Sh SEE ALSO .Sh SEE ALSO
.Xr bus_alloc_resource 9 , .Xr bus_alloc_resource 9 ,

View file

@ -347,8 +347,7 @@ static struct resource *mv_pcib_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t, u_int); rman_res_t, rman_res_t, rman_res_t, u_int);
static int mv_pcib_adjust_resource(device_t, device_t, struct resource *, static int mv_pcib_adjust_resource(device_t, device_t, struct resource *,
rman_res_t, rman_res_t); rman_res_t, rman_res_t);
static int mv_pcib_release_resource(device_t, device_t, int, int, static int mv_pcib_release_resource(device_t, device_t, struct resource *);
struct resource *);
static int mv_pcib_activate_resource(device_t, device_t, struct resource *); static int mv_pcib_activate_resource(device_t, device_t, struct resource *);
static int mv_pcib_deactivate_resource(device_t, device_t, struct resource *); static int mv_pcib_deactivate_resource(device_t, device_t, struct resource *);
static int mv_pcib_map_resource(device_t, device_t, struct resource *, static int mv_pcib_map_resource(device_t, device_t, struct resource *,
@ -962,25 +961,22 @@ mv_pcib_adjust_resource(device_t dev, device_t child,
} }
static int static int
mv_pcib_release_resource(device_t dev, device_t child, int type, int rid, mv_pcib_release_resource(device_t dev, device_t child, struct resource *res)
struct resource *res)
{ {
#ifdef PCI_RES_BUS #ifdef PCI_RES_BUS
struct mv_pcib_softc *sc = device_get_softc(dev); struct mv_pcib_softc *sc = device_get_softc(dev);
#endif #endif
switch (type) { switch (rman_get_type(res)) {
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
return (bus_generic_rman_release_resource(dev, child, type, return (bus_generic_rman_release_resource(dev, child, res));
rid, res));
#ifdef PCI_RES_BUS #ifdef PCI_RES_BUS
case PCI_RES_BUS: case PCI_RES_BUS:
return (pci_domain_release_bus(sc->ap_segment, child, rid, res)); return (pci_domain_release_bus(sc->ap_segment, child, res));
#endif #endif
default: default:
return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, return (bus_generic_release_resource(dev, child, res));
type, rid, res));
} }
} }

View file

@ -57,7 +57,7 @@
static struct resource * thunder_pcie_fdt_alloc_resource(device_t, device_t, static struct resource * thunder_pcie_fdt_alloc_resource(device_t, device_t,
int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); int, int *, rman_res_t, rman_res_t, rman_res_t, u_int);
static int thunder_pcie_fdt_release_resource(device_t, device_t, static int thunder_pcie_fdt_release_resource(device_t, device_t,
int, int, struct resource*); struct resource*);
#endif #endif
static int thunder_pcie_fdt_attach(device_t); static int thunder_pcie_fdt_attach(device_t);
static int thunder_pcie_fdt_probe(device_t); static int thunder_pcie_fdt_probe(device_t);
@ -288,14 +288,14 @@ thunder_pcie_fdt_alloc_resource(device_t dev, device_t child, int type,
} }
static int static int
thunder_pcie_fdt_release_resource(device_t dev, device_t child, int type, thunder_pcie_fdt_release_resource(device_t dev, device_t child,
int rid, struct resource *res) struct resource *res)
{ {
if ((int)ofw_bus_get_node(child) <= 0) if ((int)ofw_bus_get_node(child) <= 0)
return (pci_host_generic_core_release_resource(dev, child, type, return (pci_host_generic_core_release_resource(dev, child,
rid, res)); res));
return (bus_generic_release_resource(dev, child, type, rid, res)); return (bus_generic_release_resource(dev, child, res));
} }
#endif #endif

View file

@ -149,8 +149,7 @@ static uint32_t thunder_pem_read_config(device_t, u_int, u_int, u_int, u_int,
int); int);
static int thunder_pem_read_ivar(device_t, device_t, int, uintptr_t *); static int thunder_pem_read_ivar(device_t, device_t, int, uintptr_t *);
static void thunder_pem_release_all(device_t); static void thunder_pem_release_all(device_t);
static int thunder_pem_release_resource(device_t, device_t, int, int, static int thunder_pem_release_resource(device_t, device_t, struct resource *);
struct resource *);
static struct rman * thunder_pem_get_rman(device_t, int, u_int); static struct rman * thunder_pem_get_rman(device_t, int, u_int);
static void thunder_pem_slix_s2m_regx_acc_modify(struct thunder_pem_softc *, static void thunder_pem_slix_s2m_regx_acc_modify(struct thunder_pem_softc *,
int, int); int, int);
@ -716,28 +715,25 @@ thunder_pem_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
static int static int
thunder_pem_release_resource(device_t dev, device_t child, int type, int rid, thunder_pem_release_resource(device_t dev, device_t child, struct resource *res)
struct resource *res)
{ {
device_t parent_dev; device_t parent_dev;
#if defined(NEW_PCIB) && defined(PCI_RES_BUS) #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
struct thunder_pem_softc *sc = device_get_softc(dev); struct thunder_pem_softc *sc = device_get_softc(dev);
#endif #endif
switch (type) { switch (rman_get_type(res)) {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS) #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
case PCI_RES_BUS: case PCI_RES_BUS:
return (pci_domain_release_bus(sc->id, child, rid, res)); return (pci_domain_release_bus(sc->id, child, res));
#endif #endif
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
return (bus_generic_rman_release_resource(dev, child, type, return (bus_generic_rman_release_resource(dev, child, res));
rid, res));
default: default:
/* Find parent device. On ThunderX we know an exact path. */ /* Find parent device. On ThunderX we know an exact path. */
parent_dev = device_get_parent(device_get_parent(dev)); parent_dev = device_get_parent(device_get_parent(dev));
return (BUS_RELEASE_RESOURCE(parent_dev, child, return (BUS_RELEASE_RESOURCE(parent_dev, child, res));
type, rid, res));
} }
} }

View file

@ -1580,17 +1580,16 @@ acpi_adjust_resource(device_t bus, device_t child, struct resource *r,
} }
static int static int
acpi_release_resource(device_t bus, device_t child, int type, int rid, acpi_release_resource(device_t bus, device_t child, struct resource *r)
struct resource *r)
{ {
/* /*
* If this resource belongs to one of our internal managers, * If this resource belongs to one of our internal managers,
* deactivate it and release it to the local pool. * deactivate it and release it to the local pool.
*/ */
if (acpi_is_resource_managed(bus, r)) if (acpi_is_resource_managed(bus, r))
return (bus_generic_rman_release_resource(bus, child, type, rid, r)); return (bus_generic_rman_release_resource(bus, child, r));
return (bus_generic_rl_release_resource(bus, child, type, rid, r)); return (bus_generic_rl_release_resource(bus, child, r));
} }
static void static void

View file

@ -101,8 +101,7 @@ static int acpi_pcib_acpi_adjust_resource(device_t dev,
rman_res_t start, rman_res_t end); rman_res_t start, rman_res_t end);
#ifdef PCI_RES_BUS #ifdef PCI_RES_BUS
static int acpi_pcib_acpi_release_resource(device_t dev, static int acpi_pcib_acpi_release_resource(device_t dev,
device_t child, int type, int rid, device_t child, struct resource *r);
struct resource *r);
static int acpi_pcib_acpi_activate_resource(device_t dev, static int acpi_pcib_acpi_activate_resource(device_t dev,
device_t child, struct resource *r); device_t child, struct resource *r);
static int acpi_pcib_acpi_deactivate_resource(device_t dev, static int acpi_pcib_acpi_deactivate_resource(device_t dev,
@ -516,7 +515,7 @@ acpi_pcib_acpi_attach(device_t dev)
return (ENXIO); return (ENXIO);
} }
sc->ap_bus = rman_get_start(bus_res); sc->ap_bus = rman_get_start(bus_res);
pci_domain_release_bus(sc->ap_segment, dev, rid, bus_res); pci_domain_release_bus(sc->ap_segment, dev, bus_res);
} }
} else { } else {
/* /*
@ -759,15 +758,15 @@ acpi_pcib_acpi_adjust_resource(device_t dev, device_t child,
#ifdef PCI_RES_BUS #ifdef PCI_RES_BUS
int int
acpi_pcib_acpi_release_resource(device_t dev, device_t child, int type, int rid, acpi_pcib_acpi_release_resource(device_t dev, device_t child,
struct resource *r) struct resource *r)
{ {
struct acpi_hpcib_softc *sc; struct acpi_hpcib_softc *sc;
sc = device_get_softc(dev); sc = device_get_softc(dev);
if (type == PCI_RES_BUS) if (rman_get_type(r) == PCI_RES_BUS)
return (pci_domain_release_bus(sc->ap_segment, child, rid, r)); return (pci_domain_release_bus(sc->ap_segment, child, r));
return (bus_generic_release_resource(dev, child, type, rid, r)); return (bus_generic_release_resource(dev, child, r));
} }
int int

View file

@ -2053,8 +2053,8 @@ agp_i915_chipset_flush_free_page(device_t dev)
return; return;
BUS_DEACTIVATE_RESOURCE(device_get_parent(vga), dev, BUS_DEACTIVATE_RESOURCE(device_get_parent(vga), dev,
sc->sc_flush_page_res); sc->sc_flush_page_res);
BUS_RELEASE_RESOURCE(device_get_parent(vga), dev, SYS_RES_MEMORY, BUS_RELEASE_RESOURCE(device_get_parent(vga), dev,
sc->sc_flush_page_rid, sc->sc_flush_page_res); sc->sc_flush_page_res);
} }
static int static int

View file

@ -640,16 +640,15 @@ ahci_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
int int
ahci_release_resource(device_t dev, device_t child, int type, int rid, ahci_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
switch (type) { switch (rman_get_type(r)) {
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
rman_release_resource(r); rman_release_resource(r);
return (0); return (0);
case SYS_RES_IRQ: case SYS_RES_IRQ:
if (rid != ATA_IRQ_RID) if (rman_get_rid(r) != ATA_IRQ_RID)
return (ENOENT); return (ENOENT);
return (0); return (0);
} }

View file

@ -656,8 +656,7 @@ int ahci_setup_interrupt(device_t dev);
int ahci_print_child(device_t dev, device_t child); int ahci_print_child(device_t dev, device_t child);
struct resource *ahci_alloc_resource(device_t dev, device_t child, int type, int *rid, struct resource *ahci_alloc_resource(device_t dev, device_t child, int type, int *rid,
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); rman_res_t start, rman_res_t end, rman_res_t count, u_int flags);
int ahci_release_resource(device_t dev, device_t child, int type, int rid, int ahci_release_resource(device_t dev, device_t child, struct resource *r);
struct resource *r);
int ahci_setup_intr(device_t dev, device_t child, struct resource *irq, int ahci_setup_intr(device_t dev, device_t child, struct resource *irq,
int flags, driver_filter_t *filter, driver_intr_t *function, int flags, driver_filter_t *filter, driver_intr_t *function,
void *argument, void **cookiep); void *argument, void **cookiep);

View file

@ -273,24 +273,20 @@ ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
int int
ata_pci_release_resource(device_t dev, device_t child, int type, int rid, ata_pci_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
int rid = rman_get_rid(r);
int type = rman_get_type(r);
if (device_get_devclass(child) == ata_devclass) { if (device_get_devclass(child) == ata_devclass) {
struct ata_pci_controller *controller = device_get_softc(dev); struct ata_pci_controller *controller = device_get_softc(dev);
int unit = ((struct ata_channel *)device_get_softc(child))->unit;
if (type == SYS_RES_IOPORT) { if (type == SYS_RES_IOPORT) {
switch (rid) { switch (rid) {
case ATA_IOADDR_RID: case ATA_IOADDR_RID:
return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev,
SYS_RES_IOPORT,
PCIR_BAR(0) + (unit << 3), r);
case ATA_CTLADDR_RID: case ATA_CTLADDR_RID:
return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev,
SYS_RES_IOPORT, r);
PCIR_BAR(1) + (unit << 3), r);
default: default:
return ENOENT; return ENOENT;
} }
@ -300,7 +296,7 @@ ata_pci_release_resource(device_t dev, device_t child, int type, int rid,
return ENOENT; return ENOENT;
if (controller->legacy) { if (controller->legacy) {
return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, return BUS_RELEASE_RESOURCE(device_get_parent(dev), child,
SYS_RES_IRQ, rid, r); r);
} else } else
return 0; return 0;
} }
@ -311,7 +307,7 @@ ata_pci_release_resource(device_t dev, device_t child, int type, int rid,
return (0); return (0);
} else { } else {
return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child,
type, rid, r)); r));
} }
} }
return (EINVAL); return (EINVAL);

View file

@ -538,7 +538,7 @@ void ata_pci_write_config(device_t dev, device_t child, int reg,
int ata_pci_print_child(device_t dev, device_t child); int ata_pci_print_child(device_t dev, device_t child);
int ata_pci_child_location(device_t dev, device_t child, struct sbuf *sb); int ata_pci_child_location(device_t dev, device_t child, struct sbuf *sb);
struct resource * ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); struct resource * ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags);
int ata_pci_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r); int ata_pci_release_resource(device_t dev, device_t child, struct resource *r);
int ata_pci_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *function, void *argument, void **cookiep); int ata_pci_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *function, void *argument, void **cookiep);
int ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie); int ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie);
int ata_pci_ch_attach(device_t dev); int ata_pci_ch_attach(device_t dev);

View file

@ -53,7 +53,7 @@ static struct resource *atkbdc_isa_alloc_resource(device_t dev, device_t child,
int type, int *rid, rman_res_t start, rman_res_t end, int type, int *rid, rman_res_t start, rman_res_t end,
rman_res_t count, u_int flags); rman_res_t count, u_int flags);
static int atkbdc_isa_release_resource(device_t dev, device_t child, static int atkbdc_isa_release_resource(device_t dev, device_t child,
int type, int rid, struct resource *r); struct resource *r);
static device_method_t atkbdc_isa_methods[] = { static device_method_t atkbdc_isa_methods[] = {
DEVMETHOD(device_probe, atkbdc_isa_probe), DEVMETHOD(device_probe, atkbdc_isa_probe),
@ -306,15 +306,14 @@ atkbdc_isa_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
static int static int
atkbdc_isa_release_resource(device_t dev, device_t child, int type, int rid, atkbdc_isa_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
atkbdc_softc_t *sc; atkbdc_softc_t *sc;
sc = *(atkbdc_softc_t **)device_get_softc(dev); sc = *(atkbdc_softc_t **)device_get_softc(dev);
if (type == SYS_RES_IRQ && rid == KBDC_RID_KBD && r == sc->irq) if (r == sc->irq)
return (0); return (0);
return (bus_generic_rl_release_resource(dev, child, type, rid, r)); return (bus_generic_rl_release_resource(dev, child, r));
} }
DRIVER_MODULE(atkbdc, isa, atkbdc_isa_driver, 0, 0); DRIVER_MODULE(atkbdc, isa, atkbdc_isa_driver, 0, 0);

View file

@ -2241,7 +2241,7 @@ bhnd_bus_generic_alloc_resource(device_t dev, device_t child, int type,
failed: failed:
if (res != NULL) if (res != NULL)
BUS_RELEASE_RESOURCE(dev, child, type, *rid, res); BUS_RELEASE_RESOURCE(dev, child, res);
free(br, M_BHND); free(br, M_BHND);
return (NULL); return (NULL);
@ -2259,7 +2259,7 @@ bhnd_bus_generic_release_resource(device_t dev, device_t child, int type,
{ {
int error; int error;
if ((error = BUS_RELEASE_RESOURCE(dev, child, type, rid, r->res))) if ((error = BUS_RELEASE_RESOURCE(dev, child, r->res)))
return (error); return (error);
free(r, M_BHND); free(r, M_BHND);

View file

@ -1034,8 +1034,7 @@ bhndb_alloc_resource(device_t dev, device_t child, int type,
* Default bhndb(4) implementation of BUS_RELEASE_RESOURCE(). * Default bhndb(4) implementation of BUS_RELEASE_RESOURCE().
*/ */
static int static int
bhndb_release_resource(device_t dev, device_t child, int type, int rid, bhndb_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
struct bhndb_softc *sc; struct bhndb_softc *sc;
struct resource_list_entry *rle; struct resource_list_entry *rle;
@ -1047,9 +1046,9 @@ bhndb_release_resource(device_t dev, device_t child, int type, int rid,
/* Delegate to our parent device's bus if the requested resource type /* Delegate to our parent device's bus if the requested resource type
* isn't handled locally. */ * isn't handled locally. */
if (bhndb_get_rman(sc, child, type) == NULL) { if (bhndb_get_rman(sc, child, rman_get_type(r)) == NULL) {
return (BUS_RELEASE_RESOURCE(device_get_parent(sc->parent_dev), return (BUS_RELEASE_RESOURCE(device_get_parent(sc->parent_dev),
child, type, rid, r)); child, r));
} }
/* Deactivate resources */ /* Deactivate resources */
@ -1065,7 +1064,7 @@ bhndb_release_resource(device_t dev, device_t child, int type, int rid,
if (!passthrough) { if (!passthrough) {
/* Clean resource list entry */ /* Clean resource list entry */
rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child), rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child),
type, rid); rman_get_type(r), rman_get_rid(r));
if (rle != NULL) if (rle != NULL)
rle->res = NULL; rle->res = NULL;
} }

View file

@ -873,8 +873,7 @@ chipc_alloc_resource(device_t dev, device_t child, int type,
} }
static int static int
chipc_release_resource(device_t dev, device_t child, int type, int rid, chipc_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
struct chipc_softc *sc; struct chipc_softc *sc;
struct chipc_region *cr; struct chipc_region *cr;
@ -885,10 +884,9 @@ chipc_release_resource(device_t dev, device_t child, int type, int rid,
sc = device_get_softc(dev); sc = device_get_softc(dev);
/* Handled by parent bus? */ /* Handled by parent bus? */
rm = chipc_get_rman(dev, type, rman_get_flags(r)); rm = chipc_get_rman(dev, rman_get_type(r), rman_get_flags(r));
if (rm == NULL || !rman_is_region_manager(r, rm)) { if (rm == NULL || !rman_is_region_manager(r, rm)) {
return (bus_generic_rl_release_resource(dev, child, type, rid, return (bus_generic_rl_release_resource(dev, child, r));
r));
} }
/* Locate the mapping region */ /* Locate the mapping region */
@ -897,7 +895,7 @@ chipc_release_resource(device_t dev, device_t child, int type, int rid,
return (EINVAL); return (EINVAL);
/* Deactivate resources */ /* Deactivate resources */
error = bus_generic_rman_release_resource(dev, child, type, rid, r); error = bus_generic_rman_release_resource(dev, child, r);
if (error != 0) if (error != 0)
return (error); return (error);
@ -905,7 +903,8 @@ chipc_release_resource(device_t dev, device_t child, int type, int rid,
chipc_release_region(sc, cr, RF_ALLOCATED); chipc_release_region(sc, cr, RF_ALLOCATED);
/* Clear reference from the resource list entry if exists */ /* Clear reference from the resource list entry if exists */
rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child), type, rid); rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child),
rman_get_type(r), rman_get_rid(r));
if (rle != NULL) if (rle != NULL)
rle->res = NULL; rle->res = NULL;

View file

@ -69,8 +69,7 @@ static struct resource * bhnd_usb_alloc_resource(device_t bus,
rman_res_t start, rman_res_t end, rman_res_t start, rman_res_t end,
rman_res_t count, u_int flags); rman_res_t count, u_int flags);
static int bhnd_usb_release_resource(device_t dev, static int bhnd_usb_release_resource(device_t dev,
device_t child, int type, int rid, device_t child, struct resource *r);
struct resource *r);
static struct resource_list * bhnd_usb_get_reslist(device_t dev, static struct resource_list * bhnd_usb_get_reslist(device_t dev,
device_t child); device_t child);
@ -311,8 +310,8 @@ bhnd_usb_get_reslist(device_t dev, device_t child)
} }
static int static int
bhnd_usb_release_resource(device_t dev, device_t child, int type, bhnd_usb_release_resource(device_t dev, device_t child,
int rid, struct resource *r) struct resource *r)
{ {
struct bhnd_usb_softc *sc; struct bhnd_usb_softc *sc;
struct resource_list_entry *rle; struct resource_list_entry *rle;
@ -325,18 +324,17 @@ bhnd_usb_release_resource(device_t dev, device_t child, int type,
/* Delegate to our parent device's bus if the requested resource type /* Delegate to our parent device's bus if the requested resource type
* isn't handled locally. */ * isn't handled locally. */
if (type != SYS_RES_MEMORY) { if (type != SYS_RES_MEMORY) {
return (bus_generic_rl_release_resource(dev, child, type, rid, return (bus_generic_rl_release_resource(dev, child, r));
r));
} }
error = bus_generic_rman_release_resource(dev, child, type, rid, r); error = bus_generic_rman_release_resource(dev, child, r);
if (error != 0) if (error != 0)
return (error); return (error);
if (!passthrough) { if (!passthrough) {
/* Clean resource list entry */ /* Clean resource list entry */
rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child), rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child),
type, rid); rman_get_type(r), rman_get_rid(r));
if (rle != NULL) if (rle != NULL)
rle->res = NULL; rle->res = NULL;
} }

View file

@ -116,8 +116,7 @@ fman_activate_resource(device_t bus, device_t child, struct resource *res)
} }
int int
fman_release_resource(device_t bus, device_t child, int type, int rid, fman_release_resource(device_t bus, device_t child, struct resource *res)
struct resource *res)
{ {
struct resource_list *rl; struct resource_list *rl;
struct resource_list_entry *rle; struct resource_list_entry *rle;
@ -125,9 +124,9 @@ fman_release_resource(device_t bus, device_t child, int type, int rid,
passthrough = (device_get_parent(child) != bus); passthrough = (device_get_parent(child) != bus);
rl = BUS_GET_RESOURCE_LIST(bus, child); rl = BUS_GET_RESOURCE_LIST(bus, child);
if (type != SYS_RES_IRQ) { if (rman_get_type(res) != SYS_RES_IRQ) {
if ((rman_get_flags(res) & RF_ACTIVE) != 0 ){ if ((rman_get_flags(res) & RF_ACTIVE) != 0 ){
rv = bus_deactivate_resource(child, type, rid, res); rv = bus_deactivate_resource(child, res);
if (rv != 0) if (rv != 0)
return (rv); return (rv);
} }
@ -135,7 +134,8 @@ fman_release_resource(device_t bus, device_t child, int type, int rid,
if (rv != 0) if (rv != 0)
return (rv); return (rv);
if (!passthrough) { if (!passthrough) {
rle = resource_list_find(rl, type, rid); rle = resource_list_find(rl, rman_get_type(res),
rman_get_rid(res));
KASSERT(rle != NULL, KASSERT(rle != NULL,
("%s: resource entry not found!", __func__)); ("%s: resource entry not found!", __func__));
KASSERT(rle->res != NULL, KASSERT(rle->res != NULL,
@ -144,7 +144,7 @@ fman_release_resource(device_t bus, device_t child, int type, int rid,
} }
return (0); return (0);
} }
return (resource_list_release(rl, bus, child, type, rid, res)); return (resource_list_release(rl, bus, child, res));
} }
struct resource * struct resource *

View file

@ -57,8 +57,7 @@ struct resource * fman_alloc_resource(device_t bus, device_t child, int type,
int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags);
int fman_activate_resource(device_t bus, device_t child, int fman_activate_resource(device_t bus, device_t child,
struct resource *res); struct resource *res);
int fman_release_resource(device_t bus, device_t child, int type, int rid, int fman_release_resource(device_t bus, device_t child, struct resource *res);
struct resource *res);
int fman_attach(device_t dev); int fman_attach(device_t dev);
int fman_detach(device_t dev); int fman_detach(device_t dev);
int fman_suspend(device_t dev); int fman_suspend(device_t dev);

View file

@ -356,16 +356,14 @@ dpaa2_mc_adjust_resource(device_t mcdev, device_t child,
} }
int int
dpaa2_mc_release_resource(device_t mcdev, device_t child, int type, int rid, dpaa2_mc_release_resource(device_t mcdev, device_t child, struct resource *r)
struct resource *r)
{ {
struct rman *rm; struct rman *rm;
rm = dpaa2_mc_rman(mcdev, type, rman_get_flags(r)); rm = dpaa2_mc_rman(mcdev, rman_get_type(r), rman_get_flags(r));
if (rm) if (rm)
return (bus_generic_rman_release_resource(mcdev, child, type, return (bus_generic_rman_release_resource(mcdev, child, r));
rid, r)); return (bus_generic_release_resource(mcdev, child, r));
return (bus_generic_release_resource(mcdev, child, type, rid, r));
} }
int int

View file

@ -185,8 +185,8 @@ struct resource * dpaa2_mc_alloc_resource(device_t mcdev, device_t child,
u_int flags); u_int flags);
int dpaa2_mc_adjust_resource(device_t mcdev, device_t child, int dpaa2_mc_adjust_resource(device_t mcdev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end); struct resource *r, rman_res_t start, rman_res_t end);
int dpaa2_mc_release_resource(device_t mcdev, device_t child, int type, int dpaa2_mc_release_resource(device_t mcdev, device_t child,
int rid, struct resource *r); struct resource *r);
int dpaa2_mc_activate_resource(device_t mcdev, device_t child, int dpaa2_mc_activate_resource(device_t mcdev, device_t child,
struct resource *r); struct resource *r);
int dpaa2_mc_deactivate_resource(device_t mcdev, device_t child, int dpaa2_mc_deactivate_resource(device_t mcdev, device_t child,

View file

@ -263,19 +263,18 @@ dpaa2_rc_alloc_resource(device_t rcdev, device_t child, int type, int *rid,
} }
static int static int
dpaa2_rc_release_resource(device_t rcdev, device_t child, int type, int rid, dpaa2_rc_release_resource(device_t rcdev, device_t child, struct resource *r)
struct resource *r)
{ {
struct resource_list *rl; struct resource_list *rl;
struct dpaa2_devinfo *dinfo; struct dpaa2_devinfo *dinfo;
if (device_get_parent(child) != rcdev) if (device_get_parent(child) != rcdev)
return (BUS_RELEASE_RESOURCE(device_get_parent(rcdev), child, return (BUS_RELEASE_RESOURCE(device_get_parent(rcdev), child,
type, rid, r)); r));
dinfo = device_get_ivars(child); dinfo = device_get_ivars(child);
rl = &dinfo->resources; rl = &dinfo->resources;
return (resource_list_release(rl, rcdev, child, type, rid, r)); return (resource_list_release(rl, rcdev, child, r));
} }
static void static void

View file

@ -46,8 +46,6 @@
static int simplebus_probe(device_t dev); static int simplebus_probe(device_t dev);
static struct resource *simplebus_alloc_resource(device_t, device_t, int, static struct resource *simplebus_alloc_resource(device_t, device_t, int,
int *, rman_res_t, rman_res_t, rman_res_t, u_int); int *, rman_res_t, rman_res_t, rman_res_t, u_int);
static int simplebus_release_resource(device_t bus, device_t child,
int type, int rid, struct resource *r);
static void simplebus_probe_nomatch(device_t bus, device_t child); static void simplebus_probe_nomatch(device_t bus, device_t child);
static int simplebus_print_child(device_t bus, device_t child); static int simplebus_print_child(device_t bus, device_t child);
static device_t simplebus_add_child(device_t dev, u_int order, static device_t simplebus_add_child(device_t dev, u_int order,
@ -85,7 +83,7 @@ static device_method_t simplebus_methods[] = {
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
DEVMETHOD(bus_alloc_resource, simplebus_alloc_resource), DEVMETHOD(bus_alloc_resource, simplebus_alloc_resource),
DEVMETHOD(bus_release_resource, simplebus_release_resource), DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
@ -485,16 +483,6 @@ simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
count, flags)); count, flags));
} }
static int
simplebus_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
if (type == SYS_RES_IOPORT)
type = SYS_RES_MEMORY;
return (bus_generic_release_resource(bus, child, type, rid, r));
}
static int static int
simplebus_print_res(struct simplebus_devinfo *di) simplebus_print_res(struct simplebus_devinfo *di)
{ {

View file

@ -1725,19 +1725,18 @@ vmbus_pcib_adjust_resource(device_t dev, device_t child,
} }
static int static int
vmbus_pcib_release_resource(device_t dev, device_t child, int type, int rid, vmbus_pcib_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
struct vmbus_pcib_softc *sc = device_get_softc(dev); struct vmbus_pcib_softc *sc = device_get_softc(dev);
if (type == PCI_RES_BUS) switch (rman_get_type(r)) {
return (pci_domain_release_bus(sc->hbus->pci_domain, child, case PCI_RES_BUS:
rid, r)); return (pci_domain_release_bus(sc->hbus->pci_domain, child, r));
case SYS_RES_IOPORT:
if (type == SYS_RES_IOPORT)
return (EINVAL); return (EINVAL);
default:
return (bus_generic_release_resource(dev, child, type, rid, r)); return (bus_generic_release_resource(dev, child, r));
}
} }
static int static int

View file

@ -422,16 +422,15 @@ mvs_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
static int static int
mvs_release_resource(device_t dev, device_t child, int type, int rid, mvs_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
switch (type) { switch (rman_get_type(r)) {
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
rman_release_resource(r); rman_release_resource(r);
return (0); return (0);
case SYS_RES_IRQ: case SYS_RES_IRQ:
if (rid != ATA_IRQ_RID) if (rman_get_rid(r) != ATA_IRQ_RID)
return ENOENT; return ENOENT;
return (0); return (0);
} }

View file

@ -366,11 +366,10 @@ mvs_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
static int static int
mvs_release_resource(device_t dev, device_t child, int type, int rid, mvs_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
switch (type) { switch (rman_get_type(r)) {
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
rman_release_resource(r); rman_release_resource(r);
return (0); return (0);

View file

@ -67,8 +67,7 @@
static struct rman *ofw_pcib_get_rman(device_t, int, u_int); static struct rman *ofw_pcib_get_rman(device_t, int, u_int);
static struct resource * ofw_pcib_alloc_resource(device_t, device_t, static struct resource * ofw_pcib_alloc_resource(device_t, device_t,
int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); int, int *, rman_res_t, rman_res_t, rman_res_t, u_int);
static int ofw_pcib_release_resource(device_t, device_t, int, int, static int ofw_pcib_release_resource(device_t, device_t, struct resource *);
struct resource *);
static int ofw_pcib_activate_resource(device_t, device_t, struct resource *); static int ofw_pcib_activate_resource(device_t, device_t, struct resource *);
static int ofw_pcib_deactivate_resource(device_t, device_t, struct resource *); static int ofw_pcib_deactivate_resource(device_t, device_t, struct resource *);
static int ofw_pcib_adjust_resource(device_t, device_t, static int ofw_pcib_adjust_resource(device_t, device_t,
@ -444,27 +443,23 @@ ofw_pcib_alloc_resource(device_t bus, device_t child, int type, int *rid,
} }
static int static int
ofw_pcib_release_resource(device_t bus, device_t child, int type, int rid, ofw_pcib_release_resource(device_t bus, device_t child, struct resource *res)
struct resource *res)
{ {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS) #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
struct ofw_pci_softc *sc; struct ofw_pci_softc *sc;
sc = device_get_softc(bus); sc = device_get_softc(bus);
#endif #endif
switch (type) { switch (rman_get_type(res)) {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS) #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
case PCI_RES_BUS: case PCI_RES_BUS:
return (pci_domain_release_bus(sc->sc_pci_domain, child, rid, return (pci_domain_release_bus(sc->sc_pci_domain, child, res));
res));
#endif #endif
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
return (bus_generic_rman_release_resource(bus, child, type, rid, return (bus_generic_rman_release_resource(bus, child, res));
res));
default: default:
return (bus_generic_release_resource(bus, child, type, rid, return (bus_generic_release_resource(bus, child, res));
res));
} }
} }

View file

@ -170,8 +170,7 @@ ofwbus_alloc_resource(device_t bus, device_t child, int type, int *rid,
} }
static int static int
ofwbus_release_resource(device_t bus, device_t child, int type, ofwbus_release_resource(device_t bus, device_t child, struct resource *r)
int rid, struct resource *r)
{ {
struct resource_list_entry *rle; struct resource_list_entry *rle;
bool passthrough; bool passthrough;
@ -180,11 +179,11 @@ ofwbus_release_resource(device_t bus, device_t child, int type,
if (!passthrough) { if (!passthrough) {
/* Clean resource list entry */ /* Clean resource list entry */
rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child), rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child),
type, rid); rman_get_type(r), rman_get_rid(r));
if (rle != NULL) if (rle != NULL)
rle->res = NULL; rle->res = NULL;
} }
/* Let nexus handle the release. */ /* Let nexus handle the release. */
return (bus_generic_release_resource(bus, child, type, rid, r)); return (bus_generic_release_resource(bus, child, r));
} }

View file

@ -162,7 +162,7 @@ static struct resource *cbb_cardbus_alloc_resource(device_t brdev,
device_t child, int type, int *rid, rman_res_t start, device_t child, int type, int *rid, rman_res_t start,
rman_res_t end, rman_res_t count, u_int flags); rman_res_t end, rman_res_t count, u_int flags);
static int cbb_cardbus_release_resource(device_t brdev, device_t child, static int cbb_cardbus_release_resource(device_t brdev, device_t child,
int type, int rid, struct resource *res); struct resource *res);
static int cbb_cardbus_power_enable_socket(device_t brdev, static int cbb_cardbus_power_enable_socket(device_t brdev,
device_t child); device_t child);
static int cbb_cardbus_power_disable_socket(device_t brdev, static int cbb_cardbus_power_disable_socket(device_t brdev,
@ -1263,20 +1263,20 @@ cbb_cardbus_alloc_resource(device_t brdev, device_t child, int type,
} }
static int static int
cbb_cardbus_release_resource(device_t brdev, device_t child, int type, cbb_cardbus_release_resource(device_t brdev, device_t child,
int rid, struct resource *res) struct resource *res)
{ {
struct cbb_softc *sc = device_get_softc(brdev); struct cbb_softc *sc = device_get_softc(brdev);
int error; int error;
if (rman_get_flags(res) & RF_ACTIVE) { if (rman_get_flags(res) & RF_ACTIVE) {
error = bus_deactivate_resource(child, type, rid, res); error = bus_deactivate_resource(child, res);
if (error != 0) if (error != 0)
return (error); return (error);
} }
cbb_remove_res(sc, res); cbb_remove_res(sc, res);
return (BUS_RELEASE_RESOURCE(device_get_parent(brdev), child, return (BUS_RELEASE_RESOURCE(device_get_parent(brdev), child,
type, rid, res)); res));
} }
/************************************************************************/ /************************************************************************/
@ -1424,20 +1424,20 @@ cbb_pcic_alloc_resource(device_t brdev, device_t child, int type, int *rid,
} }
static int static int
cbb_pcic_release_resource(device_t brdev, device_t child, int type, cbb_pcic_release_resource(device_t brdev, device_t child,
int rid, struct resource *res) struct resource *res)
{ {
struct cbb_softc *sc = device_get_softc(brdev); struct cbb_softc *sc = device_get_softc(brdev);
int error; int error;
if (rman_get_flags(res) & RF_ACTIVE) { if (rman_get_flags(res) & RF_ACTIVE) {
error = bus_deactivate_resource(child, type, rid, res); error = bus_deactivate_resource(child, res);
if (error != 0) if (error != 0)
return (error); return (error);
} }
cbb_remove_res(sc, res); cbb_remove_res(sc, res);
return (BUS_RELEASE_RESOURCE(device_get_parent(brdev), child, return (BUS_RELEASE_RESOURCE(device_get_parent(brdev), child,
type, rid, res)); res));
} }
/************************************************************************/ /************************************************************************/
@ -1519,17 +1519,14 @@ cbb_alloc_resource(device_t brdev, device_t child, int type, int *rid,
} }
int int
cbb_release_resource(device_t brdev, device_t child, int type, int rid, cbb_release_resource(device_t brdev, device_t child, struct resource *r)
struct resource *r)
{ {
struct cbb_softc *sc = device_get_softc(brdev); struct cbb_softc *sc = device_get_softc(brdev);
if (sc->flags & CBB_16BIT_CARD) if (sc->flags & CBB_16BIT_CARD)
return (cbb_pcic_release_resource(brdev, child, type, return (cbb_pcic_release_resource(brdev, child, r));
rid, r));
else else
return (cbb_cardbus_release_resource(brdev, child, type, return (cbb_cardbus_release_resource(brdev, child, r));
rid, r));
} }
int int

View file

@ -818,24 +818,23 @@ cbb_pci_adjust_resource(device_t bus, device_t child,
} }
static int static int
cbb_pci_release_resource(device_t bus, device_t child, int type, int rid, cbb_pci_release_resource(device_t bus, device_t child, struct resource *r)
struct resource *r)
{ {
struct cbb_softc *sc; struct cbb_softc *sc;
int error; int error;
sc = device_get_softc(bus); sc = device_get_softc(bus);
if (type == PCI_RES_BUS) { if (rman_get_type(r) == PCI_RES_BUS) {
if (!rman_is_region_manager(r, &sc->bus.rman)) if (!rman_is_region_manager(r, &sc->bus.rman))
return (EINVAL); return (EINVAL);
if (rman_get_flags(r) & RF_ACTIVE) { if (rman_get_flags(r) & RF_ACTIVE) {
error = bus_deactivate_resource(child, type, rid, r); error = bus_deactivate_resource(child, r);
if (error) if (error)
return (error); return (error);
} }
return (rman_release_resource(r)); return (rman_release_resource(r));
} }
return (cbb_release_resource(bus, child, type, rid, r)); return (cbb_release_resource(bus, child, r));
} }
#endif #endif

View file

@ -130,7 +130,7 @@ int cbb_power_disable_socket(device_t brdev, device_t child);
int cbb_read_ivar(device_t brdev, device_t child, int which, int cbb_read_ivar(device_t brdev, device_t child, int which,
uintptr_t *result); uintptr_t *result);
int cbb_release_resource(device_t brdev, device_t child, int cbb_release_resource(device_t brdev, device_t child,
int type, int rid, struct resource *r); struct resource *r);
int cbb_setup_intr(device_t dev, device_t child, struct resource *irq, int cbb_setup_intr(device_t dev, device_t child, struct resource *irq,
int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg,
void **cookiep); void **cookiep);

View file

@ -106,11 +106,10 @@ pci_hostb_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
static int static int
pci_hostb_release_resource(device_t dev, device_t child, int type, int rid, pci_hostb_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
return (bus_release_resource(dev, type, rid, r)); return (bus_release_resource(dev, r));
} }
/* PCI interface. */ /* PCI interface. */

View file

@ -55,7 +55,7 @@ static struct resource * isab_pci_alloc_resource(device_t dev,
device_t child, int type, int *rid, rman_res_t start, rman_res_t end, device_t child, int type, int *rid, rman_res_t start, rman_res_t end,
rman_res_t count, u_int flags); rman_res_t count, u_int flags);
static int isab_pci_release_resource(device_t dev, device_t child, static int isab_pci_release_resource(device_t dev, device_t child,
int type, int rid, struct resource *r); struct resource *r);
static device_method_t isab_methods[] = { static device_method_t isab_methods[] = {
/* Device interface */ /* Device interface */
@ -199,23 +199,22 @@ isab_pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
static int static int
isab_pci_release_resource(device_t dev, device_t child, int type, int rid, isab_pci_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
struct isab_pci_softc *sc; struct isab_pci_softc *sc;
int bar, error; int bar, error;
if (device_get_parent(child) != dev) if (device_get_parent(child) != dev)
return bus_generic_release_resource(dev, child, type, rid, r); return bus_generic_release_resource(dev, child, r);
switch (type) { switch (rman_get_type(r)) {
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
/* /*
* For BARs, we release the resource from the PCI bus * For BARs, we release the resource from the PCI bus
* when the last child reference goes away. * when the last child reference goes away.
*/ */
bar = PCI_RID2BAR(rid); bar = PCI_RID2BAR(rman_get_rid(r));
if (bar < 0 || bar > PCIR_MAX_BAR_0) if (bar < 0 || bar > PCIR_MAX_BAR_0)
return (EINVAL); return (EINVAL);
sc = device_get_softc(dev); sc = device_get_softc(dev);
@ -229,7 +228,7 @@ isab_pci_release_resource(device_t dev, device_t child, int type, int rid,
} }
KASSERT(sc->isab_pci_res[bar].ip_refs > 0, KASSERT(sc->isab_pci_res[bar].ip_refs > 0,
("isa_pci resource reference count underflow")); ("isa_pci resource reference count underflow"));
error = bus_release_resource(dev, type, rid, r); error = bus_release_resource(dev, r);
if (error == 0) { if (error == 0) {
sc->isab_pci_res[bar].ip_res = NULL; sc->isab_pci_res[bar].ip_res = NULL;
sc->isab_pci_res[bar].ip_refs = 0; sc->isab_pci_res[bar].ip_refs = 0;
@ -237,6 +236,5 @@ isab_pci_release_resource(device_t dev, device_t child, int type, int rid,
return (error); return (error);
} }
return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, type, return (bus_generic_release_resource(dev, child, r));
rid, r));
} }

View file

@ -5636,29 +5636,26 @@ pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
int int
pci_release_resource(device_t dev, device_t child, int type, int rid, pci_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
struct pci_devinfo *dinfo; struct pci_devinfo *dinfo;
struct resource_list *rl; struct resource_list *rl;
pcicfgregs *cfg __unused; pcicfgregs *cfg __unused;
if (device_get_parent(child) != dev) if (device_get_parent(child) != dev)
return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, return (bus_generic_release_resource(dev, child, r));
type, rid, r));
dinfo = device_get_ivars(child); dinfo = device_get_ivars(child);
cfg = &dinfo->cfg; cfg = &dinfo->cfg;
#ifdef PCI_IOV #ifdef PCI_IOV
if (cfg->flags & PCICFG_VF) { if (cfg->flags & PCICFG_VF) {
switch (type) { switch (rman_get_type(r)) {
/* VFs can't have I/O BARs. */ /* VFs can't have I/O BARs. */
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
return (EDOOFUS); return (EDOOFUS);
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
return (pci_vf_release_mem_resource(dev, child, rid, return (pci_vf_release_mem_resource(dev, child, r));
r));
} }
/* Fall through for other types of resource allocations. */ /* Fall through for other types of resource allocations. */
@ -5671,19 +5668,19 @@ pci_release_resource(device_t dev, device_t child, int type, int rid,
* those allocations just pass the request up the tree. * those allocations just pass the request up the tree.
*/ */
if (cfg->hdrtype == PCIM_HDRTYPE_BRIDGE && if (cfg->hdrtype == PCIM_HDRTYPE_BRIDGE &&
(type == SYS_RES_IOPORT || type == SYS_RES_MEMORY)) { (rman_get_type(r) == SYS_RES_IOPORT ||
switch (rid) { rman_get_type(r) == SYS_RES_MEMORY)) {
switch (rman_get_rid(r)) {
case PCIR_IOBASEL_1: case PCIR_IOBASEL_1:
case PCIR_MEMBASE_1: case PCIR_MEMBASE_1:
case PCIR_PMBASEL_1: case PCIR_PMBASEL_1:
return (bus_generic_release_resource(dev, child, type, return (bus_generic_release_resource(dev, child, r));
rid, r));
} }
} }
#endif #endif
rl = &dinfo->resources; rl = &dinfo->resources;
return (resource_list_release(rl, dev, child, type, rid, r)); return (resource_list_release(rl, dev, child, r));
} }
int int

View file

@ -436,26 +436,24 @@ generic_pcie_get_rman(device_t dev, int type, u_int flags)
} }
int int
pci_host_generic_core_release_resource(device_t dev, device_t child, int type, pci_host_generic_core_release_resource(device_t dev, device_t child,
int rid, struct resource *res) struct resource *res)
{ {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS) #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
struct generic_pcie_core_softc *sc; struct generic_pcie_core_softc *sc;
sc = device_get_softc(dev); sc = device_get_softc(dev);
#endif #endif
switch (type) { switch (rman_get_type(res)) {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS) #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
case PCI_RES_BUS: case PCI_RES_BUS:
return (pci_domain_release_bus(sc->ecam, child, rid, res)); return (pci_domain_release_bus(sc->ecam, child, res));
#endif #endif
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
return (bus_generic_rman_release_resource(dev, child, type, rid, return (bus_generic_rman_release_resource(dev, child, res));
res));
default: default:
return (bus_generic_release_resource(dev, child, type, rid, return (bus_generic_release_resource(dev, child, res));
res));
} }
} }

View file

@ -95,7 +95,7 @@ int pci_host_generic_core_attach(device_t);
int pci_host_generic_core_detach(device_t); int pci_host_generic_core_detach(device_t);
struct resource *pci_host_generic_core_alloc_resource(device_t, device_t, int, struct resource *pci_host_generic_core_alloc_resource(device_t, device_t, int,
int *, rman_res_t, rman_res_t, rman_res_t, u_int); int *, rman_res_t, rman_res_t, rman_res_t, u_int);
int pci_host_generic_core_release_resource(device_t, device_t, int, int, int pci_host_generic_core_release_resource(device_t, device_t,
struct resource *); struct resource *);
#endif /* __PCI_HOST_GENERIC_H_ */ #endif /* __PCI_HOST_GENERIC_H_ */

View file

@ -778,9 +778,7 @@ pci_iov_config(struct cdev *cdev, struct pci_iov_arg *arg)
for (i = 0; i <= PCIR_MAX_BAR_0; i++) { for (i = 0; i <= PCIR_MAX_BAR_0; i++) {
if (iov->iov_bar[i].res != NULL) { if (iov->iov_bar[i].res != NULL) {
pci_release_resource(bus, dev, SYS_RES_MEMORY, pci_release_resource(bus, dev, iov->iov_bar[i].res);
iov->iov_pos + PCIR_SRIOV_BAR(i),
iov->iov_bar[i].res);
pci_delete_resource(bus, dev, SYS_RES_MEMORY, pci_delete_resource(bus, dev, SYS_RES_MEMORY,
iov->iov_pos + PCIR_SRIOV_BAR(i)); iov->iov_pos + PCIR_SRIOV_BAR(i));
iov->iov_bar[i].res = NULL; iov->iov_bar[i].res = NULL;
@ -890,9 +888,7 @@ pci_iov_delete_iov_children(struct pci_devinfo *dinfo)
for (i = 0; i <= PCIR_MAX_BAR_0; i++) { for (i = 0; i <= PCIR_MAX_BAR_0; i++) {
if (iov->iov_bar[i].res != NULL) { if (iov->iov_bar[i].res != NULL) {
pci_release_resource(bus, dev, SYS_RES_MEMORY, pci_release_resource(bus, dev, iov->iov_bar[i].res);
iov->iov_pos + PCIR_SRIOV_BAR(i),
iov->iov_bar[i].res);
pci_delete_resource(bus, dev, SYS_RES_MEMORY, pci_delete_resource(bus, dev, SYS_RES_MEMORY,
iov->iov_pos + PCIR_SRIOV_BAR(i)); iov->iov_pos + PCIR_SRIOV_BAR(i));
iov->iov_bar[i].res = NULL; iov->iov_bar[i].res = NULL;
@ -1066,21 +1062,21 @@ pci_vf_alloc_mem_resource(device_t dev, device_t child, int *rid,
} }
int int
pci_vf_release_mem_resource(device_t dev, device_t child, int rid, pci_vf_release_mem_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
struct pci_devinfo *dinfo; struct pci_devinfo *dinfo;
struct resource_list_entry *rle; struct resource_list_entry *rle;
int error; int error, rid;
dinfo = device_get_ivars(child); dinfo = device_get_ivars(child);
if (rman_get_flags(r) & RF_ACTIVE) { if (rman_get_flags(r) & RF_ACTIVE) {
error = bus_deactivate_resource(child, SYS_RES_MEMORY, rid, r); error = bus_deactivate_resource(child, r);
if (error != 0) if (error != 0)
return (error); return (error);
} }
rid = rman_get_rid(r);
rle = resource_list_find(&dinfo->resources, SYS_RES_MEMORY, rid); rle = resource_list_find(&dinfo->resources, SYS_RES_MEMORY, rid);
if (rle != NULL) { if (rle != NULL) {
rle->res = NULL; rle->res = NULL;

View file

@ -2440,8 +2440,7 @@ pcib_adjust_resource(device_t bus, device_t child, struct resource *r,
} }
static int static int
pcib_release_resource(device_t dev, device_t child, int type, int rid, pcib_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
struct pcib_softc *sc; struct pcib_softc *sc;
int error; int error;
@ -2449,13 +2448,13 @@ pcib_release_resource(device_t dev, device_t child, int type, int rid,
sc = device_get_softc(dev); sc = device_get_softc(dev);
if (pcib_is_resource_managed(sc, r)) { if (pcib_is_resource_managed(sc, r)) {
if (rman_get_flags(r) & RF_ACTIVE) { if (rman_get_flags(r) & RF_ACTIVE) {
error = bus_deactivate_resource(child, type, rid, r); error = bus_deactivate_resource(child, r);
if (error) if (error)
return (error); return (error);
} }
return (rman_release_resource(r)); return (rman_release_resource(r));
} }
return (bus_generic_release_resource(dev, child, type, rid, r)); return (bus_generic_release_resource(dev, child, r));
} }
static int static int

View file

@ -117,8 +117,8 @@ int pci_msix_table_bar_method(device_t dev, device_t child);
struct resource *pci_alloc_resource(device_t dev, device_t child, struct resource *pci_alloc_resource(device_t dev, device_t child,
int type, int *rid, rman_res_t start, rman_res_t end, int type, int *rid, rman_res_t start, rman_res_t end,
rman_res_t count, u_int flags); rman_res_t count, u_int flags);
int pci_release_resource(device_t dev, device_t child, int type, int pci_release_resource(device_t dev, device_t child,
int rid, struct resource *r); struct resource *r);
int pci_activate_resource(device_t dev, device_t child, int pci_activate_resource(device_t dev, device_t child,
struct resource *r); struct resource *r);
int pci_deactivate_resource(device_t dev, device_t child, int pci_deactivate_resource(device_t dev, device_t child,
@ -183,5 +183,5 @@ struct resource *pci_vf_alloc_mem_resource(device_t dev, device_t child,
int *rid, rman_res_t start, rman_res_t end, int *rid, rman_res_t start, rman_res_t end,
rman_res_t count, u_int flags); rman_res_t count, u_int flags);
int pci_vf_release_mem_resource(device_t dev, device_t child, int pci_vf_release_mem_resource(device_t dev, device_t child,
int rid, struct resource *r); struct resource *r);
#endif /* _PCI_PRIVATE_H_ */ #endif /* _PCI_PRIVATE_H_ */

View file

@ -366,7 +366,7 @@ pci_domain_adjust_bus(int domain, device_t dev, struct resource *r,
} }
int int
pci_domain_release_bus(int domain, device_t dev, int rid, struct resource *r) pci_domain_release_bus(int domain, device_t dev, struct resource *r)
{ {
#ifdef INVARIANTS #ifdef INVARIANTS
struct pci_domain *d; struct pci_domain *d;

View file

@ -158,7 +158,7 @@ struct resource *pci_domain_alloc_bus(int domain, device_t dev, int *rid,
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); rman_res_t start, rman_res_t end, rman_res_t count, u_int flags);
int pci_domain_adjust_bus(int domain, device_t dev, int pci_domain_adjust_bus(int domain, device_t dev,
struct resource *r, rman_res_t start, rman_res_t end); struct resource *r, rman_res_t start, rman_res_t end);
int pci_domain_release_bus(int domain, device_t dev, int rid, int pci_domain_release_bus(int domain, device_t dev,
struct resource *r); struct resource *r);
int pci_domain_activate_bus(int domain, device_t dev, int pci_domain_activate_bus(int domain, device_t dev,
struct resource *r); struct resource *r);

View file

@ -69,8 +69,8 @@ static struct vga_resource *lookup_res(struct vga_pci_softc *sc, int rid);
static struct resource *vga_pci_alloc_resource(device_t dev, device_t child, static struct resource *vga_pci_alloc_resource(device_t dev, device_t child,
int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count,
u_int flags); u_int flags);
static int vga_pci_release_resource(device_t dev, device_t child, int type, static int vga_pci_release_resource(device_t dev, device_t child,
int rid, struct resource *r); struct resource *r);
int vga_pci_default_unit = -1; int vga_pci_default_unit = -1;
SYSCTL_INT(_hw_pci, OID_AUTO, default_vgapci_unit, CTLFLAG_RDTUN, SYSCTL_INT(_hw_pci, OID_AUTO, default_vgapci_unit, CTLFLAG_RDTUN,
@ -241,8 +241,7 @@ vga_pci_map_bios(device_t dev, size_t *size)
rom_addr |= rman_get_start(res) | 0x1; rom_addr |= rman_get_start(res) | 0x1;
pci_write_config(dev, rid, rom_addr, 4); pci_write_config(dev, rid, rom_addr, 4);
vr = lookup_res(device_get_softc(dev), rid); vr = lookup_res(device_get_softc(dev), rid);
vga_pci_release_resource(dev, NULL, SYS_RES_MEMORY, rid, vga_pci_release_resource(dev, NULL, vr->vr_res);
vr->vr_res);
/* /*
* re-allocate * re-allocate
@ -265,8 +264,7 @@ vga_pci_map_bios(device_t dev, size_t *size)
return (__DEVOLATILE(void *, bios)); return (__DEVOLATILE(void *, bios));
device_printf(dev, "ROM mapping failed\n"); device_printf(dev, "ROM mapping failed\n");
vr = lookup_res(device_get_softc(dev), rid); vr = lookup_res(device_get_softc(dev), rid);
vga_pci_release_resource(dev, NULL, SYS_RES_MEMORY, rid, vga_pci_release_resource(dev, NULL, vr->vr_res);
vr->vr_res);
return (NULL); return (NULL);
} }
@ -309,8 +307,7 @@ vga_pci_unmap_bios(device_t dev, void *bios)
KASSERT(vr->vr_res != NULL, ("vga_pci_unmap_bios: bios not mapped")); KASSERT(vr->vr_res != NULL, ("vga_pci_unmap_bios: bios not mapped"));
KASSERT(rman_get_virtual(vr->vr_res) == bios, KASSERT(rman_get_virtual(vr->vr_res) == bios,
("vga_pci_unmap_bios: mismatch")); ("vga_pci_unmap_bios: mismatch"));
vga_pci_release_resource(dev, NULL, SYS_RES_MEMORY, rid, vga_pci_release_resource(dev, NULL, vr->vr_res);
vr->vr_res);
} }
int int
@ -478,20 +475,19 @@ vga_pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
static int static int
vga_pci_release_resource(device_t dev, device_t child, int type, int rid, vga_pci_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
struct vga_resource *vr; struct vga_resource *vr;
int error; int error;
switch (type) { switch (rman_get_type(r)) {
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
/* /*
* For BARs, we release the resource from the PCI bus * For BARs, we release the resource from the PCI bus
* when the last child reference goes away. * when the last child reference goes away.
*/ */
vr = lookup_res(device_get_softc(dev), rid); vr = lookup_res(device_get_softc(dev), rman_get_rid(r));
if (vr == NULL) if (vr == NULL)
return (EINVAL); return (EINVAL);
if (vr->vr_res == NULL) if (vr->vr_res == NULL)
@ -503,7 +499,7 @@ vga_pci_release_resource(device_t dev, device_t child, int type, int rid,
} }
KASSERT(vr->vr_refs > 0, KASSERT(vr->vr_refs > 0,
("vga_pci resource reference count underflow")); ("vga_pci resource reference count underflow"));
error = bus_release_resource(dev, type, rid, r); error = bus_release_resource(dev, r);
if (error == 0) { if (error == 0) {
vr->vr_res = NULL; vr->vr_res = NULL;
vr->vr_refs = 0; vr->vr_refs = 0;
@ -511,7 +507,7 @@ vga_pci_release_resource(device_t dev, device_t child, int type, int rid,
return (error); return (error);
} }
return (bus_release_resource(dev, type, rid, r)); return (bus_release_resource(dev, r));
} }
/* PCI interface. */ /* PCI interface. */

View file

@ -1976,22 +1976,12 @@ ppc_alloc_resource(device_t bus, device_t child, int type, int *rid,
} }
int int
ppc_release_resource(device_t bus, device_t child, int type, int rid, ppc_release_resource(device_t bus, device_t child, struct resource *r)
struct resource *r)
{ {
#ifdef INVARIANTS
struct ppc_data *ppc = DEVTOSOFTC(bus); struct ppc_data *ppc = DEVTOSOFTC(bus);
#endif
switch (type) { if (r == ppc->res_irq)
case SYS_RES_IRQ: return (0);
if (rid == 0) {
KASSERT(r == ppc->res_irq,
("ppc child IRQ resource mismatch"));
return (0);
}
break;
}
return (EINVAL); return (EINVAL);
} }

View file

@ -42,8 +42,7 @@ int ppc_exec_microseq(device_t, struct ppb_microseq **);
struct resource *ppc_alloc_resource(device_t bus, device_t child, int type, struct resource *ppc_alloc_resource(device_t bus, device_t child, int type,
int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags);
int ppc_release_resource(device_t bus, device_t child, int type, int rid, int ppc_release_resource(device_t bus, device_t child, struct resource *r);
struct resource *r);
int ppc_reset_epp(device_t); int ppc_reset_epp(device_t);
int ppc_ecp_sync(device_t); int ppc_ecp_sync(device_t);
int ppc_setmode(device_t, int); int ppc_setmode(device_t, int);

View file

@ -526,8 +526,7 @@ puc_bus_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
int int
puc_bus_release_resource(device_t dev, device_t child, int type, int rid, puc_bus_release_resource(device_t dev, device_t child, struct resource *res)
struct resource *res)
{ {
struct puc_port *port; struct puc_port *port;
device_t originator; device_t originator;
@ -542,18 +541,13 @@ puc_bus_release_resource(device_t dev, device_t child, int type, int rid,
port = device_get_ivars(child); port = device_get_ivars(child);
KASSERT(port != NULL, ("%s %d", __func__, __LINE__)); KASSERT(port != NULL, ("%s %d", __func__, __LINE__));
if (rid != 0 || res == NULL) if (res == NULL)
return (EINVAL); return (EINVAL);
if (type == port->p_bar->b_type) { if (res == port->p_ires) {
if (res != port->p_rres)
return (EINVAL);
} else if (type == SYS_RES_IRQ) {
if (res != port->p_ires)
return (EINVAL);
if (port->p_hasintr) if (port->p_hasintr)
return (EBUSY); return (EBUSY);
} else } else if (res != port->p_rres)
return (EINVAL); return (EINVAL);
if (rman_get_device(res) != originator) if (rman_get_device(res) != originator)

View file

@ -89,7 +89,7 @@ struct resource *puc_bus_alloc_resource(device_t, device_t, int, int *,
int puc_bus_get_resource(device_t, device_t, int, int, rman_res_t *, rman_res_t *); int puc_bus_get_resource(device_t, device_t, int, int, rman_res_t *, rman_res_t *);
int puc_bus_print_child(device_t, device_t); int puc_bus_print_child(device_t, device_t);
int puc_bus_read_ivar(device_t, device_t, int, uintptr_t *); int puc_bus_read_ivar(device_t, device_t, int, uintptr_t *);
int puc_bus_release_resource(device_t, device_t, int, int, struct resource *); int puc_bus_release_resource(device_t, device_t, struct resource *);
int puc_bus_setup_intr(device_t, device_t, struct resource *, int, int puc_bus_setup_intr(device_t, device_t, struct resource *, int,
driver_filter_t *, driver_intr_t *, void *, void **); driver_filter_t *, driver_intr_t *, void *, void **);
int puc_bus_teardown_intr(device_t, device_t, struct resource *, void *); int puc_bus_teardown_intr(device_t, device_t, struct resource *, void *);

View file

@ -64,7 +64,7 @@ struct resource *quicc_bus_alloc_resource(device_t, device_t, int, int *,
int quicc_bus_get_resource(device_t, device_t, int, int, int quicc_bus_get_resource(device_t, device_t, int, int,
rman_res_t *, rman_res_t *); rman_res_t *, rman_res_t *);
int quicc_bus_read_ivar(device_t, device_t, int, uintptr_t *); int quicc_bus_read_ivar(device_t, device_t, int, uintptr_t *);
int quicc_bus_release_resource(device_t, device_t, int, int, struct resource *); int quicc_bus_release_resource(device_t, device_t, struct resource *);
int quicc_bus_setup_intr(device_t, device_t, struct resource *, int, int quicc_bus_setup_intr(device_t, device_t, struct resource *, int,
driver_filter_t *, void (*)(void *), void *, void **); driver_filter_t *, void (*)(void *), void *, void **);
int quicc_bus_teardown_intr(device_t, device_t, struct resource *, void *); int quicc_bus_teardown_intr(device_t, device_t, struct resource *, void *);

View file

@ -333,8 +333,7 @@ quicc_bus_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
} }
int int
quicc_bus_release_resource(device_t dev, device_t child, int type, int rid, quicc_bus_release_resource(device_t dev, device_t child, struct resource *res)
struct resource *res)
{ {
struct quicc_device *qd; struct quicc_device *qd;
struct resource_list_entry *rle; struct resource_list_entry *rle;
@ -343,7 +342,8 @@ quicc_bus_release_resource(device_t dev, device_t child, int type, int rid,
return (EINVAL); return (EINVAL);
qd = device_get_ivars(child); qd = device_get_ivars(child);
rle = resource_list_find(&qd->qd_rlist, type, rid); rle = resource_list_find(&qd->qd_rlist, rman_get_type(res),
rman_get_rid(res));
return ((rle == NULL) ? EINVAL : 0); return ((rle == NULL) ? EINVAL : 0);
} }

View file

@ -145,7 +145,7 @@ struct resource *scc_bus_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t, u_int); rman_res_t, rman_res_t, rman_res_t, u_int);
int scc_bus_get_resource(device_t, device_t, int, int, rman_res_t *, rman_res_t *); int scc_bus_get_resource(device_t, device_t, int, int, rman_res_t *, rman_res_t *);
int scc_bus_read_ivar(device_t, device_t, int, uintptr_t *); int scc_bus_read_ivar(device_t, device_t, int, uintptr_t *);
int scc_bus_release_resource(device_t, device_t, int, int, struct resource *); int scc_bus_release_resource(device_t, device_t, struct resource *);
int scc_bus_setup_intr(device_t, device_t, struct resource *, int, int scc_bus_setup_intr(device_t, device_t, struct resource *, int,
driver_filter_t *, void (*)(void *), void *, void **); driver_filter_t *, void (*)(void *), void *, void **);
int scc_bus_teardown_intr(device_t, device_t, struct resource *, void *); int scc_bus_teardown_intr(device_t, device_t, struct resource *, void *);

View file

@ -495,8 +495,7 @@ scc_bus_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
} }
int int
scc_bus_release_resource(device_t dev, device_t child, int type, int rid, scc_bus_release_resource(device_t dev, device_t child, struct resource *res)
struct resource *res)
{ {
struct resource_list_entry *rle; struct resource_list_entry *rle;
struct scc_chan *ch; struct scc_chan *ch;
@ -507,7 +506,8 @@ scc_bus_release_resource(device_t dev, device_t child, int type, int rid,
m = device_get_ivars(child); m = device_get_ivars(child);
ch = m->m_chan; ch = m->m_chan;
rle = resource_list_find(&ch->ch_rlist, type, rid); rle = resource_list_find(&ch->ch_rlist, rman_get_type(res),
rman_get_rid(res));
return ((rle == NULL) ? EINVAL : 0); return ((rle == NULL) ? EINVAL : 0);
} }

View file

@ -346,16 +346,15 @@ siis_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
static int static int
siis_release_resource(device_t dev, device_t child, int type, int rid, siis_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
switch (type) { switch (rman_get_type(r)) {
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
rman_release_resource(r); rman_release_resource(r);
return (0); return (0);
case SYS_RES_IRQ: case SYS_RES_IRQ:
if (rid != ATA_IRQ_RID) if (rman_get_rid(r) != ATA_IRQ_RID)
return ENOENT; return ENOENT;
return (0); return (0);
} }

View file

@ -83,8 +83,7 @@ static int csa_attach(device_t dev);
static struct resource *csa_alloc_resource(device_t bus, device_t child, int type, int *rid, static struct resource *csa_alloc_resource(device_t bus, device_t child, int type, int *rid,
rman_res_t start, rman_res_t end, rman_res_t start, rman_res_t end,
rman_res_t count, u_int flags); rman_res_t count, u_int flags);
static int csa_release_resource(device_t bus, device_t child, int type, int rid, static int csa_release_resource(device_t bus, device_t child, struct resource *r);
struct resource *r);
static int csa_setup_intr(device_t bus, device_t child, static int csa_setup_intr(device_t bus, device_t child,
struct resource *irq, int flags, struct resource *irq, int flags,
driver_filter_t *filter, driver_filter_t *filter,
@ -430,8 +429,7 @@ csa_alloc_resource(device_t bus, device_t child, int type, int *rid,
} }
static int static int
csa_release_resource(device_t bus, device_t child, int type, int rid, csa_release_resource(device_t bus, device_t child, struct resource *r)
struct resource *r)
{ {
return (0); return (0);
} }

View file

@ -728,8 +728,7 @@ fm801_alloc_resource(device_t bus, device_t child, int type, int *rid,
} }
static int static int
fm801_release_resource(device_t bus, device_t child, int type, int rid, fm801_release_resource(device_t bus, device_t child, struct resource *r)
struct resource *r)
{ {
return (0); return (0);
} }

View file

@ -480,15 +480,13 @@ vmd_adjust_resource(device_t dev, device_t child,
} }
static int static int
vmd_release_resource(device_t dev, device_t child, int type, int rid, vmd_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
if (type == SYS_RES_IRQ) { if (rman_get_type(r) == SYS_RES_IRQ) {
return (bus_generic_release_resource(dev, child, type, rid, return (bus_generic_release_resource(dev, child, r));
r));
} }
return (bus_generic_rman_release_resource(dev, child, type, rid, r)); return (bus_generic_rman_release_resource(dev, child, r));
} }
static int static int

View file

@ -909,8 +909,6 @@ isa_driver_added(device_t dev, driver_t *driver)
STAILQ_FOREACH(rle, &idev->id_resources, link) { STAILQ_FOREACH(rle, &idev->id_resources, link) {
if (rle->res) if (rle->res)
resource_list_release(rl, dev, child, resource_list_release(rl, dev, child,
rle->type,
rle->rid,
rle->res); rle->res);
} }

View file

@ -72,6 +72,6 @@ extern struct resource *isa_alloc_resource(device_t bus, device_t child,
int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count,
u_int flags); u_int flags);
extern int isa_release_resource(device_t bus, device_t child, extern int isa_release_resource(device_t bus, device_t child,
int type, int rid, struct resource *r); struct resource *r);
extern driver_t isa_driver; extern driver_t isa_driver;

View file

@ -427,15 +427,11 @@ METHOD int translate_resource {
* *
* @param _dev the parent device of @p _child * @param _dev the parent device of @p _child
* @param _child the device which allocated the resource * @param _child the device which allocated the resource
* @param _type the type of resource
* @param _rid the resource identifier
* @param _r the resource to release * @param _r the resource to release
*/ */
METHOD int release_resource { METHOD int release_resource {
device_t _dev; device_t _dev;
device_t _child; device_t _child;
int _type;
int _rid;
struct resource *_res; struct resource *_res;
}; };

View file

@ -3133,8 +3133,6 @@ resource_list_alloc(struct resource_list *rl, device_t bus, device_t child,
* @param rl the resource list which was allocated from * @param rl the resource list which was allocated from
* @param bus the parent device of @p child * @param bus the parent device of @p child
* @param child the device which is requesting a release * @param child the device which is requesting a release
* @param type the type of resource to release
* @param rid the resource identifier
* @param res the resource to release * @param res the resource to release
* *
* @retval 0 success * @retval 0 success
@ -3143,7 +3141,7 @@ resource_list_alloc(struct resource_list *rl, device_t bus, device_t child,
*/ */
int int
resource_list_release(struct resource_list *rl, device_t bus, device_t child, resource_list_release(struct resource_list *rl, device_t bus, device_t child,
int type, int rid, struct resource *res) struct resource *res)
{ {
struct resource_list_entry *rle = NULL; struct resource_list_entry *rle = NULL;
int passthrough = (device_get_parent(child) != bus); int passthrough = (device_get_parent(child) != bus);
@ -3151,10 +3149,10 @@ resource_list_release(struct resource_list *rl, device_t bus, device_t child,
if (passthrough) { if (passthrough) {
return (BUS_RELEASE_RESOURCE(device_get_parent(bus), child, return (BUS_RELEASE_RESOURCE(device_get_parent(bus), child,
type, rid, res)); res));
} }
rle = resource_list_find(rl, type, rid); rle = resource_list_find(rl, rman_get_type(res), rman_get_rid(res));
if (!rle) if (!rle)
panic("resource_list_release: can't find resource"); panic("resource_list_release: can't find resource");
@ -3163,8 +3161,7 @@ resource_list_release(struct resource_list *rl, device_t bus, device_t child,
if (rle->flags & RLE_RESERVED) { if (rle->flags & RLE_RESERVED) {
if (rle->flags & RLE_ALLOCATED) { if (rle->flags & RLE_ALLOCATED) {
if (rman_get_flags(res) & RF_ACTIVE) { if (rman_get_flags(res) & RF_ACTIVE) {
error = bus_deactivate_resource(child, type, error = bus_deactivate_resource(child, res);
rid, res);
if (error) if (error)
return (error); return (error);
} }
@ -3174,8 +3171,7 @@ resource_list_release(struct resource_list *rl, device_t bus, device_t child,
return (EINVAL); return (EINVAL);
} }
error = BUS_RELEASE_RESOURCE(device_get_parent(bus), child, error = BUS_RELEASE_RESOURCE(device_get_parent(bus), child, res);
type, rid, res);
if (error) if (error)
return (error); return (error);
@ -3215,8 +3211,7 @@ resource_list_release_active(struct resource_list *rl, device_t bus,
RLE_RESERVED) RLE_RESERVED)
continue; continue;
retval = EBUSY; retval = EBUSY;
error = resource_list_release(rl, bus, child, type, error = resource_list_release(rl, bus, child, rle->res);
rman_get_rid(rle->res), rle->res);
if (error != 0) if (error != 0)
device_printf(bus, device_printf(bus,
"Failed to release active resource: %d\n", error); "Failed to release active resource: %d\n", error);
@ -3260,7 +3255,7 @@ resource_list_unreserve(struct resource_list *rl, device_t bus, device_t child,
if (rle->flags & RLE_ALLOCATED) if (rle->flags & RLE_ALLOCATED)
return (EBUSY); return (EBUSY);
rle->flags &= ~RLE_RESERVED; rle->flags &= ~RLE_RESERVED;
return (resource_list_release(rl, bus, child, type, rid, rle->res)); return (resource_list_release(rl, bus, child, rle->res));
} }
/** /**
@ -3928,13 +3923,11 @@ bus_generic_alloc_resource(device_t dev, device_t child, int type, int *rid,
* BUS_RELEASE_RESOURCE() method of the parent of @p dev. * BUS_RELEASE_RESOURCE() method of the parent of @p dev.
*/ */
int int
bus_generic_release_resource(device_t dev, device_t child, int type, int rid, bus_generic_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
/* Propagate up the bus hierarchy until someone handles it. */ /* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent) if (dev->parent)
return (BUS_RELEASE_RESOURCE(dev->parent, child, type, rid, return (BUS_RELEASE_RESOURCE(dev->parent, child, r));
r));
return (EINVAL); return (EINVAL);
} }
@ -4180,20 +4173,19 @@ bus_generic_rl_delete_resource(device_t dev, device_t child, int type, int rid)
* BUS_GET_RESOURCE_LIST() to find a suitable resource list. * BUS_GET_RESOURCE_LIST() to find a suitable resource list.
*/ */
int int
bus_generic_rl_release_resource(device_t dev, device_t child, int type, bus_generic_rl_release_resource(device_t dev, device_t child,
int rid, struct resource *r) struct resource *r)
{ {
struct resource_list * rl = NULL; struct resource_list * rl = NULL;
if (device_get_parent(child) != dev) if (device_get_parent(child) != dev)
return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, r));
type, rid, r));
rl = BUS_GET_RESOURCE_LIST(dev, child); rl = BUS_GET_RESOURCE_LIST(dev, child);
if (!rl) if (!rl)
return (EINVAL); return (EINVAL);
return (resource_list_release(rl, dev, child, type, rid, r)); return (resource_list_release(rl, dev, child, r));
} }
/** /**
@ -4284,8 +4276,8 @@ bus_generic_rman_adjust_resource(device_t dev, device_t child,
* allocated by bus_generic_rman_alloc_resource. * allocated by bus_generic_rman_alloc_resource.
*/ */
int int
bus_generic_rman_release_resource(device_t dev, device_t child, int type, bus_generic_rman_release_resource(device_t dev, device_t child,
int rid, struct resource *r) struct resource *r)
{ {
#ifdef INVARIANTS #ifdef INVARIANTS
struct rman *rm; struct rman *rm;
@ -4293,13 +4285,13 @@ bus_generic_rman_release_resource(device_t dev, device_t child, int type,
int error; int error;
#ifdef INVARIANTS #ifdef INVARIANTS
rm = BUS_GET_RMAN(dev, type, rman_get_flags(r)); rm = BUS_GET_RMAN(dev, rman_get_type(r), rman_get_flags(r));
KASSERT(rman_is_region_manager(r, rm), KASSERT(rman_is_region_manager(r, rm),
("%s: rman %p doesn't match for resource %p", __func__, rm, r)); ("%s: rman %p doesn't match for resource %p", __func__, rm, r));
#endif #endif
if (rman_get_flags(r) & RF_ACTIVE) { if (rman_get_flags(r) & RF_ACTIVE) {
error = bus_deactivate_resource(child, type, rid, r); error = bus_deactivate_resource(child, r);
if (error != 0) if (error != 0)
return (error); return (error);
} }
@ -4653,21 +4645,20 @@ bus_unmap_resource_old(device_t dev, int type, struct resource *r,
* parent of @p dev. * parent of @p dev.
*/ */
int int
bus_release_resource(device_t dev, int type, int rid, struct resource *r) bus_release_resource(device_t dev, struct resource *r)
{ {
int rv; int rv;
if (dev->parent == NULL) if (dev->parent == NULL)
return (EINVAL); return (EINVAL);
rv = BUS_RELEASE_RESOURCE(dev->parent, dev, type, rid, r); rv = BUS_RELEASE_RESOURCE(dev->parent, dev, r);
return (rv); return (rv);
} }
int int
bus_release_resource_new(device_t dev, struct resource *r) bus_release_resource_old(device_t dev, int type, int rid, struct resource *r)
{ {
return (bus_release_resource(dev, rman_get_type(r), rman_get_rid(r), return (bus_release_resource(dev, r));
r));
} }
/** /**

View file

@ -73,11 +73,10 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
} }
int int
isa_release_resource(device_t bus, device_t child, int type, int rid, isa_release_resource(device_t bus, device_t child, struct resource *r)
struct resource *r)
{ {
struct isa_device* idev = DEVTOISA(child); struct isa_device* idev = DEVTOISA(child);
struct resource_list *rl = &idev->id_resources; struct resource_list *rl = &idev->id_resources;
return (resource_list_release(rl, bus, child, type, rid, r)); return (resource_list_release(rl, bus, child, r));
} }

View file

@ -83,8 +83,7 @@ static struct resource *lbc_alloc_resource(device_t, device_t, int, int *,
static int lbc_adjust_resource(device_t, device_t, struct resource *, static int lbc_adjust_resource(device_t, device_t, struct resource *,
rman_res_t, rman_res_t); rman_res_t, rman_res_t);
static int lbc_print_child(device_t, device_t); static int lbc_print_child(device_t, device_t);
static int lbc_release_resource(device_t, device_t, int, int, static int lbc_release_resource(device_t, device_t, struct resource *);
struct resource *);
static const struct ofw_bus_devinfo *lbc_get_devinfo(device_t, device_t); static const struct ofw_bus_devinfo *lbc_get_devinfo(device_t, device_t);
/* /*
@ -776,18 +775,13 @@ lbc_adjust_resource(device_t dev, device_t child, struct resource *r,
} }
static int static int
lbc_release_resource(device_t dev, device_t child, int type, int rid, lbc_release_resource(device_t dev, device_t child, struct resource *res)
struct resource *res)
{ {
switch (type) { switch (rman_get_type(res)) {
case SYS_RES_IOPORT:
type = SYS_RES_MEMORY;
/* FALLTHROUGH */
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
return (bus_generic_rman_release_resource(dev, child, type, return (bus_generic_rman_release_resource(dev, child, res));
rid, res));
case SYS_RES_IRQ: case SYS_RES_IRQ:
return (bus_generic_release_resource(dev, child, type, rid, res)); return (bus_generic_release_resource(dev, child, res));
default: default:
return (EINVAL); return (EINVAL);
} }

View file

@ -88,8 +88,7 @@ static int macio_adjust_resource(device_t, device_t, struct resource *,
rman_res_t, rman_res_t); rman_res_t, rman_res_t);
static int macio_activate_resource(device_t, device_t, struct resource *); static int macio_activate_resource(device_t, device_t, struct resource *);
static int macio_deactivate_resource(device_t, device_t, struct resource *); static int macio_deactivate_resource(device_t, device_t, struct resource *);
static int macio_release_resource(device_t, device_t, int, int, static int macio_release_resource(device_t, device_t, struct resource *);
struct resource *);
static int macio_map_resource(device_t, device_t, struct resource *, static int macio_map_resource(device_t, device_t, struct resource *,
struct resource_map_request *, struct resource_map_request *,
struct resource_map *); struct resource_map *);
@ -610,17 +609,14 @@ macio_adjust_resource(device_t bus, device_t child, struct resource *r,
} }
static int static int
macio_release_resource(device_t bus, device_t child, int type, int rid, macio_release_resource(device_t bus, device_t child, struct resource *res)
struct resource *res)
{ {
switch (type) { switch (rman_get_type(res)) {
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
return (bus_generic_rman_release_resource(bus, child, type, rid, return (bus_generic_rman_release_resource(bus, child, res));
res));
case SYS_RES_IRQ: case SYS_RES_IRQ:
return (bus_generic_rl_release_resource(bus, child, type, rid, return (bus_generic_rl_release_resource(bus, child, res));
res));
default: default:
return (EINVAL); return (EINVAL);
} }

View file

@ -87,8 +87,7 @@ static int unin_chip_map_resource(device_t, device_t, struct resource *,
struct resource_map *); struct resource_map *);
static int unin_chip_unmap_resource(device_t, device_t, struct resource *, static int unin_chip_unmap_resource(device_t, device_t, struct resource *,
struct resource_map *); struct resource_map *);
static int unin_chip_release_resource(device_t, device_t, int, int, static int unin_chip_release_resource(device_t, device_t, struct resource *);
struct resource *);
static struct resource_list *unin_chip_get_resource_list (device_t, device_t); static struct resource_list *unin_chip_get_resource_list (device_t, device_t);
/* /*
@ -570,17 +569,14 @@ unin_chip_adjust_resource(device_t bus, device_t child, struct resource *r,
} }
static int static int
unin_chip_release_resource(device_t bus, device_t child, int type, int rid, unin_chip_release_resource(device_t bus, device_t child, struct resource *res)
struct resource *res)
{ {
switch (type) { switch (rman_get_type(res)) {
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
return (bus_generic_rman_release_resource(bus, child, type, rid, return (bus_generic_rman_release_resource(bus, child, res));
res));
case SYS_RES_IRQ: case SYS_RES_IRQ:
return (bus_generic_rl_release_resource(bus, child, type, rid, return (bus_generic_rl_release_resource(bus, child, res));
res));
default: default:
return (EINVAL); return (EINVAL);
} }

View file

@ -61,8 +61,7 @@ static int ata_iobus_print_child(device_t dev, device_t child);
struct resource *ata_iobus_alloc_resource(device_t, device_t, int, int *, struct resource *ata_iobus_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t, rman_res_t, rman_res_t, rman_res_t,
u_int); u_int);
static int ata_iobus_release_resource(device_t, device_t, int, int, static int ata_iobus_release_resource(device_t, device_t, struct resource *);
struct resource *);
static device_method_t ata_iobus_methods[] = { static device_method_t ata_iobus_methods[] = {
/* Device interface */ /* Device interface */
@ -192,8 +191,7 @@ ata_iobus_alloc_resource(device_t dev, device_t child, int type, int *rid,
} }
static int static int
ata_iobus_release_resource(device_t dev, device_t child, int type, int rid, ata_iobus_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
/* no hotplug... */ /* no hotplug... */
return (0); return (0);

View file

@ -83,8 +83,7 @@ static int iobus_map_resource(device_t, device_t, struct resource *,
struct resource_map *); struct resource_map *);
static int iobus_unmap_resource(device_t, device_t, struct resource *, static int iobus_unmap_resource(device_t, device_t, struct resource *,
struct resource_map *); struct resource_map *);
static int iobus_release_resource(device_t, device_t, int, int, static int iobus_release_resource(device_t, device_t, struct resource *);
struct resource *);
/* /*
* Bus interface definition * Bus interface definition
@ -357,17 +356,15 @@ iobus_adjust_resource(device_t bus, device_t child, struct resource *r,
} }
static int static int
iobus_release_resource(device_t bus, device_t child, int type, int rid, iobus_release_resource(device_t bus, device_t child, struct resource *res)
struct resource *res)
{ {
switch (type) { switch (rman_get_type(res)) {
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
case SYS_RES_IOPORT: case SYS_RES_IOPORT:
return (bus_generic_rman_release_resource(bus, child, type, rid, return (bus_generic_rman_release_resource(bus, child, res));
res));
case SYS_RES_IRQ: case SYS_RES_IRQ:
return (bus_generic_release_resource(bus, child, type, rid, res)); return (bus_generic_release_resource(bus, child, res));
default: default:
return (EINVAL); return (EINVAL);
} }

View file

@ -396,7 +396,7 @@ struct resource *
rman_res_t count, u_int flags); rman_res_t count, u_int flags);
int resource_list_release(struct resource_list *rl, int resource_list_release(struct resource_list *rl,
device_t bus, device_t child, device_t bus, device_t child,
int type, int rid, struct resource *res); struct resource *res);
int resource_list_release_active(struct resource_list *rl, int resource_list_release_active(struct resource_list *rl,
device_t bus, device_t child, device_t bus, device_t child,
int type); int type);
@ -481,7 +481,7 @@ int bus_generic_probe(device_t dev);
int bus_generic_read_ivar(device_t dev, device_t child, int which, int bus_generic_read_ivar(device_t dev, device_t child, int which,
uintptr_t *result); uintptr_t *result);
int bus_generic_release_resource(device_t bus, device_t child, int bus_generic_release_resource(device_t bus, device_t child,
int type, int rid, struct resource *r); struct resource *r);
int bus_generic_resume(device_t dev); int bus_generic_resume(device_t dev);
int bus_generic_resume_child(device_t dev, device_t child); int bus_generic_resume_child(device_t dev, device_t child);
int bus_generic_setup_intr(device_t dev, device_t child, int bus_generic_setup_intr(device_t dev, device_t child,
@ -497,8 +497,7 @@ int bus_generic_rl_get_resource (device_t, device_t, int, int, rman_res_t *,
rman_res_t *); rman_res_t *);
int bus_generic_rl_set_resource (device_t, device_t, int, int, rman_res_t, int bus_generic_rl_set_resource (device_t, device_t, int, int, rman_res_t,
rman_res_t); rman_res_t);
int bus_generic_rl_release_resource (device_t, device_t, int, int, int bus_generic_rl_release_resource (device_t, device_t, struct resource *);
struct resource *);
struct resource * struct resource *
bus_generic_rman_alloc_resource(device_t dev, device_t child, int type, bus_generic_rman_alloc_resource(device_t dev, device_t child, int type,
int *rid, rman_res_t start, int *rid, rman_res_t start,
@ -508,7 +507,6 @@ int bus_generic_rman_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, struct resource *r, rman_res_t start,
rman_res_t end); rman_res_t end);
int bus_generic_rman_release_resource(device_t dev, device_t child, int bus_generic_rman_release_resource(device_t dev, device_t child,
int type, int rid,
struct resource *r); struct resource *r);
int bus_generic_rman_activate_resource(device_t dev, device_t child, int bus_generic_rman_activate_resource(device_t dev, device_t child,
struct resource *r); struct resource *r);
@ -571,8 +569,7 @@ int bus_get_cpus(device_t dev, enum cpu_sets op, size_t setsize,
bus_dma_tag_t bus_get_dma_tag(device_t dev); bus_dma_tag_t bus_get_dma_tag(device_t dev);
bus_space_tag_t bus_get_bus_tag(device_t dev); bus_space_tag_t bus_get_bus_tag(device_t dev);
int bus_get_domain(device_t dev, int *domain); int bus_get_domain(device_t dev, int *domain);
int bus_release_resource(device_t dev, int type, int rid, int bus_release_resource(device_t dev, struct resource *r);
struct resource *r);
int bus_free_resource(device_t dev, int type, struct resource *r); int bus_free_resource(device_t dev, int type, struct resource *r);
int bus_setup_intr(device_t dev, struct resource *r, int flags, int bus_setup_intr(device_t dev, struct resource *r, int flags,
driver_filter_t filter, driver_intr_t handler, driver_filter_t filter, driver_intr_t handler,
@ -621,7 +618,8 @@ int bus_map_resource_old(device_t dev, int type, struct resource *r,
struct resource_map *map); struct resource_map *map);
int bus_unmap_resource_old(device_t dev, int type, struct resource *r, int bus_unmap_resource_old(device_t dev, int type, struct resource *r,
struct resource_map *map); struct resource_map *map);
int bus_release_resource_new(device_t dev, struct resource *r); int bus_release_resource_old(device_t dev, int type, int rid,
struct resource *r);
#define _BUS_API_MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME #define _BUS_API_MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME
@ -646,8 +644,8 @@ int bus_release_resource_new(device_t dev, struct resource *r);
bus_unmap_resource)(__VA_ARGS__) bus_unmap_resource)(__VA_ARGS__)
#define bus_release_resource(...) \ #define bus_release_resource(...) \
_BUS_API_MACRO(__VA_ARGS__, INVALID, bus_release_resource, \ _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_release_resource_old, \
INVALID, bus_release_resource_new)(__VA_ARGS__) INVALID, bus_release_resource)(__VA_ARGS__)
/* /*
* Access functions for device. * Access functions for device.

View file

@ -60,8 +60,8 @@ struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child,
u_int flags); u_int flags);
int legacy_pcib_adjust_resource(device_t dev, device_t child, int legacy_pcib_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end); struct resource *r, rman_res_t start, rman_res_t end);
int legacy_pcib_release_resource(device_t dev, device_t child, int type, int legacy_pcib_release_resource(device_t dev, device_t child,
int rid, struct resource *r); struct resource *r);
int legacy_pcib_activate_resource(device_t dev, device_t child, int legacy_pcib_activate_resource(device_t dev, device_t child,
struct resource *r); struct resource *r);
int legacy_pcib_deactivate_resource(device_t dev, device_t child, int legacy_pcib_deactivate_resource(device_t dev, device_t child,

View file

@ -130,13 +130,12 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
} }
int int
isa_release_resource(device_t bus, device_t child, int type, int rid, isa_release_resource(device_t bus, device_t child, struct resource *r)
struct resource *r)
{ {
struct isa_device* idev = DEVTOISA(child); struct isa_device* idev = DEVTOISA(child);
struct resource_list *rl = &idev->id_resources; struct resource_list *rl = &idev->id_resources;
return resource_list_release(rl, bus, child, type, rid, r); return resource_list_release(rl, bus, child, r);
} }
/* /*

View file

@ -617,13 +617,12 @@ legacy_pcib_adjust_resource(device_t dev, device_t child,
} }
int int
legacy_pcib_release_resource(device_t dev, device_t child, int type, int rid, legacy_pcib_release_resource(device_t dev, device_t child, struct resource *r)
struct resource *r)
{ {
if (type == PCI_RES_BUS) if (rman_get_type(r) == PCI_RES_BUS)
return (pci_domain_release_bus(0, child, rid, r)); return (pci_domain_release_bus(0, child, r));
return (bus_generic_release_resource(dev, child, type, rid, r)); return (bus_generic_release_resource(dev, child, r));
} }
int int