|
@@ -553,6 +553,27 @@ int allocate_resource(struct resource *root, struct resource *new,
|
|
|
|
|
|
EXPORT_SYMBOL(allocate_resource);
|
|
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,
|
|
* Insert a resource into the resource tree. If successful, return NULL,
|
|
* otherwise return the conflicting resource (compare to __request_resource())
|
|
* otherwise return the conflicting resource (compare to __request_resource())
|