Thread (1 message) 1 message, 1 author, 2018-06-12

Re: [PATCH v5 1/4] resource: Move reparent_resources() to kernel/resource.c and make it public

From: Andy Shevchenko <hidden>
Date: 2018-06-12 08:29:00
Also in: kexec, linux-devicetree, linux-input, nvdimm

On Tue, Jun 12, 2018 at 6:28 AM, Baoquan He [off-list ref] wrote:
reparent_resources() is duplicated in arch/microblaze/pci/pci-common.c
and arch/powerpc/kernel/pci-common.c, so move it to kernel/resource.c
so that it's shared. Later its code also need be updated using list_head
to replace singly linked list.
While this is a good deduplication of the code, some requirements for
public functions would be good to satisfy.
+/*
+ * Reparent resource children of pr that conflict with res
+ * under res, and make res replace those children.
+ */
kernel doc format, though...
+static int reparent_resources(struct resource *parent,
+                                    struct resource *res)
...is it really public with static keyword?!


+{
+       for (pp = &parent->child; (p = *pp) != NULL; pp = &p->sibling) {
+               if (p->end < res->start)
+                       continue;
+               if (res->end < p->start)
+                       break;
+               if (p->start < res->start || p->end > res->end)
+                       return -1;      /* not completely contained */
Usually we are expecting real eeror codes.
+               if (firstpp == NULL)
+                       firstpp = pp;
+       }
+       if (firstpp == NULL)
+               return -1;      /* didn't find any conflicting entries? */
Ditto.
+}
+EXPORT_SYMBOL(reparent_resources);
-- 
With Best Regards,
Andy Shevchenko
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help