Page MenuHomeFreeBSD

D59682.diff
No OneTemporary

D59682.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
@@ -892,33 +892,20 @@
}
/*
- * For now, this method supports only requests for GPIO IRQ resources.
- * The requesting device, a consumer, does not have to be a child or
- * a descendant of the bus device.
- *
- * FIXME
- * The method does not support non-IRQ resources or non-GPIO IRQ resources
- * even for its children. This should be fixed as soon as there is
- * a child driver needs access to system resources.
+ * Allocate a resource managed by gpiobus's rman (currently only GPIO IRQ
+ * resources). The requesting device does not have to be a child of the
+ * bus; this is needed for cousin interrupt sources.
*/
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 rman *rm;
+ struct resource *r;
struct resource_list *rl;
struct resource_list_entry *rle;
int isdefault;
- dprintf("%s: entry (%p, %p, %d, %d, %p, %ld)\n",
- __func__, bus, child, type, rid, (void *)(intptr_t)start, count);
-
- /*
- * FIXME support indirect discendants and non-IRQ resources.
- * The request should be forwarded upwards for those.
- */
- if (type != SYS_RES_IRQ)
- return (NULL);
-
isdefault = RMAN_IS_DEFAULT_RANGE(start, end) && count == 1 &&
device_get_parent(child) == bus;
if (isdefault) {
@@ -932,27 +919,50 @@
count = rle->count;
end = rle->end;
}
- return (bus_generic_rman_alloc_resource(bus, child, type, rid, start,
- end, count, flags));
+
+ rm = gpiobus_get_rman(bus, type, flags);
+ r = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE,
+ child);
+ if (r == NULL)
+ return (NULL);
+ rman_set_rid(r, rid);
+ rman_set_type(r, type);
+
+ if ((flags & RF_ACTIVE) != 0 && rman_activate_resource(r) != 0) {
+ rman_release_resource(r);
+ return (NULL);
+ }
+
+ return (r);
}
static int
gpiobus_release_resource(device_t dev, device_t child, struct resource *r)
{
+ struct rman *rm;
int err;
+ u_int flags;
#ifdef INTRNG
u_int irq;
irq = rman_get_start(r);
MPASS(irq == rman_get_end(r));
#endif
- err = bus_generic_rman_release_resource(dev, child, r);
- if (err != 0)
- return (err);
+
+ flags = rman_get_flags(r);
+ rm = gpiobus_get_rman(dev, rman_get_type(r), flags);
+ KASSERT(rman_is_region_manager(r, rm),
+ ("%s: rman %p doesn't match for resource %p", __func__, rm, r));
+ if (flags & RF_ACTIVE) {
+ err = rman_deactivate_resource(r);
+ if (err != 0)
+ return (err);
+ }
+
#ifdef INTRNG
intr_unmap_irq(irq);
#endif
- return (0);
+ return (rman_release_resource(r));
}
static struct resource_list *

File Metadata

Mime Type
text/plain
Expires
Wed, Sep 16, 1:10 AM (12 m, 55 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38990224
Default Alt Text
D59682.diff (2 KB)

Event Timeline