From nobody Sun Feb 8 11:26:22 2026 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4CB22877FA for ; Sat, 15 Nov 2025 13:49:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763214573; cv=none; b=STFxxeCYcvNUa9ya2mCib/Pv1QEcbUb5qxHSjyodGl/oRa9Ht+9bJ1i1LGUpXXQzNYt7YKyZXm0h/BvufcDNR47x7GVFbYkXdwcN2ltyI7sSlIJ42sYDg7H6pXsdvD2JSPEjpVAUu20sUuTVMo3K1uIgz648mRzW78y6rSPE8bY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763214573; c=relaxed/simple; bh=fmpEB35pIYZLj0gJCg7yla2LFVzXeaAL5ZdlyABTiC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r6jPq5XiG4G5Hiqt8LvUtXnr4HxxCqvcqFlpv2UaSUVWqLmjMWgS2eOOD84OgOeAKgPYvEzvfmNFxeHWi2NIxS3iV8ClZL2Qyl8eI7hdzk8qVA2HaolYPfQ5ewME6WVeUK5tEWL8Rl2505GA+6Sad08fkkEhxqEzHgvCSJIMbNc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Lt3M7JYb; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Lt3M7JYb" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763214564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GnCwOF+dI773dn/Glk11DJ97ct85y2yDFhHBMya8yK0=; b=Lt3M7JYbY+KOk1WCou+FAAgZEsu4P1TA3aNkNvI6owDvkZ/aWYWzIza1k9yUVWnfzErRWi qCJUMYDdb/GdiyLAOtcs3DOJ1hih0+CqKiTf42JFLj6YldLb25wq4eoL3Zd3Hjy4hQfVVI wQYfN59H/iYWGOW9ICvCuAVBqtKyA8U= From: Yuntao Wang To: Rob Herring , Saravana Kannan Cc: Geert Uytterhoeven , Catalin Marinas , James Morse , Baoquan He , Zhen Lei , Ard Biesheuvel , Mark Rutland , Geoff Levand , Andrew Morton , Changyuan Lyu , Alexander Graf , "Mike Rapoport (Microsoft)" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Yuntao Wang Subject: [PATCH v3 5/8] of/fdt: Simplify the logic of early_init_dt_scan_memory() Date: Sat, 15 Nov 2025 21:47:50 +0800 Message-ID: <20251115134753.179931-6-yuntao.wang@linux.dev> In-Reply-To: <20251115134753.179931-1-yuntao.wang@linux.dev> References: <20251115134753.179931-1-yuntao.wang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Use the existing helper functions to simplify the logic of early_init_dt_scan_memory() Signed-off-by: Yuntao Wang --- drivers/of/fdt.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index fdaee4906836..d378d4b4109f 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1033,8 +1033,8 @@ int __init early_init_dt_scan_memory(void) =20 fdt_for_each_subnode(node, fdt, 0) { const char *type =3D of_get_flat_dt_prop(node, "device_type", NULL); - const __be32 *reg, *endp; - int l; + const __be32 *reg; + int i, l; bool hotpluggable; =20 /* We are scanning "memory" nodes only */ @@ -1044,23 +1044,21 @@ int __init early_init_dt_scan_memory(void) if (!of_fdt_device_is_available(fdt, node)) continue; =20 - reg =3D of_get_flat_dt_prop(node, "linux,usable-memory", &l); + reg =3D of_flat_dt_get_addr_size_prop(node, "linux,usable-memory", &l); if (reg =3D=3D NULL) - reg =3D of_get_flat_dt_prop(node, "reg", &l); + reg =3D of_flat_dt_get_addr_size_prop(node, "reg", &l); if (reg =3D=3D NULL) continue; =20 - endp =3D reg + (l / sizeof(__be32)); hotpluggable =3D of_get_flat_dt_prop(node, "hotpluggable", NULL); =20 - pr_debug("memory scan node %s, reg size %d,\n", + pr_debug("memory scan node %s, reg {addr,size} entries %d,\n", fdt_get_name(fdt, node, NULL), l); =20 - while ((endp - reg) >=3D (dt_root_addr_cells + dt_root_size_cells)) { + for (i =3D 0; i < l; i++) { u64 base, size; =20 - base =3D dt_mem_next_cell(dt_root_addr_cells, ®); - size =3D dt_mem_next_cell(dt_root_size_cells, ®); + of_flat_dt_read_addr_size(reg, i, &base, &size); =20 if (size =3D=3D 0) continue; --=20 2.51.0