From patchwork Thu Feb 3 14:14:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 1588019 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tq-group.com header.i=@tq-group.com header.a=rsa-sha256 header.s=key1 header.b=YH97mYX1; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.a=rsa-sha256 header.s=key1 header.b=a4jYOXP8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JqLKW5nw1z9s8s for ; Fri, 4 Feb 2022 01:15:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4520F836BF; Thu, 3 Feb 2022 15:15:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=tq-group.com header.i=@tq-group.com header.b="YH97mYX1"; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.b="a4jYOXP8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3D2C2836C3; Thu, 3 Feb 2022 15:15:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 12C9283388 for ; Thu, 3 Feb 2022 15:15:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=matthias.schiffer@ew.tq-group.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1643897703; x=1675433703; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Q1fw3yavN8zAIZ40F+/v0Mq4+JeceT82R4GQ7cWXawA=; b=YH97mYX1hSpijGaXXv0Bq5Y0ARiBNoyeSjDX/ec2u9HVNi45OBjOqkCe n3Z3WcY+jDhkpYMihpLWub2wdjqLjLPCSchtjypvSv7s2/2znBL9QQGnj SOgvzAVl4kmmS2aPGuQ+mq+voHD4BdkLnbflFE3nSboG5oL6ZjfDcLePQ tjYu7UQVMFazmuRT/ld/brJIifqNPEeORrAIL1gArgolJ59UGi42d0qHt SLHKS0PFS3dznhbo0rCzqcxsmLGRGqDoFLXTnYsHpsMFNeV+5U+aFe/FN +skeORHpFFtS7VSO79W/Y+p5LCDGwDHWISfcW6/38fjs6chBYOvgzCitD A==; X-IronPort-AV: E=Sophos;i="5.88,340,1635199200"; d="scan'208";a="21881779" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 03 Feb 2022 15:15:02 +0100 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Thu, 03 Feb 2022 15:15:02 +0100 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Thu, 03 Feb 2022 15:15:02 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1643897702; x=1675433702; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Q1fw3yavN8zAIZ40F+/v0Mq4+JeceT82R4GQ7cWXawA=; b=a4jYOXP8l7bEWhF7hyrMmasQdZ94becOlnxlMtaPRsUJ5ZoLzyRs4xqC 7jEk2Pe92ht27OWPXPtEDFUCgubHQhqwIBBNv05azD+0jpWAfuuOM9pIa R2I+smg0veCTtODmKzb8NJbUKqx79Lzw6xuf3jdP75Iyt0FNGApABmWnX o52cGWFPsl7I9Cvaviej5Mi7AHaZo6mGjZngrx2aKb3yn1hACOd3D6D1G llBweRIkDcn7URiWjA48iD12+1nfsUFJYu2Z4RjyWixRXKPmCr+vsvwxg +6az1rsDy66ZjW+5a/ypBvvQ0FhRaL4/NYoqKf/q36PraYZHEHqf3uGOT Q==; X-IronPort-AV: E=Sophos;i="5.88,340,1635199200"; d="scan'208";a="21881778" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 03 Feb 2022 15:15:02 +0100 Received: from localhost.localdomain (SCHIFFERM-M2.tq-net.de [10.121.201.138]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id 724AF280065; Thu, 3 Feb 2022 15:15:02 +0100 (CET) From: Matthias Schiffer To: Simon Glass Cc: u-boot@lists.denx.de, Matthias Schiffer Subject: [PATCH] common: fdt_support: add support for "partitions" subnode to fdt_fixup_mtdparts() Date: Thu, 3 Feb 2022 15:14:47 +0100 Message-Id: <20220203141447.986798-1-matthias.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Listing MTD partitions directly in the flash mode has been deprecated for a while for kernel Device Trees. Look for a node "partitions" in the found flash nodes and use it instead of the flash node itself for the partition list when it exists, so Device Trees following the current best practices can be fixed up. Signed-off-by: Matthias Schiffer Reviewed-by: Simon Glass --- common/fdt_support.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index daa24d4c10..ea18ea3f04 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -988,7 +988,7 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, { struct mtd_device *dev; int i, idx; - int noff; + int noff, parts; bool inited = false; for (i = 0; i < node_info_size; i++) { @@ -1014,7 +1014,12 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, dev = device_find(node_info[i].type, idx++); if (dev) { - if (fdt_node_set_part_info(blob, noff, dev)) + parts = fdt_subnode_offset(blob, noff, + "partitions"); + if (parts < 0) + parts = noff; + + if (fdt_node_set_part_info(blob, parts, dev)) return; /* return on error */ } }