From patchwork Fri Aug 31 14:57:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 964534 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 4222kf3Wyyz9ryn for ; Sat, 1 Sep 2018 01:06:33 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 960D9C21E08; Fri, 31 Aug 2018 15:02:22 +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 90AFBC21DC1; Fri, 31 Aug 2018 14:58:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A834CC21E2F; Fri, 31 Aug 2018 14:58:14 +0000 (UTC) Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 0E1D2C21DF8 for ; Fri, 31 Aug 2018 14:58:10 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id 659A2208C7; Fri, 31 Aug 2018 16:58:10 +0200 (CEST) Received: from localhost.localdomain (AAubervilliers-681-1-92-107.w90-88.abo.wanadoo.fr [90.88.33.107]) by mail.bootlin.com (Postfix) with ESMTPSA id 33B2122A3E; Fri, 31 Aug 2018 16:57:52 +0200 (CEST) From: Miquel Raynal To: u-boot@lists.denx.de Date: Fri, 31 Aug 2018 16:57:39 +0200 Message-Id: <20180831145741.17350-12-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180831145741.17350-1-miquel.raynal@bootlin.com> References: <20180831145741.17350-1-miquel.raynal@bootlin.com> Cc: Tom Rini , Miquel Raynal , Stefan Roese , Jagan Teki , alexandre@bootlin.com Subject: [U-Boot] [PATCH v7 11/13] 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);