From patchwork Thu Nov 16 04:23:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 10060653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5242560230 for ; Thu, 16 Nov 2017 04:25:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 459E32A74F for ; Thu, 16 Nov 2017 04:25:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A80F2A755; Thu, 16 Nov 2017 04:25:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD9692A74F for ; Thu, 16 Nov 2017 04:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758349AbdKPEZt (ORCPT ); Wed, 15 Nov 2017 23:25:49 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:38340 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758319AbdKPEZs (ORCPT ); Wed, 15 Nov 2017 23:25:48 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id vAG4OrmY029961; Wed, 15 Nov 2017 22:24:53 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1510806293; bh=+HNAxS07uBvHB9DViV7NW8oWUbXU83QOto7c6Tf4nIA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=R9H1VYnEgXWr5EIVCEqNeSAfNiOP1OpvF0HfBSjvgqDcDY9nYeUvb0Dau7WzNZiO0 479XiHchotvhw/hHSP/6YaLtF/j6xUdw1Jmlw5UZUXfi6pvUcnsVhcSqyhL9ksXXeu NKxyi0HejNxHuhD7y+LdUI7jHPz88HM0m83Hc6w0= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id vAG4OrVB031195; Wed, 15 Nov 2017 22:24:53 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Wed, 15 Nov 2017 22:24:53 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Wed, 15 Nov 2017 22:24:53 -0600 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id vAG4ODg4015762; Wed, 15 Nov 2017 22:24:49 -0600 From: Keerthy To: , , CC: , , , , , , , , , Subject: [PATCH v3 7/9] of: platform: Add a function to get platfrom data from device node Date: Thu, 16 Nov 2017 09:53:40 +0530 Message-ID: <1510806222-22096-8-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1510806222-22096-1-git-send-email-j-keerthy@ti.com> References: <1510806222-22096-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a function to get platfrom data from device node. Signed-off-by: Keerthy --- drivers/of/platform.c | 23 +++++++++++++++++++++++ include/linux/of_platform.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b7cf84b..b9edfcf 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -60,6 +60,29 @@ struct platform_device *of_find_device_by_node(struct device_node *np) } EXPORT_SYMBOL(of_find_device_by_node); +/** + * of_find_platdata_by_node - Find the platform_data associated with a node + * @np: Pointer to device tree node + * + * Fetches the platform device pointer of device tree node and in turn gets the + * associated platform data. + * + * Returns platform_data pointer, or NULL if not found + */ +void *of_find_platdata_by_node(struct device_node *np) +{ + struct platform_device *pdev; + + pdev = of_find_device_by_node(np); + if (!pdev) { + pr_err("Unable to find pdev\n"); + return pdev; + } + + return dev_get_platdata(&pdev->dev); +} +EXPORT_SYMBOL(of_find_platdata_by_node); + #ifdef CONFIG_OF_ADDRESS /* * The following routines scan a subtree and registers a device for diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index fb908e5..77b770f 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -59,11 +59,17 @@ extern struct platform_device *of_device_alloc(struct device_node *np, struct device *parent); #ifdef CONFIG_OF extern struct platform_device *of_find_device_by_node(struct device_node *np); +extern void *of_find_platdata_by_node(struct device_node *np); #else static inline struct platform_device *of_find_device_by_node(struct device_node *np) { return NULL; } + +static void *of_find_platdata_by_node(struct device_node *np) +{ + return NULL; +} #endif /* Platform devices and busses creation */