Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753482AbdLMCcO (ORCPT ); Tue, 12 Dec 2017 21:32:14 -0500 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:19326 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753396AbdLMCcK (ORCPT ); Tue, 12 Dec 2017 21:32:10 -0500 X-RM-TRANSID: 2ee65a309126904-fa5a9 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee45a30912532c-2907b Date: Tue, 12 Dec 2017 21:32:00 -0500 From: Yaowei Bai To: Joe Perches Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/8] mm/memblock: memblock_is_map/region_memory can be boolean Message-ID: <20171213023200.GC28668@byw> Reply-To: baiyaowei@cmss.chinamobile.com References: <1513047319-22302-1-git-send-email-baiyaowei@cmss.chinamobile.com> <1513047319-22302-2-git-send-email-baiyaowei@cmss.chinamobile.com> <1513094591.3036.55.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1513094591.3036.55.camel@perches.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1497 Lines: 48 On Tue, Dec 12, 2017 at 08:03:11AM -0800, Joe Perches wrote: > On Mon, 2017-12-11 at 21:55 -0500, Yaowei Bai wrote: > > This patch makes memblock_is_map/region_memory return bool due to these > > two functions only using either true or false as its return value. > [] > > @@ -1690,13 +1690,13 @@ int __init_memblock memblock_search_pfn_nid(unsigned long pfn, > > * RETURNS: > > * 0 if false, non-zero if true > > */ > > -int __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t size) > > +bool __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t size) > > { > > int idx = memblock_search(&memblock.memory, base); > > phys_addr_t end = base + memblock_cap_size(base, &size); > > > > if (idx == -1) > > - return 0; > > + return false; > > return (memblock.memory.regions[idx].base + > > memblock.memory.regions[idx].size) >= end; > > } > > I'd be more inclined to use a temporary for > memblock.memory.regions[idx] so the function was > something like: > > int __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t size) > { > phys_addr_t end; > struct memblock_region *region; > int idx = memblock_search(&memblock.memory, base); > > if (idx == -1) > return 0; > > end = base + memblock_cap_size(base, &size); > region = &memblock.memory.regions[idx]; > > return (region->base + region->size) >= end; > } It' better. > > Maybe change to bool at your option. Ok. You also can ack this one first. :)