Page MenuHomeFreeBSD

D43887.diff
No OneTemporary

D43887.diff

diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c
--- a/sys/dev/gpio/gpiobus.c
+++ b/sys/dev/gpio/gpiobus.c
@@ -809,20 +809,29 @@
return (0);
}
+static struct rman *
+gpiobus_get_rman(device_t bus, int type, u_int flags)
+{
+ struct gpiobus_softc *sc;
+
+ sc = device_get_softc(bus);
+ switch (type) {
+ case SYS_RES_IRQ:
+ return (&sc->sc_intr_rman);
+ default:
+ return (NULL);
+ }
+}
+
static struct resource *
gpiobus_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)
{
- struct gpiobus_softc *sc;
- struct resource *rv;
struct resource_list *rl;
struct resource_list_entry *rle;
int isdefault;
- if (type != SYS_RES_IRQ)
- return (NULL);
isdefault = (RMAN_IS_DEFAULT_RANGE(start, end) && count == 1);
- rle = NULL;
if (isdefault) {
rl = BUS_GET_RESOURCE_LIST(bus, child);
if (rl == NULL)
@@ -830,40 +839,12 @@
rle = resource_list_find(rl, type, *rid);
if (rle == NULL)
return (NULL);
- if (rle->res != NULL)
- panic("%s: resource entry is busy", __func__);
start = rle->start;
count = rle->count;
end = rle->end;
}
- sc = device_get_softc(bus);
- rv = rman_reserve_resource(&sc->sc_intr_rman, start, end, count, flags,
- child);
- if (rv == NULL)
- return (NULL);
- rman_set_rid(rv, *rid);
- if ((flags & RF_ACTIVE) != 0 &&
- bus_activate_resource(child, type, *rid, rv) != 0) {
- rman_release_resource(rv);
- return (NULL);
- }
-
- return (rv);
-}
-
-static int
-gpiobus_release_resource(device_t bus __unused, device_t child, int type,
- int rid, struct resource *r)
-{
- int error;
-
- if (rman_get_flags(r) & RF_ACTIVE) {
- error = bus_deactivate_resource(child, type, rid, r);
- if (error)
- return (error);
- }
-
- return (rman_release_resource(r));
+ return (bus_generic_rman_alloc_resource(bus, child, type, rid, start,
+ end, count, flags));
}
static struct resource_list *
@@ -1060,9 +1041,9 @@
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
DEVMETHOD(bus_alloc_resource, gpiobus_alloc_resource),
- DEVMETHOD(bus_release_resource, gpiobus_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_rman_release_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_rman_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_rman_deactivate_resource),
DEVMETHOD(bus_get_resource_list, gpiobus_get_resource_list),
DEVMETHOD(bus_add_child, gpiobus_add_child),
DEVMETHOD(bus_rescan, gpiobus_rescan),

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 9, 5:21 AM (7 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15729836
Default Alt Text
D43887.diff (2 KB)

Event Timeline