Date: Sat, 11 Aug 2007 21:33:52 GMT From: Christopher Davis <loafier@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 125067 for review Message-ID: <200708112133.l7BLXqua010107@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125067 Change 125067 by loafier@chrisdsoc on 2007/08/11 21:33:08 bus_alloc_resources(), etc. Affected files ... .. //depot/projects/soc2007/loafier_busalloc/src/sys/dev/acpica/acpi_ec.c#2 edit Differences ... ==== //depot/projects/soc2007/loafier_busalloc/src/sys/dev/acpica/acpi_ec.c#2 (text+ko) ==== @@ -217,16 +217,16 @@ * Register access primitives */ #define EC_GET_DATA(sc) \ - bus_space_read_1((sc)->ec_data_tag, (sc)->ec_data_handle, 0) + bus_read_1((sc)->ec_res[RES_DATA], 0) #define EC_SET_DATA(sc, v) \ - bus_space_write_1((sc)->ec_data_tag, (sc)->ec_data_handle, 0, (v)) + bus_write_1((sc)->ec_res[RES_DATA], 0, (v)) #define EC_GET_CSR(sc) \ - bus_space_read_1((sc)->ec_csr_tag, (sc)->ec_csr_handle, 0) + bus_read_1((sc)->ec_res[RES_CSR], 0) #define EC_SET_CSR(sc, v) \ - bus_space_write_1((sc)->ec_csr_tag, (sc)->ec_csr_handle, 0, (v)) + bus_write_1((sc)->ec_res[RES_CSR], 0, (v)) /* Additional params to pass from the probe routine */ struct acpi_ec_params { @@ -242,6 +242,18 @@ /* * Driver softc. */ +enum { + RES_DATA, + RES_CSR, + RES_SZ +}; + +static struct resource_spec ec_res_spec[] = { + {SYS_RES_IOPORT, 0, RF_ACTIVE}, + {SYS_RES_IOPORT, 1, RF_ACTIVE}, + {-1, 0, 0} +}; + struct acpi_ec_softc { device_t ec_dev; ACPI_HANDLE ec_handle; @@ -250,15 +262,7 @@ UINT8 ec_gpebit; UINT8 ec_csrvalue; - int ec_data_rid; - struct resource *ec_data_res; - bus_space_tag_t ec_data_tag; - bus_space_handle_t ec_data_handle; - - int ec_csr_rid; - struct resource *ec_csr_res; - bus_space_tag_t ec_csr_tag; - bus_space_handle_t ec_csr_handle; + struct resource *ec_res[RES_SZ]; struct mtx ec_mtx; int ec_glk; @@ -588,26 +592,11 @@ free(params, M_TEMP); /* Attach bus resources for data and command/status ports. */ - sc->ec_data_rid = 0; - sc->ec_data_res = bus_alloc_resource_any(sc->ec_dev, SYS_RES_IOPORT, - &sc->ec_data_rid, RF_ACTIVE); - if (sc->ec_data_res == NULL) { - device_printf(dev, "can't allocate data port\n"); - goto error; + if (bus_alloc_resources(dev, ec_res_spec, sc->ec_res) != 0) { + device_printf(dev, "can't allocate resources\n"); + goto error; } - sc->ec_data_tag = rman_get_bustag(sc->ec_data_res); - sc->ec_data_handle = rman_get_bushandle(sc->ec_data_res); - sc->ec_csr_rid = 1; - sc->ec_csr_res = bus_alloc_resource_any(sc->ec_dev, SYS_RES_IOPORT, - &sc->ec_csr_rid, RF_ACTIVE); - if (sc->ec_csr_res == NULL) { - device_printf(dev, "can't allocate command/status port\n"); - goto error; - } - sc->ec_csr_tag = rman_get_bustag(sc->ec_csr_res); - sc->ec_csr_handle = rman_get_bushandle(sc->ec_csr_res); - /* * Install a handler for this EC's GPE bit. We want edge-triggered * behavior. @@ -655,13 +644,9 @@ AcpiRemoveGpeHandler(sc->ec_gpehandle, sc->ec_gpebit, &EcGpeHandler); AcpiRemoveAddressSpaceHandler(sc->ec_handle, ACPI_ADR_SPACE_EC, EcSpaceHandler); - if (sc->ec_csr_res) - bus_release_resource(sc->ec_dev, SYS_RES_IOPORT, sc->ec_csr_rid, - sc->ec_csr_res); - if (sc->ec_data_res) - bus_release_resource(sc->ec_dev, SYS_RES_IOPORT, sc->ec_data_rid, - sc->ec_data_res); + bus_release_resources(sc->ec_dev, ec_res_spec, sc->ec_res); mtx_destroy(&sc->ec_mtx); + return (ENXIO); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708112133.l7BLXqua010107>