From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 414lTm3w3mzF4DN for ; Tue, 12 Jun 2018 19:49:32 +1000 (AEST) Date: Tue, 12 Jun 2018 17:49:23 +0800 From: Baoquan He To: Andy Shevchenko Cc: Linux Kernel Mailing List , Andrew Morton , Rob Herring , Dan Williams , Nicolas Pitre , Josh Triplett , kbuild test robot , Borislav Petkov , Patrik Jakobsson , David Airlie , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Dmitry Torokhov , Frank Rowand , Keith Busch , Jon Derrick , Lorenzo Pieralisi , Bjorn Helgaas , Thomas Gleixner , brijesh.singh@amd.com, =?iso-8859-1?B?Suly9G1l?= Glisse , Tom Lendacky , Greg Kroah-Hartman , baiyaowei@cmss.chinamobile.com, richard.weiyang@gmail.com, devel@linuxdriverproject.org, linux-input , linux-nvdimm@lists.01.org, devicetree , linux-pci@vger.kernel.org, Eric Biederman , Vivek Goyal , Dave Young , Yinghai Lu , kexec@lists.infradead.org, Michal Simek , "David S. Miller" , Chris Zankel , Max Filippov , Gustavo Padovan , Maarten Lankhorst , Sean Paul , linux-parisc@vger.kernel.org, "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Subject: Re: [PATCH v5 1/4] resource: Move reparent_resources() to kernel/resource.c and make it public Message-ID: <20180612094923.GD1820@MiWiFi-R3L-srv> References: <20180612032831.29747-1-bhe@redhat.com> <20180612032831.29747-2-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On 06/12/18 at 11:29am, Andy Shevchenko wrote: > On Tue, Jun 12, 2018 at 6:28 AM, Baoquan He 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... Will rewrite it, thanks. > > > +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