From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Tue, 30 Oct 2018 11:13:37 +0100 Subject: [U-Boot] [PATCH] cmd: mtdparts: Probe MTD devices in mtdparts_init() In-Reply-To: <20181030110354.48e1736d@bbrezillon> References: <20181030095151.12442-1-sr@denx.de> <20181030110354.48e1736d@bbrezillon> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de Hi Boris, On 30.10.18 11:03, Boris Brezillon wrote: > On Tue, 30 Oct 2018 10:51:51 +0100 > Stefan Roese wrote: > >> Calling "mtdparts" currently fails when its called before any other mtd >> command (or ubi command) has been called. The MTD devices are not >> probed at this point and therefore it fails e.g. with this message: >> >> => mtdparts >> Device spi-nand0 not found! > > IIRC, we decided that mtdparts should not call mtd_probe_devices() to > encourage people to stop using it. I see. But I don't quite get how this missing call (and reslting error message) would encourage people to stop using it. >> >> This patch adds a call to mtd_probe_devices() to mtdparts_init() to >> solve this issue. This also fixes a problem when calling "ubi part" >> as first flash storage related command. > > Hm, this one is unexpected. Miquel, any idea why this happens. Do we > need to enable a specific option if we want mtd_probe_devices() to be > called in the ubi part path? Please note that "ubi part part-foo" does still work. It only prints this error message before attaching the MTD partition. The error is printed because of this call-chain: ubi_part() -> ubi_detach() -> mtdparts_init() So again, mtdparts_init() is called without the MTD devices being probed. Thanks, Stefan >> Here also the warning from >> above is printed without this patch. >> >> Signed-off-by: Stefan Roese >> Cc: Miquel Raynal >> Cc: Boris Brezillon >> Cc: Jagan Teki >> --- >> cmd/mtdparts.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c >> index f7ed1a0779..d90e568143 100644 >> --- a/cmd/mtdparts.c >> +++ b/cmd/mtdparts.c >> @@ -73,6 +73,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -1726,6 +1727,9 @@ int mtdparts_init(void) >> char tmp_ep[PARTITION_MAXLEN + 1]; >> char tmp_parts[MTDPARTS_MAXLEN]; >> >> + /* First probe all MTD devices */ >> + mtd_probe_devices(); >> + >> debug("\n---mtdparts_init---\n"); >> if (!initialized) { >> INIT_LIST_HEAD(&mtdids); > Viele Grüße, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de