From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752175AbcFBBl0 (ORCPT ); Wed, 1 Jun 2016 21:41:26 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:8274 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751628AbcFBBlY (ORCPT ); Wed, 1 Jun 2016 21:41:24 -0400 Subject: Re: [PATCH v2 2/5] of/numa: fix a memory@ node can only contains one memory block To: Rob Herring References: <1464427377-12712-1-git-send-email-thunder.leizhen@huawei.com> <1464427377-12712-3-git-send-email-thunder.leizhen@huawei.com> CC: Catalin Marinas , Will Deacon , linux-arm-kernel , Ganapatrao Kulkarni , Robert Richter , "David Daney" , Frank Rowand , "Grant Likely" , devicetree , linux-kernel , Zefan Li , Xinwei Hu , Tianhong Ding , Hanjun Guo From: "Leizhen (ThunderTown)" Message-ID: <574F8DA8.4040503@huawei.com> Date: Thu, 2 Jun 2016 09:36:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090206.574F8DB3.0081,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 362c90a543f2e5509651969985d60e60 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/6/2 4:13, Rob Herring wrote: > On Sat, May 28, 2016 at 4:22 AM, Zhen Lei wrote: >> For a normal memory@ devicetree node, its reg property can contains more >> memory blocks. >> >> Because we don't known how many memory blocks maybe contained, so we try >> from index=0, increase 1 until error returned(the end). >> >> Signed-off-by: Zhen Lei >> --- >> drivers/of/of_numa.c | 26 +++++++++----------------- >> 1 file changed, 9 insertions(+), 17 deletions(-) >> >> diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c >> index fb71b4e..fa85a51 100644 >> --- a/drivers/of/of_numa.c >> +++ b/drivers/of/of_numa.c >> @@ -63,13 +63,9 @@ static int __init of_numa_parse_memory_nodes(void) >> struct device_node *np = NULL; >> struct resource rsrc; >> u32 nid; >> - int r = 0; >> - >> - for (;;) { >> - np = of_find_node_by_type(np, "memory"); >> - if (!np) >> - break; >> + int i, r = 0; >> >> + for_each_node_by_type(np, "memory") { >> r = of_property_read_u32(np, "numa-node-id", &nid); >> if (r == -EINVAL) >> /* >> @@ -78,21 +74,17 @@ static int __init of_numa_parse_memory_nodes(void) >> * "numa-node-id" property >> */ >> continue; >> - else if (r) >> - /* some other error */ >> - break; >> >> - r = of_address_to_resource(np, 0, &rsrc); >> - if (r) { >> - pr_err("NUMA: bad reg property in memory node\n"); >> - break; >> - } >> + for (i = 0; !r && !of_address_to_resource(np, i, &rsrc); i++) >> + r = numa_add_memblk(nid, rsrc.start, rsrc.end + 1); >> >> - r = numa_add_memblk(nid, rsrc.start, rsrc.end + 1); >> - if (r) >> + if (!i || r) { >> + of_node_put(np); >> + pr_err("NUMA: bad property in memory node\n"); >> + r = r ? : -EINVAL; >> break; >> + } >> } >> - of_node_put(np); > > I believe you still need this and not the one above. You only need it > within the loop if you return. Otherwise, the last node always need to > be put. OK. Thanks. Addition with Matthias's suggestion, I will move "return" into this patch, so that this of_node_put(np) can be safely removed. > > With that, for the series: > > Acked-by: Rob Herring > > Rob > > . >