From patchwork Thu Sep 6 07:08:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 966831 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 425WyS2p0Vz9sDb for ; Thu, 6 Sep 2018 17:13:52 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 27071C21C27; Thu, 6 Sep 2018 07:12:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A89C3C21E42; Thu, 6 Sep 2018 07:09:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2E19EC21D74; Thu, 6 Sep 2018 07:09:05 +0000 (UTC) Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 354F7C21DB6 for ; Thu, 6 Sep 2018 07:09:00 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id 949E6208B9; Thu, 6 Sep 2018 09:09:00 +0200 (CEST) Received: from localhost.localdomain (AAubervilliers-681-1-30-219.w90-88.abo.wanadoo.fr [90.88.15.219]) by mail.bootlin.com (Postfix) with ESMTPSA id 37FAF20731; Thu, 6 Sep 2018 09:09:00 +0200 (CEST) From: Miquel Raynal To: Tom Rini , Jagan Teki Date: Thu, 6 Sep 2018 09:08:52 +0200 Message-Id: <20180906070854.9717-11-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180906070854.9717-1-miquel.raynal@bootlin.com> References: <20180906070854.9717-1-miquel.raynal@bootlin.com> Cc: Alexandre Belloni , Boris Brezillon , Antoine Tenart , Allan Nielsen , u-boot@lists.denx.de, Miquel Raynal , Stefan Roese Subject: [U-Boot] [PATCH v7 10/12] cmd: mtdparts: try to probe the MTD devices as a fallback X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Current implementation of mtdparts command errors out if the desired MTD device is not found. Fallback to the new probe function in this case before erroring out. This will the save the user the need to call something like 'mtd list' before mtdparts. Signed-off-by: Miquel Raynal Acked-by: Jagan Teki Reviewed-by: Stefan Roese --- cmd/mtdparts.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c index f7ed1a0779..a1102c3fc5 100644 --- a/cmd/mtdparts.c +++ b/cmd/mtdparts.c @@ -79,6 +79,10 @@ #include #include +#if defined(CONFIG_MTD) +#include +#endif + #if defined(CONFIG_CMD_NAND) #include #include @@ -307,9 +311,15 @@ static int get_mtd_info(u8 type, u8 num, struct mtd_info **mtd) sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(type), num); *mtd = get_mtd_device_nm(mtd_dev); - if (IS_ERR(*mtd)) { - printf("Device %s not found!\n", mtd_dev); - return 1; + if (IS_ERR_OR_NULL(*mtd)) { +#ifdef CONFIG_MTD + mtd_probe_devices(); + *mtd = get_mtd_device_nm(mtd_dev); +#endif + if (IS_ERR_OR_NULL(*mtd)) { + printf("Device %s not found!\n", mtd_dev); + return 1; + } } put_mtd_device(*mtd);