From patchwork Thu Nov 26 13:47:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 7707061 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AF2EB9F2EC for ; Thu, 26 Nov 2015 13:51:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A86B8205BA for ; Thu, 26 Nov 2015 13:51:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B039B20483 for ; Thu, 26 Nov 2015 13:51:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752576AbbKZNuu (ORCPT ); Thu, 26 Nov 2015 08:50:50 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:40834 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752095AbbKZNru (ORCPT ); Thu, 26 Nov 2015 08:47:50 -0500 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NYF02U9DCZHHP40@mailout4.samsung.com>; Thu, 26 Nov 2015 22:47:41 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.112]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 1B.1A.30395.D7D07565; Thu, 26 Nov 2015 22:47:41 +0900 (KST) X-AuditID: cbfee68f-f79666d0000076bb-b1-56570d7d65be Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id C1.AF.00996.D7D07565; Thu, 26 Nov 2015 22:47:41 +0900 (KST) Received: from chan.10.32.193.11 ([10.252.81.195]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NYF00D4UCZGTXL0@mmp1.samsung.com>; Thu, 26 Nov 2015 22:47:40 +0900 (KST) From: Chanwoo Choi To: myungjoo.ham@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, k.kozlowski@samsung.com Cc: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, linux@arm.linux.org.uk, tjakobi@math.uni-bielefeld.de, cw00.choi@samsung.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org Subject: [RFC PATCH 06/15] PM / devfreq: Add devfreq_get_devfreq_by_phandle() Date: Thu, 26 Nov 2015 22:47:30 +0900 Message-id: <1448545659-32287-7-git-send-email-cw00.choi@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1448545659-32287-1-git-send-email-cw00.choi@samsung.com> References: <1448545659-32287-1-git-send-email-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRmVeSWpSXmKPExsWyRsSkQLeWNzzMYPd2aYvrX56zWsw/co7V ov/NQlaLc69WMlq8fmFo0f/4NbPF2aY37BaXd81hs/jce4TRYsb5fUwWty/zWiy9fhHIaFzB ZjFh+loWi9a9R9gt2lZ/YHUQ8Fgzbw2jR0tzD5vH5b5eJo+Vy7+weWxa1cnm8e8Yu0ffllWM Hp83yQVwRHHZpKTmZJalFunbJXBlnHnezFrwRbxi4ZWjLA2M/4W7GDk5JARMJBZP2sECYYtJ XLi3nq2LkYtDSGAFo8Sejh3MMEVbpq5mhEgsZZR4veIFC4TzhVHi5uMJjCBVbAJaEvtf3GAD sUUEUiT+3pwN1sEscIhJ4sy7I0wgCWEBX4mNB2aBjWURUJU4fPAYWDOvgKv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AB6MSD2+BbViYEGtiWXFl7iFGCQ5mJRHeWyzhYUK8 KYmVValF+fFFpTmpxYcYTYEOm8gsJZqcD0wueSXxhsYmZkaWRuaGFkbG5krivBf2+4UJCaQn lqRmp6YWpBbB9DFxcEo1MK7YN2XpuZgZzSd5ojVspl/uXGUev3Nr6txvh4MdzzcLrEv4e/iJ 2JZFet++XbOTXGgSqie3iuuV5g11i9sBu46Hu7y/Xb+9Wy/lYdWd31fOLrnj8URIva1j+9MP dU6s3Z1uZdHnH4Q1Z7XzSEill6dX/Mg/2sxk6O29bFa/VcaXVx5rtsxePk2JpTgj0VCLuag4 EQAAGDc99gIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the new devfreq_get_devfreq_by_phandle() OF helper function which can find the instance of devfreq device by using phandle ("devfreq"). Signed-off-by: Chanwoo Choi --- drivers/devfreq/devfreq.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/devfreq.h | 9 +++++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 15e58779e4c0..78ea4cdaa82c 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "governor.h" static struct class *devfreq_class; @@ -686,6 +687,49 @@ struct devfreq *devm_devfreq_add_device(struct device *dev, } EXPORT_SYMBOL(devm_devfreq_add_device); +#ifdef CONFIG_OF +/* + * devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree + * @dev - instance to the given device + * @index - index into list of devfreq + * + * return the instance of devfreq device + */ +struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index) +{ + struct device_node *node; + struct devfreq *devfreq; + + if (!dev) + return ERR_PTR(-EINVAL); + + if (!dev->of_node) + return ERR_PTR(-EINVAL); + + node = of_parse_phandle(dev->of_node, "devfreq", index); + if (!node) + return ERR_PTR(-ENODEV); + + mutex_lock(&devfreq_list_lock); + list_for_each_entry(devfreq, &devfreq_list, node) { + if (devfreq->dev.parent + && devfreq->dev.parent->of_node == node) { + mutex_unlock(&devfreq_list_lock); + return devfreq; + } + } + mutex_unlock(&devfreq_list_lock); + + return ERR_PTR(-EPROBE_DEFER); +} +#else +struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index) +{ + return ERR_PTR(-ENODEV); +} +#endif /* CONFIG_OF */ +EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_phandle); + /** * devm_devfreq_remove_device() - Resource-managed devfreq_remove_device() * @dev: the device to add devfreq feature. diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index f7a6e6bd716e..d648041145ba 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -211,6 +211,9 @@ extern int devm_devfreq_register_opp_notifier(struct device *dev, extern void devm_devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq); +extern struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, + int index); + /** * devfreq_update_stats() - update the last_status pointer in struct devfreq * @df: the devfreq instance whose status needs updating @@ -324,6 +327,12 @@ static inline void devm_devfreq_unregister_opp_notifier(struct device *dev, { } +static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, + int index) +{ + return ERR_PTR(-ENODEV); +} + static inline int devfreq_update_stats(struct devfreq *df) { return -EINVAL;