[Intel-gfx] [PATCH 2/3] resource: Introduce lookup_resource_by_name()

Chris Wilson chris at chris-wilson.co.uk
Thu Jul 25 12:02:17 CEST 2013


This is useful for drivers to find a resource inserted by, for example,
an early PCI quirk.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 include/linux/ioport.h |  2 ++
 kernel/resource.c      | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 89b7c24..acad72f 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -158,6 +158,8 @@ extern int allocate_resource(struct resource *root, struct resource *new,
 						       resource_size_t),
 			     void *alignf_data);
 struct resource *lookup_resource(struct resource *root, resource_size_t start);
+struct resource *lookup_resource_by_name(struct resource *root,
+					 const char *name);
 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 3f285dc..9cc1bb8 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -624,6 +624,20 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start)
 	return res;
 }
 
+struct resource *lookup_resource_by_name(struct resource *root, const char *name)
+{
+	struct resource *res;
+
+	read_lock(&resource_lock);
+	for (res = root->child; res; res = res->sibling) {
+		if (strcmp(res->name, name) == 0)
+			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())
-- 
1.8.3.2




More information about the Intel-gfx mailing list