All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: u-boot@lists.denx.de
Subject: [PATCH 1/2] fdt_support: call mtdparts_init() after finding MTD node to fix up
Date: Wed, 15 Jul 2020 19:56:37 +0900	[thread overview]
Message-ID: <20200715105638.19140-1-yamada.masahiro@socionext.com> (raw)

Platform code can call fdt_fixup_mtdparts() in order to hand U-Boot's
MTD partitions over to the Linux device tree.

Currently, fdt_fixup_mtdparts() calls mtdparts_init() in its entry.
If no target MTD device is found, an error message like follows is
displayed:

    Device nand0 not found!

This occurs when the same code (e.g. arch/arm/mach-uniphier/fdt-fixup.c)
is shared among several boards, but not all boards support an MTD device.

Parse the DT first, then call mtdparts_init() only when the target MTD
node is found.

Yet, you still need to call mtdparts_init() before device_find().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 common/fdt_support.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index b010d0b552ad..717b2b6354c0 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -951,9 +951,7 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
 	struct mtd_device *dev;
 	int i, idx;
 	int noff;
-
-	if (mtdparts_init() != 0)
-		return;
+	bool initialized = false;
 
 	for (i = 0; i < node_info_size; i++) {
 		idx = 0;
@@ -963,6 +961,13 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
 			debug("%s: %s, mtd dev type %d\n",
 				fdt_get_name(blob, noff, 0),
 				node_info[i].compat, node_info[i].type);
+
+			if (!initialized) {
+				if (mtdparts_init() != 0)
+					return;
+				initialized = true;
+			}
+
 			dev = device_find(node_info[i].type, idx++);
 			if (dev) {
 				if (fdt_node_set_part_info(blob, noff, dev))
-- 
2.17.1

             reply	other threads:[~2020-07-15 10:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15 10:56 Masahiro Yamada [this message]
2020-07-15 10:56 ` [PATCH 2/2] fdt_support: skip MTD node with "disabled" in fdt_fixup_mtdparts() Masahiro Yamada
2020-07-16 15:43   ` Simon Glass
2020-07-17  1:35     ` Masahiro Yamada
2020-07-26 14:54       ` Simon Glass
2020-07-16 15:43 ` [PATCH 1/2] fdt_support: call mtdparts_init() after finding MTD node to fix up Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200715105638.19140-1-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.