Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3242683imu; Sat, 24 Nov 2018 00:55:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/V1gWWKK9Mb4SX02d2dwYh35/OFk+yV6LhEClhsZJ/a+WhibVCbL7+ylX3E+FwbsFPlbMwz X-Received: by 2002:a17:902:8607:: with SMTP id f7mr18770125plo.123.1543049700379; Sat, 24 Nov 2018 00:55:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543049700; cv=none; d=google.com; s=arc-20160816; b=YBO0mZaCYvWnDTe9khGRWaUHMbzQ90AbVvAgysKqZUdKWBIcWeGMyT2HvRzB+xZvfJ DOv499eyqEBNKzXIPeQiGBi+H301WDxD2P+v+gg5PLxNKjOMVo+RvJF0v76Q3BtjTRkQ MblOyNRHc3YXm1UyUIyp1nGmlWbZ/l3XW7SuHQPrIk1FhzlnlAFvxsPd83/2hnCQu0BP /nUIQ9WyZbzA8zQxDB0eGFbBxx5RQaI5UI50sRzTHU0NnJzPqN75ytPKBVd+EjfJZkrZ gUyHPKiKYImdYxwNF5FWfOObJqI+pbI++HYgDc3u0CB7Up3qbC2D9Y6Q268VBunUhzR/ GP+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=8gTioXrfb1hYx42mMThFJ6Ee2wmmeYe6sGLfcA6NCF4=; b=SVLi1cyHfsYAzAqOCXU2QXgqrfVNGrP5zq8avS/n7Jg8Ie19epTDORH76zhLu9OZ2p 1tmYGOaPeoPq2BUDnT3yMwmXuc1CpOIae6icGx6HyXw+cMVrRbllrF92zro9fBqyEtUo TaTge3HT36HPzhEb6H3Vaff/YxAhdlw4pUu7qsatcgd/lBz+Tc0rJhx6rn9VX9xhNbF9 Q6hKUPQylxX0uXKHMON3yiLLvkcDtTYWwpnlmxtdLwIbtoBC0e3Ot+0+J1LzI/vijDGN 654S8FLmCBgzj3OqQPbgvS8F9vdtFqZl+lXUm51weSAwzN5jT8Rjl+Al1FeaTVFbQXPq cGxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vYewTL9Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n34si23165540pld.381.2018.11.24.00.54.46; Sat, 24 Nov 2018 00:55:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vYewTL9Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727468AbeKXJOr (ORCPT + 99 others); Sat, 24 Nov 2018 04:14:47 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45348 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727452AbeKXJOr (ORCPT ); Sat, 24 Nov 2018 04:14:47 -0500 Received: by mail-pf1-f193.google.com with SMTP id g62so3846396pfd.12 for ; Fri, 23 Nov 2018 14:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=8gTioXrfb1hYx42mMThFJ6Ee2wmmeYe6sGLfcA6NCF4=; b=vYewTL9QPPafvi2N1eOi2z6a7zFe8Yg9JWNZcpCtrzsUraWPrdjOkzqwX0gT4bPlKU E0rlwiyLrEznbQHhO8N6wKfS4bgpKwJryVgANrwjSkt9nBOfqKj8pibDcx6G5og6ajba 9HFUrT2bHrRR747kAK/yMhoEXZOF47lgG/PT3BCwZcjVUs54ZtVkzM1b6Gy56Vn79w08 Ld7KwFqcIO1mXAX/DhqwrShLsG7YoUCgKyTdYOW2kFdajqWBuevZe62J6nytMwQqhjfi MUlYi+JaQkWJxVe7AssVoEoF53jRakIIL2MjetM50R8gPcElF+HPFv8bZ9P9TZpogkHf eHeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8gTioXrfb1hYx42mMThFJ6Ee2wmmeYe6sGLfcA6NCF4=; b=f+0/otEjpPRq5px5YGwqRmKxCARZnPpX41fc4deLKILU8EKT1E48H16y4ZFOUtor7G sxCpLl38vtNvhVa2jb6bQ/URo43Dbf6nGDM3k1K7oWlSrpt9Tif7JpElRl1Mr5oGYABO yF6fCivlgcDGtSqYdudctVgZHA0QzreukB3R3y1CCbydrc1R4tUpQw5SWfELNu/rO+hi LogT24GlF6mlcj6VAkgVS9UJUdqCEpGchX9uOOddi7t1BkiOUwlr1dlY0Yftd85B6czF zT8CRIjeA5jO3k8Yj4hYY+VY4RwhBtPuLIgzplVW+cU5JgKFXOCgeXy8Vhvf4yVYS472 1h7g== X-Gm-Message-State: AA+aEWZI429Z0Kqs08ZYR5t27kgPz8kXE/9OjUo2+yM/J8mzZAoogBMZ L6SzXc80/h7ONi2+9BfX+qIfnqX0 X-Received: by 2002:a63:ea4f:: with SMTP id l15mr15498659pgk.102.1543012121902; Fri, 23 Nov 2018 14:28:41 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id e64-v6sm41919903pfc.122.2018.11.23.14.28.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 14:28:41 -0800 (PST) From: Wei Yang To: gregkh@linuxfoundation.org, rafael@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH] drivers/base/memory.c: remove an unnecessary check on NR_MEM_SECTIONS Date: Sat, 24 Nov 2018 06:28:11 +0800 Message-Id: <20181123222811.18216-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit cb5e39b8038b ("drivers: base: refactor add_memory_section() to add_memory_block()"), add_memory_block() is introduced, which is only invoked in memory_dev_init(). When combine these two loops in memory_dev_init() and add_memory_block(), they looks like this: for (i = 0; i < NR_MEM_SECTIONS; i += sections_per_block) for (j = i; (j < i + sections_per_block) && j < NR_MEM_SECTIONS; j++) Since it is sure (i < NR_MEM_SECTIONS) and j sits in its own memory block, the check of (j < NR_MEM_SECTIONS) is not necessary. This patch just removes this check. Signed-off-by: Wei Yang --- drivers/base/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 0e5985682642..547997a2249b 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -688,7 +688,7 @@ static int add_memory_block(int base_section_nr) int i, ret, section_count = 0, section_nr; for (i = base_section_nr; - (i < base_section_nr + sections_per_block) && i < NR_MEM_SECTIONS; + i < base_section_nr + sections_per_block; i++) { if (!present_section_nr(i)) continue; -- 2.15.1