mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-02 19:27:31 +02:00
eac20bee29
* update patches to 3.0 * add basic vr9 support * backport 3.1 fixes * backport 3.2 queue (falcon) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@28405 3c298f89-4303-0410-b956-a3cf2f4a3e73
57 lines
1.9 KiB
Diff
57 lines
1.9 KiB
Diff
commit 1c388919d89ca35741e9c4d3255adf87f76f0c06
|
|
Author: Geert Uytterhoeven <geert@linux-m68k.org>
|
|
Date: Sat May 7 20:53:16 2011 +0200
|
|
|
|
resources: Add lookup_resource()
|
|
|
|
Add a function to find an existing resource by a resource start address.
|
|
This allows to implement simple allocators (with a malloc/free-alike API)
|
|
on top of the resource system.
|
|
|
|
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
|
|
|
|
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
|
|
index e9bb22c..63eb429 100644
|
|
--- a/include/linux/ioport.h
|
|
+++ b/include/linux/ioport.h
|
|
@@ -132,6 +132,7 @@ extern int allocate_resource(struct resource *root, struct resource *new,
|
|
resource_size_t,
|
|
resource_size_t),
|
|
void *alignf_data);
|
|
+struct resource *lookup_resource(struct resource *root, resource_size_t start);
|
|
int adjust_resource(struct resource *res, resource_size_t start,
|
|
resource_size_t size);
|
|
resource_size_t resource_alignment(struct resource *res);
|
|
diff --git a/kernel/resource.c b/kernel/resource.c
|
|
index 3ff4017..3b3cedc 100644
|
|
--- a/kernel/resource.c
|
|
+++ b/kernel/resource.c
|
|
@@ -553,6 +553,27 @@ int allocate_resource(struct resource *root, struct resource *new,
|
|
|
|
EXPORT_SYMBOL(allocate_resource);
|
|
|
|
+/**
|
|
+ * lookup_resource - find an existing resource by a resource start address
|
|
+ * @root: root resource descriptor
|
|
+ * @start: resource start address
|
|
+ *
|
|
+ * Returns a pointer to the resource if found, NULL otherwise
|
|
+ */
|
|
+struct resource *lookup_resource(struct resource *root, resource_size_t start)
|
|
+{
|
|
+ struct resource *res;
|
|
+
|
|
+ read_lock(&resource_lock);
|
|
+ for (res = root->child; res; res = res->sibling) {
|
|
+ if (res->start == start)
|
|
+ break;
|
|
+ }
|
|
+ read_unlock(&resource_lock);
|
|
+
|
|
+ return res;
|
|
+}
|
|
+
|
|
/*
|
|
* Insert a resource into the resource tree. If successful, return NULL,
|
|
* otherwise return the conflicting resource (compare to __request_resource())
|