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

Andy Shevchenko andy.shevchenko at gmail.com
Tue Jun 12 18:29:00 AEST 2018


On Tue, Jun 12, 2018 at 6:28 AM, Baoquan He <bhe at redhat.com> 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


More information about the Linuxppc-dev mailing list