lkml.org 
[lkml]   [2017]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/8] mm/memblock: memblock_is_map/region_memory can be boolean
From
Date
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;
}

Maybe change to bool at your option.

\
 
 \ /
  Last update: 2017-12-12 17:04    [W:0.112 / U:2.696 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site