new-bus: Remove the 'type' argument from BUS_ADJUST_RESOURCE

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

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44128
This commit is contained in:
John Baldwin 2024-03-13 15:05:54 -07:00
parent 582b84cd25
commit fef01f0498
28 changed files with 117 additions and 152 deletions

View file

@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd April 23, 2016
.Dd March 13, 2024
.Dt BUS_ADJUST_RESOURCE 9
.Os
.Sh NAME
@ -40,7 +40,7 @@
.In machine/resource.h
.Ft int
.Fo bus_adjust_resource
.Fa "device_t dev" "int type" "struct resource *r"
.Fa "device_t dev" "struct resource *r"
.Fa "rman_res_t start" "rman_res_t end"
.Fc
.Sh DESCRIPTION
@ -52,13 +52,6 @@ should have been allocated by a previous call to
.Xr bus_alloc_resource 9 .
The new resource range must overlap the existing range of
.Fa r .
The
.Fa type
argument should match the
.Fa type
argument passed to
.Xr bus_alloc_resource 9
when the resource was initially allocated.
.Pp
Note that none of the constraints of the original allocation request such
as alignment or boundary restrictions are checked by
@ -74,8 +67,8 @@ Grow an existing memory resource by 4096 bytes.
struct resource *res;
int error;
error = bus_adjust_resource(dev, SYS_RES_MEMORY, res,
rman_get_start(res), rman_get_end(res) + 0x1000);
error = bus_adjust_resource(dev, res, rman_get_start(res),
rman_get_end(res) + 0x1000);
.Ed
.Sh ERRORS
.Fn bus_adjust_resource

View file

@ -345,7 +345,7 @@ static int mv_pcib_attach(device_t);
static struct rman *mv_pcib_get_rman(device_t, int, u_int);
static struct resource *mv_pcib_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t, u_int);
static int mv_pcib_adjust_resource(device_t, device_t, int, struct resource *,
static int mv_pcib_adjust_resource(device_t, device_t, struct resource *,
rman_res_t, rman_res_t);
static int mv_pcib_release_resource(device_t, device_t, int, int,
struct resource *);
@ -941,26 +941,25 @@ mv_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
}
static int
mv_pcib_adjust_resource(device_t dev, device_t child, int type,
mv_pcib_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
#ifdef PCI_RES_BUS
struct mv_pcib_softc *sc = device_get_softc(dev);
#endif
switch (type) {
switch (rman_get_type(r)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
return (bus_generic_rman_adjust_resource(dev, child, type, r,
start, end));
return (bus_generic_rman_adjust_resource(dev, child, r, start,
end));
#ifdef PCI_RES_BUS
case PCI_RES_BUS:
return (pci_domain_adjust_bus(sc->ap_segment, child, r, start,
end));
#endif
default:
return (bus_generic_adjust_resource(dev, child, type, r,
start, end));
return (bus_generic_adjust_resource(dev, child, r, start, end));
}
}

View file

@ -122,7 +122,7 @@
static int thunder_pem_activate_resource(device_t, device_t, int, int,
struct resource *);
static int thunder_pem_adjust_resource(device_t, device_t, int,
static int thunder_pem_adjust_resource(device_t, device_t,
struct resource *, rman_res_t, rman_res_t);
static struct resource * thunder_pem_alloc_resource(device_t, device_t, int,
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
@ -355,26 +355,26 @@ thunder_pem_unmap_resource(device_t dev, device_t child, int type,
}
static int
thunder_pem_adjust_resource(device_t dev, device_t child, int type,
struct resource *res, rman_res_t start, rman_res_t end)
thunder_pem_adjust_resource(device_t dev, device_t child, struct resource *res,
rman_res_t start, rman_res_t end)
{
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
struct thunder_pem_softc *sc;
sc = device_get_softc(dev);
#endif
switch (type) {
switch (rman_get_type(res)) {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
case PCI_RES_BUS:
return (pci_domain_adjust_bus(sc->id, child, res, start, end));
#endif
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
return (bus_generic_rman_adjust_resource(dev, child, type, res,
start, end));
return (bus_generic_rman_adjust_resource(dev, child, res, start,
end));
default:
return (bus_generic_adjust_resource(dev, child, type, res,
start, end));
return (bus_generic_adjust_resource(dev, child, res, start,
end));
}
}

View file

@ -1570,13 +1570,13 @@ acpi_managed_resource(device_t bus, int type, struct resource *r)
}
static int
acpi_adjust_resource(device_t bus, device_t child, int type, struct resource *r,
acpi_adjust_resource(device_t bus, device_t child, struct resource *r,
rman_res_t start, rman_res_t end)
{
if (acpi_is_resource_managed(bus, r))
return (rman_adjust_resource(r, start, end));
return (bus_generic_adjust_resource(bus, child, type, r, start, end));
return (bus_generic_adjust_resource(bus, child, r, start, end));
}
static int

View file

@ -97,7 +97,7 @@ static struct resource *acpi_pcib_acpi_alloc_resource(device_t dev,
u_int flags);
#ifdef NEW_PCIB
static int acpi_pcib_acpi_adjust_resource(device_t dev,
device_t child, int type, struct resource *r,
device_t child, struct resource *r,
rman_res_t start, rman_res_t end);
#ifdef PCI_RES_BUS
static int acpi_pcib_acpi_release_resource(device_t dev,
@ -745,19 +745,18 @@ acpi_pcib_acpi_alloc_resource(device_t dev, device_t child, int type, int *rid,
#ifdef NEW_PCIB
int
acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, int type,
acpi_pcib_acpi_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
struct acpi_hpcib_softc *sc;
sc = device_get_softc(dev);
#ifdef PCI_RES_BUS
if (type == PCI_RES_BUS)
if (rman_get_type(r) == PCI_RES_BUS)
return (pci_domain_adjust_bus(sc->ap_segment, child, r, start,
end));
#endif
return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start,
end));
return (pcib_host_res_adjust(&sc->ap_host_res, child, r, start, end));
}
#ifdef PCI_RES_BUS

View file

@ -1080,7 +1080,7 @@ bhndb_release_resource(device_t dev, device_t child, int type, int rid,
* Default bhndb(4) implementation of BUS_ADJUST_RESOURCE().
*/
static int
bhndb_adjust_resource(device_t dev, device_t child, int type,
bhndb_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
struct bhndb_softc *sc;
@ -1093,10 +1093,10 @@ bhndb_adjust_resource(device_t dev, device_t child, int type,
/* Delegate to our parent device's bus if the requested resource type
* isn't handled locally. */
rm = bhndb_get_rman(sc, child, type);
rm = bhndb_get_rman(sc, child, rman_get_type(r));
if (rm == NULL) {
return (BUS_ADJUST_RESOURCE(device_get_parent(sc->parent_dev),
child, type, r, start, end));
child, r, start, end));
}
/* Verify basic constraints */

View file

@ -913,7 +913,7 @@ chipc_release_resource(device_t dev, device_t child, int type, int rid,
}
static int
chipc_adjust_resource(device_t dev, device_t child, int type,
chipc_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
struct chipc_softc *sc;
@ -923,10 +923,9 @@ chipc_adjust_resource(device_t dev, device_t child, int type,
sc = device_get_softc(dev);
/* 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)) {
return (bus_generic_adjust_resource(dev, child, type, r, start,
end));
return (bus_generic_adjust_resource(dev, child, r, start, end));
}
/* The range is limited to the existing region mapping */

View file

@ -343,16 +343,16 @@ dpaa2_mc_alloc_resource(device_t mcdev, device_t child, int type, int *rid,
}
int
dpaa2_mc_adjust_resource(device_t mcdev, device_t child, int type,
dpaa2_mc_adjust_resource(device_t mcdev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
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)
return (bus_generic_rman_adjust_resource(mcdev, child, type, r,
return (bus_generic_rman_adjust_resource(mcdev, child, r,
start, end));
return (bus_generic_adjust_resource(mcdev, child, type, r, start, end));
return (bus_generic_adjust_resource(mcdev, child, r, start, end));
}
int

View file

@ -183,7 +183,7 @@ struct rman *dpaa2_mc_rman(device_t mcdev, int type, u_int flags);
struct resource * dpaa2_mc_alloc_resource(device_t mcdev, device_t child,
int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count,
u_int flags);
int dpaa2_mc_adjust_resource(device_t mcdev, device_t child, int type,
int dpaa2_mc_adjust_resource(device_t mcdev, device_t child,
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 rid, struct resource *r);

View file

@ -46,8 +46,6 @@
static int simplebus_probe(device_t dev);
static struct resource *simplebus_alloc_resource(device_t, device_t, int,
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
static int simplebus_adjust_resource(device_t bus, device_t child,
int type, struct resource *r, rman_res_t start, rman_res_t end);
static int simplebus_release_resource(device_t bus, device_t child,
int type, int rid, struct resource *r);
static int simplebus_activate_resource(device_t bus,
@ -99,7 +97,7 @@ static device_method_t simplebus_methods[] = {
DEVMETHOD(bus_release_resource, simplebus_release_resource),
DEVMETHOD(bus_activate_resource, simplebus_activate_resource),
DEVMETHOD(bus_deactivate_resource, simplebus_deactivate_resource),
DEVMETHOD(bus_adjust_resource, simplebus_adjust_resource),
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
DEVMETHOD(bus_map_resource, simplebus_map_resource),
DEVMETHOD(bus_unmap_resource, simplebus_unmap_resource),
DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
@ -496,16 +494,6 @@ simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
count, flags));
}
static int
simplebus_adjust_resource(device_t bus, device_t child, int type,
struct resource *r, rman_res_t start, rman_res_t end)
{
if (type == SYS_RES_IOPORT)
type = SYS_RES_MEMORY;
return (bus_generic_adjust_resource(bus, child, type, r, start, end));
}
static int
simplebus_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)

View file

@ -1713,15 +1713,15 @@ vmbus_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
}
static int
vmbus_pcib_adjust_resource(device_t dev, device_t child, int type,
vmbus_pcib_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
struct vmbus_pcib_softc *sc = device_get_softc(dev);
if (type == PCI_RES_BUS)
if (rman_get_type(r) == PCI_RES_BUS)
return (pci_domain_adjust_bus(sc->hbus->pci_domain, child, r,
start, end));
return (bus_generic_adjust_resource(dev, child, type, r, start, end));
return (bus_generic_adjust_resource(dev, child, r, start, end));
}
static int

View file

@ -73,7 +73,7 @@ static int ofw_pcib_activate_resource(device_t, device_t, int, int,
struct resource *);
static int ofw_pcib_deactivate_resource(device_t, device_t, int, int,
struct resource *);
static int ofw_pcib_adjust_resource(device_t, device_t, int,
static int ofw_pcib_adjust_resource(device_t, device_t,
struct resource *, rman_res_t, rman_res_t);
static int ofw_pcib_map_resource(device_t, device_t, int, struct resource *,
struct resource_map_request *, struct resource_map *);
@ -656,7 +656,7 @@ ofw_pcib_deactivate_resource(device_t bus, device_t child, int type, int rid,
}
static int
ofw_pcib_adjust_resource(device_t bus, device_t child, int type,
ofw_pcib_adjust_resource(device_t bus, device_t child,
struct resource *res, rman_res_t start, rman_res_t end)
{
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
@ -664,7 +664,7 @@ ofw_pcib_adjust_resource(device_t bus, device_t child, int type,
sc = device_get_softc(bus);
#endif
switch (type) {
switch (rman_get_type(res)) {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
case PCI_RES_BUS:
return (pci_domain_adjust_bus(sc->sc_pci_domain, child, res,
@ -672,11 +672,11 @@ ofw_pcib_adjust_resource(device_t bus, device_t child, int type,
#endif
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
return (bus_generic_rman_adjust_resource(bus, child, type, res,
return (bus_generic_rman_adjust_resource(bus, child, res,
start, end));
default:
return (bus_generic_adjust_resource(bus, child, type, res,
start, end));
return (bus_generic_adjust_resource(bus, child, res, start,
end));
}
}

View file

@ -803,18 +803,18 @@ cbb_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
static int
cbb_pci_adjust_resource(device_t bus, device_t child, int type,
cbb_pci_adjust_resource(device_t bus, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
struct cbb_softc *sc;
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))
return (EINVAL);
return (rman_adjust_resource(r, start, end));
}
return (bus_generic_adjust_resource(bus, child, type, r, start, end));
return (bus_generic_adjust_resource(bus, child, r, start, end));
}
static int

View file

@ -614,7 +614,7 @@ generic_pcie_deactivate_resource(device_t dev, device_t child, int type,
}
static int
generic_pcie_adjust_resource(device_t dev, device_t child, int type,
generic_pcie_adjust_resource(device_t dev, device_t child,
struct resource *res, rman_res_t start, rman_res_t end)
{
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
@ -622,7 +622,7 @@ generic_pcie_adjust_resource(device_t dev, device_t child, int type,
sc = device_get_softc(dev);
#endif
switch (type) {
switch (rman_get_type(res)) {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
case PCI_RES_BUS:
return (pci_domain_adjust_bus(sc->ecam, child, res, start,
@ -630,11 +630,11 @@ generic_pcie_adjust_resource(device_t dev, device_t child, int type,
#endif
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
return (bus_generic_rman_adjust_resource(dev, child, type, res,
return (bus_generic_rman_adjust_resource(dev, child, res,
start, end));
default:
return (bus_generic_adjust_resource(dev, child, type, res,
start, end));
return (bus_generic_adjust_resource(dev, child, res, start,
end));
}
}

View file

@ -2372,23 +2372,23 @@ pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
}
static int
pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r,
pcib_adjust_resource(device_t bus, device_t child, struct resource *r,
rman_res_t start, rman_res_t end)
{
struct pcib_softc *sc;
struct pcib_window *w;
rman_res_t wmask;
int error;
int error, type;
sc = device_get_softc(bus);
type = rman_get_type(r);
/*
* If the resource wasn't sub-allocated from one of our region
* managers then just pass the request up.
*/
if (!pcib_is_resource_managed(sc, r))
return (bus_generic_adjust_resource(bus, child, type, r,
start, end));
return (bus_generic_adjust_resource(bus, child, r, start, end));
#ifdef PCI_RES_BUS
if (type == PCI_RES_BUS) {

View file

@ -260,26 +260,26 @@ pcib_host_res_alloc(struct pcib_host_resources *hr, device_t dev, int type,
}
int
pcib_host_res_adjust(struct pcib_host_resources *hr, device_t dev, int type,
pcib_host_res_adjust(struct pcib_host_resources *hr, device_t dev,
struct resource *r, rman_res_t start, rman_res_t end)
{
struct resource_list_entry *rle;
rle = resource_list_find(&hr->hr_rl, type, 0);
rle = resource_list_find(&hr->hr_rl, rman_get_type(r), 0);
if (rle == NULL) {
/*
* No decoding ranges for this resource type, just pass
* the request up to the parent.
*/
return (bus_generic_adjust_resource(hr->hr_pcib, dev, type, r,
start, end));
return (bus_generic_adjust_resource(hr->hr_pcib, dev, r, start,
end));
}
/* Only allow adjustments that stay within a decoded range. */
for (; rle != NULL; rle = STAILQ_NEXT(rle, link)) {
if (rle->start <= start && rle->end >= end)
return (bus_generic_adjust_resource(hr->hr_pcib, dev,
type, r, start, end));
r, start, end));
}
return (ERANGE);
}

View file

@ -56,7 +56,7 @@ struct resource *pcib_host_res_alloc(struct pcib_host_resources *hr,
device_t dev, int type, int *rid, rman_res_t start,
rman_res_t end, rman_res_t count, u_int flags);
int pcib_host_res_adjust(struct pcib_host_resources *hr,
device_t dev, int type, struct resource *r, rman_res_t start,
device_t dev, struct resource *r, rman_res_t start,
rman_res_t end);
#endif

View file

@ -469,16 +469,14 @@ vmd_alloc_resource(device_t dev, device_t child, int type, int *rid,
}
static int
vmd_adjust_resource(device_t dev, device_t child, int type,
vmd_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
if (type == SYS_RES_IRQ) {
return (bus_generic_adjust_resource(dev, child, type, r,
start, end));
if (rman_get_type(r) == SYS_RES_IRQ) {
return (bus_generic_adjust_resource(dev, child, r, start, end));
}
return (bus_generic_rman_adjust_resource(dev, child, type, r, start,
end));
return (bus_generic_rman_adjust_resource(dev, child, r, start, end));
}
static int

View file

@ -399,7 +399,6 @@ METHOD int deactivate_resource {
*
* @param _dev the parent device of @p _child
* @param _child the device which allocated the resource
* @param _type the type of resource
* @param _res the resource to adjust
* @param _start the new starting address of the resource range
* @param _end the new ending address of the resource range
@ -407,7 +406,6 @@ METHOD int deactivate_resource {
METHOD int adjust_resource {
device_t _dev;
device_t _child;
int _type;
struct resource *_res;
rman_res_t _start;
rman_res_t _end;

View file

@ -3877,13 +3877,12 @@ bus_generic_resume_intr(device_t dev, device_t child, struct resource *irq)
* BUS_ADJUST_RESOURCE() method of the parent of @p dev.
*/
int
bus_generic_adjust_resource(device_t dev, device_t child, int type,
struct resource *r, rman_res_t start, rman_res_t end)
bus_generic_adjust_resource(device_t dev, device_t child, struct resource *r,
rman_res_t start, rman_res_t end)
{
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent)
return (BUS_ADJUST_RESOURCE(dev->parent, child, type, r, start,
end));
return (BUS_ADJUST_RESOURCE(dev->parent, child, r, start, end));
return (EINVAL);
}
@ -4270,12 +4269,12 @@ bus_generic_rman_alloc_resource(device_t dev, device_t child, int type,
* BUS_GET_RMAN().
*/
int
bus_generic_rman_adjust_resource(device_t dev, device_t child, int type,
bus_generic_rman_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
struct rman *rm;
rm = BUS_GET_RMAN(dev, type, rman_get_flags(r));
rm = BUS_GET_RMAN(dev, rman_get_type(r), rman_get_flags(r));
if (rm == NULL)
return (ENXIO);
if (!rman_is_region_manager(r, rm))
@ -4537,19 +4536,19 @@ bus_alloc_resource(device_t dev, int type, int *rid, rman_res_t start,
* parent of @p dev.
*/
int
bus_adjust_resource(device_t dev, int type, struct resource *r, rman_res_t start,
bus_adjust_resource(device_t dev, struct resource *r, rman_res_t start,
rman_res_t end)
{
if (dev->parent == NULL)
return (EINVAL);
return (BUS_ADJUST_RESOURCE(dev->parent, dev, type, r, start, end));
return (BUS_ADJUST_RESOURCE(dev->parent, dev, r, start, end));
}
int
bus_adjust_resource_new(device_t dev, struct resource *r, rman_res_t start,
rman_res_t end)
bus_adjust_resource_old(device_t dev, int type __unused, struct resource *r,
rman_res_t start, rman_res_t end)
{
return (bus_adjust_resource(dev, rman_get_type(r), r, start, end));
return (bus_adjust_resource(dev, r, start, end));
}
/**

View file

@ -81,7 +81,7 @@ static int lbc_deactivate_resource(device_t bus,
static struct rman *lbc_get_rman(device_t, int, u_int);
static struct resource *lbc_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t, u_int);
static int lbc_adjust_resource(device_t, device_t, int, struct resource *,
static int lbc_adjust_resource(device_t, device_t, struct resource *,
rman_res_t, rman_res_t);
static int lbc_print_child(device_t, device_t);
static int lbc_release_resource(device_t, device_t, int, int,
@ -762,19 +762,15 @@ lbc_print_child(device_t dev, device_t child)
}
static int
lbc_adjust_resource(device_t dev, device_t child, int type, struct resource *r,
lbc_adjust_resource(device_t dev, device_t child, struct resource *r,
rman_res_t start, rman_res_t end)
{
switch (type) {
case SYS_RES_IOPORT:
type = SYS_RES_MEMORY;
/* FALLTHROUGH */
switch (rman_get_type(r)) {
case SYS_RES_MEMORY:
return (bus_generic_rman_adjust_resource(dev, child, type, r,
start, end));
case SYS_RES_IRQ:
return (bus_generic_adjust_resource(dev, child, type, r, start,
return (bus_generic_rman_adjust_resource(dev, child, r, start,
end));
case SYS_RES_IRQ:
return (bus_generic_adjust_resource(dev, child, r, start, end));
default:
return (EINVAL);
}

View file

@ -84,7 +84,7 @@ static struct rman *macio_get_rman(device_t, int, u_int);
static struct resource *macio_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t,
u_int);
static int macio_adjust_resource(device_t, device_t, int, struct resource *,
static int macio_adjust_resource(device_t, device_t, struct resource *,
rman_res_t, rman_res_t);
static int macio_activate_resource(device_t, device_t, int, int,
struct resource *);
@ -596,17 +596,16 @@ macio_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
static int
macio_adjust_resource(device_t bus, device_t child, int type,
struct resource *r, rman_res_t start, rman_res_t end)
macio_adjust_resource(device_t bus, device_t child, struct resource *r,
rman_res_t start, rman_res_t end)
{
switch (type) {
switch (rman_get_type(r)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
return (bus_generic_rman_adjust_resource(bus, child, type, r,
start, end));
case SYS_RES_IRQ:
return (bus_generic_adjust_resource(bus, child, type, r, start,
return (bus_generic_rman_adjust_resource(bus, child, r, start,
end));
case SYS_RES_IRQ:
return (bus_generic_adjust_resource(bus, child, r, start, end));
default:
return (EINVAL);
}

View file

@ -75,7 +75,7 @@ static struct rman *unin_chip_get_rman(device_t, int, u_int);
static struct resource *unin_chip_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t,
rman_res_t, u_int);
static int unin_chip_adjust_resource(device_t, device_t, int,
static int unin_chip_adjust_resource(device_t, device_t,
struct resource *, rman_res_t,
rman_res_t);
static int unin_chip_activate_resource(device_t, device_t, int, int,
@ -554,17 +554,16 @@ unin_chip_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
static int
unin_chip_adjust_resource(device_t bus, device_t child, int type,
struct resource *r, rman_res_t start, rman_res_t end)
unin_chip_adjust_resource(device_t bus, device_t child, struct resource *r,
rman_res_t start, rman_res_t end)
{
switch (type) {
switch (rman_get_type(r)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
return (bus_generic_rman_adjust_resource(bus, child, type, r,
start, end));
case SYS_RES_IRQ:
return (bus_generic_adjust_resource(bus, child, type, r, start,
return (bus_generic_rman_adjust_resource(bus, child, r, start,
end));
case SYS_RES_IRQ:
return (bus_generic_adjust_resource(bus, child, r, start, end));
default:
return (EINVAL);
}

View file

@ -74,7 +74,7 @@ static struct rman *iobus_get_rman(device_t, int, u_int);
static struct resource *iobus_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t,
u_int);
static int iobus_adjust_resource(device_t, device_t, int, struct resource *,
static int iobus_adjust_resource(device_t, device_t, struct resource *,
rman_res_t, rman_res_t);
static int iobus_activate_resource(device_t, device_t, int, int,
struct resource *);
@ -342,18 +342,17 @@ iobus_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
static int
iobus_adjust_resource(device_t bus, device_t child, int type,
struct resource *r, rman_res_t start, rman_res_t end)
iobus_adjust_resource(device_t bus, device_t child, struct resource *r,
rman_res_t start, rman_res_t end)
{
switch (type) {
switch (rman_get_type(r)) {
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
return (bus_generic_rman_adjust_resource(bus, child, type, r,
start, end));
case SYS_RES_IRQ:
return (bus_generic_adjust_resource(bus, child, type, r, start,
return (bus_generic_rman_adjust_resource(bus, child, r, start,
end));
case SYS_RES_IRQ:
return (bus_generic_adjust_resource(bus, child, r, start, end));
default:
return (EINVAL);
}

View file

@ -432,7 +432,7 @@ int bus_generic_activate_resource(device_t dev, device_t child, int type,
device_t
bus_generic_add_child(device_t dev, u_int order, const char *name,
int unit);
int bus_generic_adjust_resource(device_t bus, device_t child, int type,
int bus_generic_adjust_resource(device_t bus, device_t child,
struct resource *r, rman_res_t start,
rman_res_t end);
struct resource *
@ -504,7 +504,7 @@ struct resource *
int *rid, rman_res_t start,
rman_res_t end, rman_res_t count,
u_int flags);
int bus_generic_rman_adjust_resource(device_t dev, device_t child, int type,
int bus_generic_rman_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start,
rman_res_t end);
int bus_generic_rman_release_resource(device_t dev, device_t child,
@ -554,7 +554,7 @@ int bus_alloc_resources(device_t dev, struct resource_spec *rs,
void bus_release_resources(device_t dev, const struct resource_spec *rs,
struct resource **res);
int bus_adjust_resource(device_t child, int type, struct resource *r,
int bus_adjust_resource(device_t child, struct resource *r,
rman_res_t start, rman_res_t end);
int bus_translate_resource(device_t child, int type, rman_res_t start,
rman_res_t *newstart);
@ -614,7 +614,7 @@ bus_alloc_resource_anywhere(device_t dev, int type, int *rid,
}
/* Compat shims for simpler bus resource API. */
int bus_adjust_resource_new(device_t child, struct resource *r,
int bus_adjust_resource_old(device_t child, int type, struct resource *r,
rman_res_t start, rman_res_t end);
int bus_activate_resource_new(device_t dev, struct resource *r);
int bus_deactivate_resource_new(device_t dev, struct resource *r);
@ -627,8 +627,8 @@ int bus_release_resource_new(device_t dev, struct resource *r);
#define _BUS_API_MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME
#define bus_adjust_resource(...) \
_BUS_API_MACRO(__VA_ARGS__, bus_adjust_resource, \
bus_adjust_resource_new)(__VA_ARGS__)
_BUS_API_MACRO(__VA_ARGS__, bus_adjust_resource_old, \
bus_adjust_resource)(__VA_ARGS__)
#define bus_activate_resource(...) \
_BUS_API_MACRO(__VA_ARGS__, INVALID, bus_activate_resource, \

View file

@ -58,7 +58,7 @@ int legacy_pcib_write_ivar(device_t dev, device_t child, int which,
struct resource *legacy_pcib_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 legacy_pcib_adjust_resource(device_t dev, device_t child, int type,
int legacy_pcib_adjust_resource(device_t dev, device_t child,
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 rid, struct resource *r);

View file

@ -607,13 +607,13 @@ legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
int
legacy_pcib_adjust_resource(device_t dev, device_t child, int type,
legacy_pcib_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
if (type == PCI_RES_BUS)
if (rman_get_type(r) == PCI_RES_BUS)
return (pci_domain_adjust_bus(0, child, r, start, end));
return (bus_generic_adjust_resource(dev, child, type, r, start, end));
return (bus_generic_adjust_resource(dev, child, r, start, end));
}
int

View file

@ -139,18 +139,17 @@ mptable_hostb_alloc_resource(device_t dev, device_t child, int type, int *rid,
}
static int
mptable_hostb_adjust_resource(device_t dev, device_t child, int type,
mptable_hostb_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
struct mptable_hostb_softc *sc;
#ifdef PCI_RES_BUS
if (type == PCI_RES_BUS)
if (rman_get_type(r) == PCI_RES_BUS)
return (pci_domain_adjust_bus(0, child, r, start, end));
#endif
sc = device_get_softc(dev);
return (pcib_host_res_adjust(&sc->sc_host_res, child, type, r, start,
end));
return (pcib_host_res_adjust(&sc->sc_host_res, child, r, start, end));
}
#endif