From patchwork Sat Sep 29 10:58:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 976573 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 42Mltr2pKzz9s55 for ; Sat, 29 Sep 2018 21:00:04 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id E1CDDC21E3B; Sat, 29 Sep 2018 10:59:40 +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=RCVD_IN_DNSWL_BLOCKED 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 4FA3AC21E2F; Sat, 29 Sep 2018 10:58:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B25BCC21DFB; Sat, 29 Sep 2018 10:58:51 +0000 (UTC) Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 695E0C21DEC for ; Sat, 29 Sep 2018 10:58:47 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id 1B49A20A82; Sat, 29 Sep 2018 12:58:46 +0200 (CEST) Received: from localhost.localdomain (unknown [91.224.148.103]) by mail.bootlin.com (Postfix) with ESMTPSA id 7209320A90; Sat, 29 Sep 2018 12:58:34 +0200 (CEST) From: Miquel Raynal To: Jagan Teki , Tom Rini , Daniel Schwierzeck Date: Sat, 29 Sep 2018 12:58:24 +0200 Message-Id: <20180929105830.13530-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180929105830.13530-1-miquel.raynal@bootlin.com> References: <20180929105830.13530-1-miquel.raynal@bootlin.com> Cc: Boris Brezillon , Antoine Tenart , Allan Nielsen , u-boot@lists.denx.de, Miquel Raynal , Stefan Roese Subject: [U-Boot] [PATCH v12 2/8] mtd: uclass: add probe function 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" The user might want to trigger the probe of any MTD device, export these functions so they can be called from a command source file. Signed-off-by: Miquel Raynal Acked-by: Jagan Teki Reviewed-by: Stefan Roese Reviewed-by: Boris Brezillon --- drivers/mtd/mtd-uclass.c | 16 ++++++++++++++++ include/mtd.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/mtd/mtd-uclass.c b/drivers/mtd/mtd-uclass.c index 9ca049c437..5418217431 100644 --- a/drivers/mtd/mtd-uclass.c +++ b/drivers/mtd/mtd-uclass.c @@ -5,9 +5,25 @@ #include #include +#include #include #include +/** + * mtd_probe - Probe the device @dev if not already done + * + * @dev: U-Boot device to probe + * + * @return 0 on success, an error otherwise. + */ +int mtd_probe(struct udevice *dev) +{ + if (device_active(dev)) + return 0; + + return device_probe(dev); +} + /* * Implement a MTD uclass which should include most flash drivers. * The uclass private is pointed to mtd_info. diff --git a/include/mtd.h b/include/mtd.h index 9e5c807294..75aca262d4 100644 --- a/include/mtd.h +++ b/include/mtd.h @@ -8,4 +8,6 @@ #include +int mtd_probe(struct udevice *dev); + #endif /* _MTD_H_ */