Index: kernel/resource.c
===================================================================
RCS file: /var/cvs/linux-2.6/kernel/resource.c,v
retrieving revision 1.4
diff -u -p -r1.4 resource.c
--- kernel/resource.c   28 Sep 2003 04:06:24 -0000      1.4
+++ kernel/resource.c   2 Oct 2003 22:17:40 -0000
@@ -317,6 +317,57 @@ int expand_resource(struct resource *res
       return 0;
}

+/**
+ * insert_resource - Inserts a resource between two existing resources
+ * @parent
+ * @new
+ *
+ * Returns 0 on success, -EBUSY if the resource can't be inserted.
+ */
+int insert_resource(struct resource *parent, struct resource *new)
+{
+       int result = 0;
+       struct resource *first, *next;
+
+       write_lock(&resource_lock);
+       first = __request_resource(parent, new);
+       if (!first)
+               goto out;
+
+       result = -EBUSY;
+       if (first == parent)
+               goto out;
+
+       for (next = first; next && next->end <= new->end; next = next->sibling)
+               if (new->end < next->start)
+                       break;
+
+       /* existing resource overlaps end of new resource */
+       if (next && next->end > new->end)
+               goto out;
+
+       result = 0;
+       if (next) {
+               new->sibling = next->sibling;
+               next->sibling = NULL;
+       }
+       new->child = first;
+       for (next = first; next; next = next->sibling)
+               next->parent = new;
+       if (parent->child == first) {
+               parent->child = new;
+       } else {
+               next = parent->child;
+               while (next->sibling != first)
+                       next = next->sibling;
+               next->sibling = new;
+       }
+
+ out:
+       write_unlock(&resource_lock);
+       return result;
+}
+
/*
 * This is compatibility stuff for IO resources.
 *