Received: by 10.213.65.68 with SMTP id h4csp2768033imn; Mon, 9 Apr 2018 08:44:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+XYbGbFu8eDlnLDg1nbqM6TYNUJF0hVOayDuvRqFoXOPTbqOrgNllygpdkxIkX2mYmqKfK X-Received: by 10.101.90.140 with SMTP id c12mr25671026pgt.191.1523288647834; Mon, 09 Apr 2018 08:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523288647; cv=none; d=google.com; s=arc-20160816; b=XfWmSJQfyNGugJm6z6J9Lejy0HXgzJp2kRYl/v2q5rMf2c4Ox2hUELaqFwE0HAtNND 8WZsA2NNNPtUqBdFq6T1qpESzrRvj0CSmsATKMlDzjNNwQW+70sHM00TwZB/VCLxQC2A pEkStMv1aI2akvF2GQl+qqLDv/ajSMmKLV8hBMK3nBPRBmnlYalFr9NsXATMKY5/m3Ko iJjb3lEFdXnowuWdIs/VvDd83jGG8wHNFdkMBTKGLlNHsUIguBi28LusMmwnhrAE0E5m hQuN7IGyZ1cFwEuNgED6mXHPdiDmdmVzvFT4Dfr3xrbuqnWPQfMcKQJ056ZO6ZF/9/fD Sz7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=jCHu9CQBXDgkk6KrRMXW7rra69ATA/yZg6MaHvu0uBw=; b=F7cgG44tpyyBX5Pz+ld+cq0P+LlMj17dcmz1W0dBGlsHXvd1WIzHwKx0i/AFgpTQIc FO5XOKmUcUy/ZpUC2oSu/BhECoNUusQRc/FX0kog3OcI0NzyGhYBHdSu49i0b/dyQJSN g4CMU+bTRFev0zsVOZFZe4RVKow6L3z8gAxDAf3vM48cEL0oHRHyaRAHlu26PJJwKVC7 fHVcQedkBzz8l0EHCbsG/RGsUumZzE6ji+XtdMBB5/2xbNiPPtytk1EryElebFC/DAwy HBzJuTpB0G50NWHFixSsPE8BwjH6ptsUIajRFWzfeo9SsTrLxXOIH4mzUyqqCvd6brR/ 2cFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=iVa57riu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64-v6si527959plf.627.2018.04.09.08.43.19; Mon, 09 Apr 2018 08:44:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=iVa57riu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753118AbeDIPiW (ORCPT + 99 others); Mon, 9 Apr 2018 11:38:22 -0400 Received: from mail-ot0-f195.google.com ([74.125.82.195]:46626 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752320AbeDIPiT (ORCPT ); Mon, 9 Apr 2018 11:38:19 -0400 Received: by mail-ot0-f195.google.com with SMTP id v64-v6so9093056otb.13 for ; Mon, 09 Apr 2018 08:38:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jCHu9CQBXDgkk6KrRMXW7rra69ATA/yZg6MaHvu0uBw=; b=iVa57riu9qhU+MnGy1IGXmETt02zBqjJ3pvbJ1GXKMIEcXH9kKvEycJixDlZL8xvWj umbemt/fly57IeXpcSCccaWLjDg165Dpmm5c6FuxBaKeIovkdlX34TfLzdS5d1+CYBTd umqdUPCcOYhS1NMP0VI2ipfVz51WXHUWQZB+BtWOHzINCh8YJUuhgYtqdEaodFNm628f mIKsNRuBmtHvuapUUL6P2vtE4YkafvaPnRKefgjD8J2MRyqQjmgqKNxGU5zGv04u7KoZ 62/lfgrDvMjJSe+5qTR1yGazqL4s+QonG1mfQ5FA4JOgaDPA96bLKNQ5dKVj0hh5CMPO oXYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=jCHu9CQBXDgkk6KrRMXW7rra69ATA/yZg6MaHvu0uBw=; b=HpZ4Hv/W/zUo7UGGWczgyw+ph3cYfeRRdE23R6OOcTGMGWF/mE+CRI2r4NraETRHR+ RGR2yKgsr+LkOuYq77kRl0Z5HTyUIULvfD+TgfCEF9YqZm6pa9klZB0ynlVWKo9OJMnM uVMc2IGvpRstg55uqO8ln9etaJjmzuuFpKnuEyR7tNz61m1Vu8sBw9djGHwU3VFAQcg4 X2/biMazl1ifuFsqUsdhNW9tnMcmr3N4uP0YR5Ueur9D369SKVWHe36HasbV+sQnBbX+ su8jdN0XQY1YLGDfx1574i9llhWW1MtyVE5RsDHeTJCVUFUj3nREi1K8v2gTk6vJm8um nuBQ== X-Gm-Message-State: AElRT7F7zxNooEpLkObQyuZlAwD8S8IDx81zJl/SqCApv/PEFS9GxC7l 6Ju4eAmmdMPlO9iuwovgvGIfV5GJbZf+Gen6ZTSBeg== X-Received: by 2002:a9d:5f15:: with SMTP id f21-v6mr24424330oti.387.1523288298746; Mon, 09 Apr 2018 08:38:18 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2435:0:0:0:0:0 with HTTP; Mon, 9 Apr 2018 08:38:18 -0700 (PDT) In-Reply-To: <20180409090853.GJ19345@localhost.localdomain> References: <20180408024724.16812-1-bhe@redhat.com> <20180408024724.16812-2-bhe@redhat.com> <20180409090853.GJ19345@localhost.localdomain> From: Dan Williams Date: Mon, 9 Apr 2018 08:38:18 -0700 Message-ID: Subject: Re: [PATCH v3 1/3] resource: Use list_head to link resource sibling To: Baoquan He Cc: Linux Kernel Mailing List , Patrik Jakobsson , David Airlie , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Dmitry Torokhov , Rob Herring , Frank Rowand , Keith Busch , Jonathan Derrick , Lorenzo Pieralisi , Bjorn Helgaas , Thomas Gleixner , Brijesh Singh , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Borislav Petkov , Tom Lendacky , Greg Kroah-Hartman , Yaowei Bai , Wei Yang , devel@linuxdriverproject.org, linux-input@vger.kernel.org, linux-nvdimm , Device Tree , linux-pci@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 9, 2018 at 2:08 AM, Baoquan He 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 > --- [..] > 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.