acpi_bus_alloc_gas: Pass rid by value
Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53405
This commit is contained in:
@@ -1770,13 +1770,13 @@ acpi_unmap_resource(device_t bus, device_t child, struct resource *r,
|
||||
|
||||
/* Allocate an IO port or memory resource, given its GAS. */
|
||||
int
|
||||
acpi_bus_alloc_gas(device_t dev, int *type, int *rid, ACPI_GENERIC_ADDRESS *gas,
|
||||
acpi_bus_alloc_gas(device_t dev, int *type, int rid, ACPI_GENERIC_ADDRESS *gas,
|
||||
struct resource **res, u_int flags)
|
||||
{
|
||||
int error, res_type;
|
||||
|
||||
error = ENOMEM;
|
||||
if (type == NULL || rid == NULL || gas == NULL || res == NULL)
|
||||
if (type == NULL || gas == NULL || res == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
/* We only support memory and IO spaces. */
|
||||
@@ -1802,14 +1802,14 @@ acpi_bus_alloc_gas(device_t dev, int *type, int *rid, ACPI_GENERIC_ADDRESS *gas,
|
||||
if (gas->Address == 0 || gas->BitWidth == 0)
|
||||
return (EINVAL);
|
||||
|
||||
bus_set_resource(dev, res_type, *rid, gas->Address,
|
||||
bus_set_resource(dev, res_type, rid, gas->Address,
|
||||
gas->BitWidth / 8);
|
||||
*res = bus_alloc_resource_any(dev, res_type, rid, RF_ACTIVE | flags);
|
||||
if (*res != NULL) {
|
||||
*type = res_type;
|
||||
error = 0;
|
||||
} else
|
||||
bus_delete_resource(dev, res_type, *rid);
|
||||
bus_delete_resource(dev, res_type, rid);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
@@ -700,7 +700,7 @@ apei_attach(device_t dev)
|
||||
rid = 0;
|
||||
TAILQ_FOREACH(ge, &sc->ges, link) {
|
||||
ge->res_rid = rid++;
|
||||
acpi_bus_alloc_gas(dev, &ge->res_type, &ge->res_rid,
|
||||
acpi_bus_alloc_gas(dev, &ge->res_type, ge->res_rid,
|
||||
&ge->v1.ErrorStatusAddress, &ge->res, 0);
|
||||
if (ge->res) {
|
||||
ge->buf = pmap_mapdev_attr(READ8(ge->res, 0),
|
||||
@@ -710,7 +710,7 @@ apei_attach(device_t dev)
|
||||
}
|
||||
if (ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2) {
|
||||
ge->res2_rid = rid++;
|
||||
acpi_bus_alloc_gas(dev, &ge->res2_type, &ge->res2_rid,
|
||||
acpi_bus_alloc_gas(dev, &ge->res2_type, ge->res2_rid,
|
||||
&ge->v2.ReadAckRegister, &ge->res2, RF_SHAREABLE);
|
||||
if (ge->res2 == NULL)
|
||||
device_printf(dev, "Can't allocate ack resource.\n");
|
||||
|
||||
@@ -732,7 +732,7 @@ acpi_cpu_generic_cx_probe(struct acpi_cpu_softc *sc)
|
||||
if (AcpiGbl_FADT.C2Latency <= 100) {
|
||||
gas.Address = sc->cpu_p_blk + 4;
|
||||
cx_ptr->res_rid = 0;
|
||||
acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, &cx_ptr->res_rid,
|
||||
acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, cx_ptr->res_rid,
|
||||
&gas, &cx_ptr->p_lvlx, RF_SHAREABLE);
|
||||
if (cx_ptr->p_lvlx != NULL) {
|
||||
cx_ptr->type = ACPI_STATE_C2;
|
||||
@@ -749,7 +749,7 @@ acpi_cpu_generic_cx_probe(struct acpi_cpu_softc *sc)
|
||||
if (AcpiGbl_FADT.C3Latency <= 1000 && !(cpu_quirks & CPU_QUIRK_NO_C3)) {
|
||||
gas.Address = sc->cpu_p_blk + 5;
|
||||
cx_ptr->res_rid = 1;
|
||||
acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, &cx_ptr->res_rid,
|
||||
acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, cx_ptr->res_rid,
|
||||
&gas, &cx_ptr->p_lvlx, RF_SHAREABLE);
|
||||
if (cx_ptr->p_lvlx != NULL) {
|
||||
cx_ptr->type = ACPI_STATE_C3;
|
||||
|
||||
@@ -126,7 +126,7 @@ acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *type, int *rid,
|
||||
|
||||
memcpy(&gas, obj->Buffer.Pointer + 3, sizeof(gas));
|
||||
|
||||
return (acpi_bus_alloc_gas(dev, type, rid, &gas, dst, flags));
|
||||
return (acpi_bus_alloc_gas(dev, type, *rid, &gas, dst, flags));
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -275,7 +275,7 @@ acpi_throttle_evaluate(struct acpi_throttle_softc *sc)
|
||||
return (ENXIO);
|
||||
}
|
||||
memcpy(&gas, obj.Buffer.Pointer + 3, sizeof(gas));
|
||||
acpi_bus_alloc_gas(sc->cpu_dev, &sc->cpu_p_type, &thr_rid,
|
||||
acpi_bus_alloc_gas(sc->cpu_dev, &sc->cpu_p_type, thr_rid,
|
||||
&gas, &sc->cpu_p_cnt, 0);
|
||||
if (sc->cpu_p_cnt != NULL && bootverbose) {
|
||||
device_printf(sc->cpu_dev, "P_CNT from _PTC %#jx\n",
|
||||
@@ -295,7 +295,7 @@ acpi_throttle_evaluate(struct acpi_throttle_softc *sc)
|
||||
gas.Address = sc->cpu_p_blk;
|
||||
gas.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
|
||||
gas.BitWidth = 32;
|
||||
acpi_bus_alloc_gas(sc->cpu_dev, &sc->cpu_p_type, &thr_rid,
|
||||
acpi_bus_alloc_gas(sc->cpu_dev, &sc->cpu_p_type, thr_rid,
|
||||
&gas, &sc->cpu_p_cnt, 0);
|
||||
if (sc->cpu_p_cnt != NULL) {
|
||||
if (bootverbose)
|
||||
|
||||
@@ -419,7 +419,7 @@ int acpi_parse_prw(ACPI_HANDLE h, struct acpi_prw_data *prw);
|
||||
ACPI_STATUS acpi_Startup(void);
|
||||
void acpi_UserNotify(const char *subsystem, ACPI_HANDLE h,
|
||||
uint8_t notify);
|
||||
int acpi_bus_alloc_gas(device_t dev, int *type, int *rid,
|
||||
int acpi_bus_alloc_gas(device_t dev, int *type, int rid,
|
||||
ACPI_GENERIC_ADDRESS *gas, struct resource **res,
|
||||
u_int flags);
|
||||
void acpi_walk_subtables(void *first, void *end,
|
||||
|
||||
@@ -612,7 +612,7 @@ wdatwd_probe(device_t dev)
|
||||
int type, rid = 0;
|
||||
struct resource *res;
|
||||
|
||||
if (acpi_bus_alloc_gas(dev, &type, &rid,
|
||||
if (acpi_bus_alloc_gas(dev, &type, rid,
|
||||
&((ACPI_WDAT_ENTRY *)(wdat + 1))->RegisterRegion,
|
||||
&res, 0))
|
||||
return (ENXIO);
|
||||
|
||||
Reference in New Issue
Block a user