From patchwork Fri Jul 13 10:12:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 141859 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp611083ljj; Fri, 13 Jul 2018 03:12:26 -0700 (PDT) X-Received: by 2002:a19:1190:: with SMTP id 16-v6mr4876838lfr.122.1531476746775; Fri, 13 Jul 2018 03:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531476746; cv=none; d=google.com; s=arc-20160816; b=M1vjcJ4dfZeYHFFZ85Mn/4vrrkkZUeSj1VtpbTta2t1jTnrAcZaEogIw1QHV0gSQnw mon2i9rn9gU588Gtx9apFaTCX7VQeud0g2ZbZ4SqX5r+jmhvg/yEocpO5XlnsCWQPCSQ gMQHPX9R07bi1LkB84M/hGwkiJ3eaOLq0OmwgSYGUU/a/x5Q9pjJRO6S3JDSBb3aFX+R vLp90e8u+QOpU/uqqAG7hG6NfXiXA4wgHVsSqz8LkXZHcDUK2djfEHi/vvP4SNtcslyr xBhZOa6NyErNYuIZFeIRPUbogouu1SY5aDZB52SHTnBoGuvqtLfHYC3sil1empJbBIpd 42jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=JPIlf6YEybOWmlRVNQGccoDdwrSOx0YoeZAEaziuZNc=; b=liZ9DibxSWcs14j1cL3MRrCjP8lnZHuSS+HCOXtHMmxGUWtoOIYHSBNDhExsfTYaFg lKpIksm/29BF5gxelAIcMzclc9C2Fljl8zzqOnfmlQIGJ4mnbZZ23f8LZhxw1YYc2ta2 jLFKFBdPZyj9RXNZojXWqVa5gzN363AGrMblm19yPQ0vnqH/YCiZGLW2ktJ5udNofVpv qW4JcWv0EFXn1mTXzD4I3OXi/jdyRJMmGXb6CPix0s5nUTMVe6rBp99oL9tetOHODiZD p1oyuRCLbgOf8RLkFHhK0vdpDrvYVdNvZQSMfOQIu5ZDwoQ5HzqV7+UvyD3sZx46M9uO E90w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mrz668KS; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p16-v6sor2576262lja.113.2018.07.13.03.12.26 for (Google Transport Security); Fri, 13 Jul 2018 03:12:26 -0700 (PDT) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mrz668KS; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=JPIlf6YEybOWmlRVNQGccoDdwrSOx0YoeZAEaziuZNc=; b=Mrz668KSvphlg46sOyWREx3cg+8awfhnbURSPeA1LZUFcfEm2TlQ1y+jhoZLDJq4+O cp40x2m0Nyod+t1a3x9xZbTj3+jgEVpDU/p8yQpx2FZzkFj4oO6XfMiMF1wcKPGzjlbk YhVBVyHccBd3JHu+PfejEDQbskSIbKBCDQe/8= 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=JPIlf6YEybOWmlRVNQGccoDdwrSOx0YoeZAEaziuZNc=; b=EHZJHuTcfOjqUApE3qwqIesVoNBTzi6b050kFjrGEGb0DqUFCuZxvGQ8PcQ0rmCW3g 9Ff4n2dMsJj0/MOu7sBU4YLsqh6D4D01xhF9Z13fdCcvxbdGBImYNUCIoXn+amrb3LWg UjT6CyvWnzG7bQzRp7BgzSse316eqjbXuhoBDCcrJOf3nXTGbRP8cy15wY4n79hw94mi 9K7LYhfjegbImTCi37M2MNmCSv+IIfYop4kuoBQf83Qwc8ACD9b5MAPzqgsLPljYn1F7 gB0oqYluxQDdob3owH/85mHgw9fXF/XR4csq6IWBoCat9u7OqRNW+reuiMB1ilLFIOY3 0rBQ== X-Gm-Message-State: AOUpUlHaJeX3/XDyCrqt7XW8w7sstk8QIiIy0ShHauW0OUh1i3Xf83+H E1qdFwpeMnVtFzMIqgVY6LZLatbV X-Google-Smtp-Source: AAOMgpdYokz/11rlfmgwDgBwAALoxKSzcJuPhBdc8gX1cwGnsGTU6T2AFs2ohmIPmaQQ660dE10/jQ== X-Received: by 2002:a2e:e3:: with SMTP id e96-v6mr2793083lji.82.1531476746581; Fri, 13 Jul 2018 03:12:26 -0700 (PDT) Return-Path: Received: from jax.urgonet (h-84-45.A175.priv.bahnhof.se. [79.136.84.45]) by smtp.gmail.com with ESMTPSA id m72-v6sm6699059lfm.49.2018.07.13.03.12.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 03:12:25 -0700 (PDT) From: Jens Wiklander To: u-boot@lists.denx.de Cc: Simon Glass , Jens Wiklander Subject: [PATCH] fdt: fix fdtdec_setup_memory_banksize() Date: Fri, 13 Jul 2018 12:12:11 +0200 Message-Id: <20180713101211.26028-1-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.17.1 Prior to this patch is fdtdec_setup_memory_banksize() incorrectly ignoring the "status" field. This patch fixes that by testing the status with fdtdec_get_is_enabled() before using a memory node. Signed-off-by: Jens Wiklander --- lib/fdtdec.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Simon Glass diff --git a/lib/fdtdec.c b/lib/fdtdec.c index f4e8dbf699a8..14005d71507c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1179,13 +1179,25 @@ int fdtdec_setup_memory_size(void) } #if defined(CONFIG_NR_DRAM_BANKS) + +static int get_next_memory_node(const void *blob, int startoffset) +{ + int mem = -1; + + do { + mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem, + "device_type", "memory", 7); + } while (!fdtdec_get_is_enabled(blob, mem)); + + return mem; +} + int fdtdec_setup_memory_banksize(void) { int bank, ret, mem, reg = 0; struct fdt_resource res; - mem = fdt_node_offset_by_prop_value(gd->fdt_blob, -1, "device_type", - "memory", 7); + mem = get_next_memory_node(gd->fdt_blob, -1); if (mem < 0) { debug("%s: Missing /memory node\n", __func__); return -EINVAL; @@ -1195,9 +1207,7 @@ int fdtdec_setup_memory_banksize(void) ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res); if (ret == -FDT_ERR_NOTFOUND) { reg = 0; - mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem, - "device_type", - "memory", 7); + mem = get_next_memory_node(gd->fdt_blob, mem); if (mem == -FDT_ERR_NOTFOUND) break;