From patchwork Mon Oct 1 13:43:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 977249 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 42P3S00WDmz9s4V for ; Mon, 1 Oct 2018 23:44:47 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5DC3CC21F4D; Mon, 1 Oct 2018 13:44:10 +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 E2079C21EB4; Mon, 1 Oct 2018 13:43:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2EFA0C21DD9; Mon, 1 Oct 2018 13:43:34 +0000 (UTC) Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id D2641C21DFD for ; Mon, 1 Oct 2018 13:43:33 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id 6F3FD20A2E; Mon, 1 Oct 2018 15:43:32 +0200 (CEST) Received: from localhost.localdomain (AAubervilliers-681-1-24-95.w90-88.abo.wanadoo.fr [90.88.144.95]) by mail.bootlin.com (Postfix) with ESMTPSA id 1322820703; Mon, 1 Oct 2018 15:43:32 +0200 (CEST) From: Miquel Raynal To: Jagan Teki , Tom Rini , Daniel Schwierzeck Date: Mon, 1 Oct 2018 15:43:25 +0200 Message-Id: <20181001134331.9756-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181001134331.9756-1-miquel.raynal@bootlin.com> References: <20181001134331.9756-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 v13 1/7] 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 548e7f191b..6e6da3002f 100644 --- a/include/mtd.h +++ b/include/mtd.h @@ -19,4 +19,6 @@ static inline struct mtd_info *mtd_get_info(struct udevice *dev) return dev_get_uclass_priv(dev); } +int mtd_probe(struct udevice *dev); + #endif /* _MTD_H_ */