From patchwork Tue Aug 6 10:38:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keerthy X-Patchwork-Id: 1142696 X-Patchwork-Delegate: trini@ti.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=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="NaqQJ9xF"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 462rl23mTpz9s00 for ; Tue, 6 Aug 2019 20:40:46 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 41913C21E7D; Tue, 6 Aug 2019 10:39:29 +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=T_DKIM_INVALID 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 BA8C4C21DF3; Tue, 6 Aug 2019 10:39:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AEB86C21BE5; Tue, 6 Aug 2019 10:38:38 +0000 (UTC) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lists.denx.de (Postfix) with ESMTPS id 52B67C21E07 for ; Tue, 6 Aug 2019 10:38:35 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x76AcX2J112873; Tue, 6 Aug 2019 05:38:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1565087913; bh=IEBRR9S/Xo2MLAD1QxBYOCrH2zRFL4lzZZT/hbg1Gk0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=NaqQJ9xFYpd9+07J4CDbPrOK8HtezJWkm+AP4ikfKpTtLVbRRoIBukteuMDHccI78 9KgSrZla6xcrxT0tbItXzGyr1gcZGIjZVbEG7j5ettTKxWbhY3X0rxM2JtFqjVEJoX aR+LzBk2oGJ9w/ULgk4s2VpfSPc7yJniF/wYOe7Q= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x76AcXb2123953 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Aug 2019 05:38:33 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 6 Aug 2019 05:38:33 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 6 Aug 2019 05:38:33 -0500 Received: from a0393675ula.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x76AcKvD013727; Tue, 6 Aug 2019 05:38:30 -0500 From: Keerthy To: , , , Date: Tue, 6 Aug 2019 16:08:33 +0530 Message-ID: <20190806103844.25277-4-j-keerthy@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190806103844.25277-1-j-keerthy@ti.com> References: <20190806103844.25277-1-j-keerthy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: t-kristo@ti.com, u-boot@lists.denx.de, rogerq@ti.com Subject: [U-Boot] [PATCH 03/14] misc: uclass: Introduce misc_init_by_ofnode 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Introduce misc_init_by_ofnode to probe a misc device using its ofnode. Signed-off-by: Keerthy --- drivers/misc/misc-uclass.c | 25 +++++++++++++++++++++++++ include/misc.h | 9 +++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c index 55381edc98..835d3f7118 100644 --- a/drivers/misc/misc-uclass.c +++ b/drivers/misc/misc-uclass.c @@ -5,6 +5,8 @@ #include #include +#include +#include #include #include @@ -65,6 +67,29 @@ int misc_set_enabled(struct udevice *dev, bool val) return ops->set_enabled(dev, val); } +int misc_init_by_ofnode(ofnode node) +{ + struct udevice *dev = NULL; + int ret; + long temp1, temp2; + + temp1 = ofnode_to_offset(node); + + for (ret = uclass_find_first_device(UCLASS_MISC, &dev); dev; + ret = uclass_find_next_device(&dev)) { + temp2 = ofnode_to_offset(dev_ofnode(dev)); + if (temp1 == temp2) { + ret = device_probe(dev); + if (ret) + debug("%s: Failed to initialize - %d\n", + dev->name, ret); + return ret; + } + } + + return -ENODEV; +} + UCLASS_DRIVER(misc) = { .id = UCLASS_MISC, .name = "misc", diff --git a/include/misc.h b/include/misc.h index 12d1325ee2..79263ed480 100644 --- a/include/misc.h +++ b/include/misc.h @@ -76,6 +76,15 @@ int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size, */ int misc_set_enabled(struct udevice *dev, bool val); +/** + * misc_init_by_ofnode() - Probe a misc device by using ofnode. + * @node: ofnode of the misc device. + * + * A misc device is probed using ofnode. + * + * Return: -ve on error, 0 on success + */ +int misc_init_by_ofnode(ofnode node); /* * struct misc_ops - Driver model Misc operations *