Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752397AbbLEH03 (ORCPT ); Sat, 5 Dec 2015 02:26:29 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:36618 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751975AbbLEH02 (ORCPT ); Sat, 5 Dec 2015 02:26:28 -0500 From: Alexander Kuleshov To: Andrew Morton Cc: Tony Luck , Tang Chen , Pekka Enberg , Wei Yang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alexander Kuleshov Subject: [PATCH] mm/memblock: use memblock_insert_region() for the empty array Date: Sat, 5 Dec 2015 13:23:40 +0600 Message-Id: <1449300220-30108-1-git-send-email-kuleshovmail@gmail.com> X-Mailer: git-send-email 2.6.2.485.g1bc8fea Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1769 Lines: 53 We have the special case for an empty array in the memblock_add_range() function. In the same time we have almost the same functional in the memblock_insert_region() function. Let's use the memblock_insert_region() instead of direct initialization. Signed-off-by: Alexander Kuleshov --- mm/memblock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index d300f13..e8a897d 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -496,12 +496,16 @@ static void __init_memblock memblock_insert_region(struct memblock_type *type, struct memblock_region *rgn = &type->regions[idx]; BUG_ON(type->cnt >= type->max); - memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn)); + /* special case for empty array */ + if (idx) + { + memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn)); + type->cnt++; + } rgn->base = base; rgn->size = size; rgn->flags = flags; memblock_set_region_node(rgn, nid); - type->cnt++; type->total_size += size; } @@ -536,11 +540,7 @@ int __init_memblock memblock_add_range(struct memblock_type *type, /* special case for empty array */ if (type->regions[0].size == 0) { WARN_ON(type->cnt != 1 || type->total_size); - type->regions[0].base = base; - type->regions[0].size = size; - type->regions[0].flags = flags; - memblock_set_region_node(&type->regions[0], nid); - type->total_size = size; + memblock_insert_region(type, 0, base, size, nid, flags); return 0; } repeat: -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/