[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPcyv4huU32+oMeoF8-HmmctafZ_uOZN-v85O5M8Ka8pBXP+Lg@mail.gmail.com>
Date: Mon, 9 Apr 2018 08:38:18 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Baoquan He <bhe@...hat.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Patrik Jakobsson <patrik.r.jakobsson@...il.com>,
David Airlie <airlied@...ux.ie>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
Keith Busch <keith.busch@...el.com>,
Jonathan Derrick <jonathan.derrick@...el.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Brijesh Singh <brijesh.singh@....com>,
Jérôme Glisse <jglisse@...hat.com>,
Borislav Petkov <bp@...e.de>,
Tom Lendacky <thomas.lendacky@....com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Yaowei Bai <baiyaowei@...s.chinamobile.com>,
Wei Yang <richard.weiyang@...il.com>,
devel@...uxdriverproject.org, linux-input@...r.kernel.org,
linux-nvdimm <linux-nvdimm@...ts.01.org>,
Device Tree <devicetree@...r.kernel.org>,
linux-pci@...r.kernel.org
Subject: Re: [PATCH v3 1/3] resource: Use list_head to link resource sibling
On Mon, Apr 9, 2018 at 2:08 AM, Baoquan He <bhe@...hat.com> wrote:
> The struct resource uses singly linked list to link siblings. It's not
> easy to do reverse iteration on sibling list. So replace it with list_head.
>
> And code refactoring makes codes in kernel/resource.c more readable than
> pointer operation.
>
> Besides, type of member variables of struct resource, sibling and child, are
> changed from 'struct resource *' to 'struct list_head'. Kernel size will
> increase because of those statically defined struct resource instances.
>
> Signed-off-by: Baoquan He <bhe@...hat.com>
> ---
[..]
> diff --git a/kernel/resource.c b/kernel/resource.c
> index e270b5048988..473c624606f9 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -31,6 +31,8 @@ struct resource ioport_resource = {
> .start = 0,
> .end = IO_SPACE_LIMIT,
> .flags = IORESOURCE_IO,
> + .sibling = LIST_HEAD_INIT(ioport_resource.sibling),
> + .child = LIST_HEAD_INIT(ioport_resource.child),
> };
> EXPORT_SYMBOL(ioport_resource);
>
> @@ -39,6 +41,8 @@ struct resource iomem_resource = {
> .start = 0,
> .end = -1,
> .flags = IORESOURCE_MEM,
> + .sibling = LIST_HEAD_INIT(iomem_resource.sibling),
> + .child = LIST_HEAD_INIT(iomem_resource.child),
> };
> EXPORT_SYMBOL(iomem_resource);
>
> @@ -57,20 +61,32 @@ static DEFINE_RWLOCK(resource_lock);
> * by boot mem after the system is up. So for reusing the resource entry
> * we need to remember the resource.
> */
> -static struct resource *bootmem_resource_free;
> +static struct list_head bootmem_resource_free = LIST_HEAD_INIT(bootmem_resource_free);
> static DEFINE_SPINLOCK(bootmem_resource_lock);
>
> +struct resource *sibling(struct resource *res)
> +{
> + if (res->parent && !list_is_last(&res->sibling, &res->parent->child))
> + return list_next_entry(res, sibling);
> + return NULL;
> +}
> +
> +struct resource *first_child(struct list_head *head)
> +{
> + return list_first_entry_or_null(head, struct resource, sibling);
> +}
> +
These names are too generic for new global symbols. A "resource_"
prefix is warranted.
Powered by blists - more mailing lists