From patchwork Thu Aug 30 19:05:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 145583 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp256958ljw; Thu, 30 Aug 2018 12:05:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYYBu17Ni6Sj5tX+YgqffZ/SsDV9KqpCY38crwT4vItg1N7OasPhQJ9pUqO2ytodUtVURX7 X-Received: by 2002:a62:aa02:: with SMTP id e2-v6mr11793429pff.211.1535655929531; Thu, 30 Aug 2018 12:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535655929; cv=none; d=google.com; s=arc-20160816; b=dG9FahH+rY32xHdy2/5g1rXDnYo0Hyc9FJPzH34V9Sjnm6GJvTkbV62jOwlgFK5blU MWzU+zEpr32UM94zWe86haMp9vwQ7IAFCXbe+PRAgy8ysQAbzldv9G6BXkyKfFR/3sj5 FOq7D3HSNBbbo7tGAJCdawcHspcLv55UORUXtRbWxZsezA0Z9BzwLe+pzMN3sTcOV3Bg +YuWOC968Cmkqv9HtAYTNlQ2KNATCJ0mC2+WEcNgaVmAOhkTlR7A3VK6Vp+F9gcjtsdW s3PzSX3LbE6RkWsWDRJ5XPS+3UOriWG2AtBPGIHRdtPAeaQmwLfiAOKBuBuzi3U/kvM9 Byxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=NFRDAdeXgojs+I7CCW5N+ajSHg8zEmxjFne5PsPUOg0=; b=xzg7ioDOWmqcN4Ee/lWAPhkhuWxOMe+v9vlvypgQgPlbLMr8o3IL5nppLbYzombWFG x3VCJ8DvtJn8qj0MSmponAlc2UtQfTRJ4ckwIULAK880CX53yzmF/8tm8/FULhhIVsiZ 95srmYoWfwfKUovNDmOgBnRpKCg0/r7x9VIshaSplDgiiXaIB7Hm5Ns8VQZkarGoX8jy frvwjWKDlmGU5IhoxB7RaJE9I0vEPUAmPevIrLB5XmPbkurbYIThxJ/QwiQFrhE7PVAU MUjXu3PPleN7DXc/0oOA3MZjZ9CG0qHmFnBhmYg0yeUie2jVSXJcjDn+QyDE/HPP7/g9 7QLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r16-v6si7397711pgg.254.2018.08.30.12.05.29; Thu, 30 Aug 2018 12:05:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727426AbeH3XJF (ORCPT + 6 others); Thu, 30 Aug 2018 19:09:05 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36728 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727550AbeH3XJD (ORCPT ); Thu, 30 Aug 2018 19:09:03 -0400 Received: by mail-oi0-f65.google.com with SMTP id r69-v6so17396898oie.3; Thu, 30 Aug 2018 12:05:26 -0700 (PDT) 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:in-reply-to :references; bh=NFRDAdeXgojs+I7CCW5N+ajSHg8zEmxjFne5PsPUOg0=; b=j+febYY946FONWbzXrB3GCNrKcEwOIQVRWf3xix30WNJZ9iChcK9sh7UU90KxdrqAj bjbJfRLgS8zA+i3qDG0NWSeh1L5nHn0n0oYrUZiqtdGnFZDckl68skNHh9EEFtpdcpm1 L1mrzPpHvzB/LVERfvjyIiW6uLq4jnlaE8bzuq58+IW9hkE2qEWO2qE0uZs/dICwcNk5 ffmDuF0oMav3fBKRY1T+GJ4zVU9l3s8X46OGVvC5DxqHj/Mr9yjv7DMO045BueGmCO+x jKH7gCLlIamlOcDJsXN9W9HpZonxwG5S/kUDMSL1xuDVFtU9jcSug92yb6stDTqH9glO Fh7g== X-Gm-Message-State: APzg51BbcwgE3EEA5/5GHQXEBimBYZEd/Vimx0ZQHM82TvT25E6Pi5lA LIJI4PX3Tf7AcZqOpL7fUMvN+8k= X-Received: by 2002:aca:dec6:: with SMTP id v189-v6mr3622229oig.98.1535655926189; Thu, 30 Aug 2018 12:05:26 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id 22-v6sm4200423oix.58.2018.08.30.12.05.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 12:05:25 -0700 (PDT) From: Rob Herring To: Frank Rowand , devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/3] of/fdt: avoid re-parsing '#{address, size}-cells' in of_fdt_limit_memory Date: Thu, 30 Aug 2018 14:05:22 -0500 Message-Id: <20180830190523.31474-3-robh@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830190523.31474-1-robh@kernel.org> References: <20180830190523.31474-1-robh@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Now that we initialize dt_root_addr_cells and dt_root_size_cells earlier, use them and simplify of_fdt_limit_memory. Cc: Frank Rowand Signed-off-by: Rob Herring --- drivers/of/fdt.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) -- 2.17.1 diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 49abe18f1bde..fef4b2c8a171 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -44,28 +44,7 @@ void of_fdt_limit_memory(int limit) int memory; int len; const void *val; - int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; - int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; - const __be32 *addr_prop; - const __be32 *size_prop; - int root_offset; - int cell_size; - - root_offset = fdt_path_offset(initial_boot_params, "/"); - if (root_offset < 0) - return; - - addr_prop = fdt_getprop(initial_boot_params, root_offset, - "#address-cells", NULL); - if (addr_prop) - nr_address_cells = fdt32_to_cpu(*addr_prop); - - size_prop = fdt_getprop(initial_boot_params, root_offset, - "#size-cells", NULL); - if (size_prop) - nr_size_cells = fdt32_to_cpu(*size_prop); - - cell_size = sizeof(uint32_t)*(nr_address_cells + nr_size_cells); + int cell_size = sizeof(uint32_t)*(dt_root_addr_cells + dt_root_size_cells); memory = fdt_path_offset(initial_boot_params, "/memory"); if (memory > 0) {