From patchwork Tue Sep 8 10:24:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 11763117 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20933746 for ; Tue, 8 Sep 2020 10:14:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7FB6215A4 for ; Tue, 8 Sep 2020 10:14:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EsVWbQ4/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="EXg/DUZY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7FB6215A4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=A3TlVPMnGVmSGGVTYCuI1A6vNMoA/R43yjaOMZJc/mg=; b=EsVWbQ4/IJPw2qeO8gZaxUhUQL 36rxfnkiUwuWpGttzGPLn10tR1Pn0qzFefqtM8yhWd6iLF5bHk+Syp4Nd/RZSQQqjFErc06/igA/j T+l8TP3oeU3baHrIu26KnKk/z3EiuTu7U7fQtkSIOliq9gTC+jbgUtfyI3h+vMixotwYsH9Htvno0 uk4ZMczbVu/p8WwaGRaUM3/KJDURJZPE5ZOl+NnAsIQllFXwAzivldOI1BtqwDAL4neiFtyEOQ1mT QZhiOdZUlwLP14cJiVeK1pmQf2ciCOyPlR0EYDmqb8d3A5WjFwllYVctb7yIJQwF7AIH9PY9Noa+8 +mp4Nb2Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFacR-0006Rx-KD; Tue, 08 Sep 2020 10:12:55 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFacE-0006Ne-M2 for linux-arm-kernel@lists.infradead.org; Tue, 08 Sep 2020 10:12:45 +0000 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200908101240epoutp0102877dd7d6c912276403bc319dbb7221~yx08T54a21401014010epoutp01W for ; Tue, 8 Sep 2020 10:12:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200908101240epoutp0102877dd7d6c912276403bc319dbb7221~yx08T54a21401014010epoutp01W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1599559960; bh=ZHYNOECr6/hyoQNi3rgR3D9rFSRmKng51Z3eUSqSMIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EXg/DUZY7LxGgS5od6oYaR8dIkwUEtU+g6EtRg8/4x/5mYhIjxPSKnTZNl0lUkFVu 6pZa5uBWKWNQRoYMf7XeVYlEbRbfKWMumFLMxTQmPq+4mIhlMdQ/X9fhJ+Mg2e2TMd 8QZi33GkMXextJuuB+ocX4tcYmIIgwl9f++6fLQU= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20200908101239epcas1p1d075182cf83a1893c740b8616589effc~yx08CCPsn2557725577epcas1p1q; Tue, 8 Sep 2020 10:12:39 +0000 (GMT) Received: from epsmges1p2.samsung.com (unknown [182.195.40.155]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Bm1DJ0QJ6zMqYkd; Tue, 8 Sep 2020 10:12:32 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id B9.1F.19033.F09575F5; Tue, 8 Sep 2020 19:12:31 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200908101230epcas1p25f1ae5d3230f802a8326bfaa7e49c159~yx0ztoYIo0740007400epcas1p2y; Tue, 8 Sep 2020 10:12:30 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200908101230epsmtrp2a300a48ee770632bff671a9434324728~yx0zskhGD2570325703epsmtrp2a; Tue, 8 Sep 2020 10:12:30 +0000 (GMT) X-AuditID: b6c32a36-16fff70000004a59-6e-5f57590f3e9e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 1A.48.08303.E09575F5; Tue, 8 Sep 2020 19:12:30 +0900 (KST) Received: from localhost.localdomain (unknown [10.113.221.102]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200908101230epsmtip20867b17f627241e809c6a25e87d89e91~yx0zg9lAb1414914149epsmtip2P; Tue, 8 Sep 2020 10:12:30 +0000 (GMT) From: Chanwoo Choi To: myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com, krzk@kernel.org, lukasz.luba@arm.com Subject: [PATCH v3 1/3] PM / devfreq: Add devfreq_get_devfreq_by_node function Date: Tue, 8 Sep 2020 19:24:45 +0900 Message-Id: <20200908102447.15097-2-cw00.choi@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200908102447.15097-1-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPKsWRmVeSWpSXmKPExsWy7bCmvi5/ZHi8wZkGK4vrX56zWpw/v4Hd 4mzTG3aLFXc/slpsenyN1eLyrjlsFp97jzBazDi/j8liYVMLu8XtxhVsDlwea+atYfTYtKqT zWPzknqPje92MHn0bVnF6PF5k1wAW1S2TUZqYkpqkUJqXnJ+SmZeuq2Sd3C8c7ypmYGhrqGl hbmSQl5ibqqtkotPgK5bZg7QZUoKZYk5pUChgMTiYiV9O5ui/NKSVIWM/OISW6XUgpScAssC veLE3OLSvHS95PxcK0MDAyNToMKE7Izrb7+zFCyQqZjybBN7A+Mr8S5GTg4JAROJ16fWM3Yx cnEICexglHhyuQPK+cQocenLVhYI5zOjxN6NH9lhWtZO+M4MkdjFKNFy4C4rhPMFyFnaxQJS xSagJbH/xQ02EFtEoEzi9perYB3MApsYJZZu/wbUwcEhLBAg0f9eDaSGRUBVYt2JuywgYV4B K4kJn6QhlslLrN5wgBnE5hSwlti+aiEbyBgJgZfsEt8+zmKDKHKR+PpuGZQtLPHq+BaoS6Uk Pr/bCxWvllh58ghUcwejxJb9F1ghEsYS+5dOZgJZzCygKbF+lz5EWFFi5++5jCA2swCfxLuv PWAnSwjwSnS0CUGUKEtcfnCXCcKWlFjc3gm1ykOi7e4TsOlCAn2MEm93c0xglJuFsGABI+Mq RrHUguLc9NRiwwIj5BjbxAhOeVpmOxgnvf2gd4iRiYPxEKMEB7OSCG/XodB4Id6UxMqq1KL8 +KLSnNTiQ4ymwLCbyCwlmpwPTLp5JfGGpkbGxsYWJoZmpoaGSuK8D28pxAsJpCeWpGanphak FsH0MXFwSjUwFVeICx1u4DOpZdBkZdXjTo3eeJ4p1XHeBZ2Vrq/XNVlwc/Ac9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51XHfhieMcbAW1LvaF Vksmah7c/I/t1NmFrVM1ztbZaV10/Dnz+MOtu6qvX+FdZn9+Rt/zRzG/v+/8VfbV+uSuiYfb y5Z0bJGZeVQ0fNGGn6nuOzlUJn6dtdXi08x7/bsXZ1xMlv+mapofW23IteyrsdvJrRMbn6iw /P7ocrf75OWAvh8Zj033cmvnygdqOe4uLeXvPXZF0oVzTvu2P0osxRmJhlrMRcWJAJn719G7 AgAA X-CMS-MailID: 20200908101230epcas1p25f1ae5d3230f802a8326bfaa7e49c159 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200908101230epcas1p25f1ae5d3230f802a8326bfaa7e49c159 References: <20200908102447.15097-1-cw00.choi@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200908_061243_299653_3E6D9BEA X-CRM114-Status: GOOD ( 23.62 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [203.254.224.24 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [203.254.224.24 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, Leonard Crestez , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Leonard Crestez Split off part of devfreq_get_devfreq_by_phandle into a separate function. This allows callers to fetch devfreq instances by enumerating devicetree instead of explicit phandles. Reviewed-by: Lukasz Luba Signed-off-by: Leonard Crestez [cw00.choi: Export devfreq_get_devfreq_by_node function and add function to devfreq.h when CONFIG_PM_DEVFREQ is enabled.] Signed-off-by: Chanwoo Choi Acked-by: Krzysztof Kozlowski --- drivers/devfreq/devfreq.c | 46 +++++++++++++++++++++++++++++---------- include/linux/devfreq.h | 6 +++++ 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 561d91b2d3bf..b9b27fb3291e 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -983,6 +983,32 @@ struct devfreq *devm_devfreq_add_device(struct device *dev, EXPORT_SYMBOL(devm_devfreq_add_device); #ifdef CONFIG_OF +/* + * devfreq_get_devfreq_by_node - Get the devfreq device from devicetree + * @node - pointer to device_node + * + * return the instance of devfreq device + */ +struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node) +{ + struct devfreq *devfreq; + + if (!node) + return ERR_PTR(-EINVAL); + + 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(-ENODEV); +} + /* * devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree * @dev - instance to the given device @@ -1005,26 +1031,24 @@ struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int 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); - of_node_put(node); - return devfreq; - } - } - mutex_unlock(&devfreq_list_lock); + devfreq = devfreq_get_devfreq_by_node(node); of_node_put(node); - return ERR_PTR(-EPROBE_DEFER); + return devfreq; } + #else +struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node) +{ + return ERR_PTR(-ENODEV); +} + 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_node); EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_phandle); /** diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 12782fbb4c25..eb971b8e5051 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -261,6 +261,7 @@ void devm_devfreq_unregister_notifier(struct device *dev, struct devfreq *devfreq, struct notifier_block *nb, unsigned int list); +struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node); struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index); #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND) @@ -414,6 +415,11 @@ static inline void devm_devfreq_unregister_notifier(struct device *dev, { } +static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node) +{ + return ERR_PTR(-ENODEV); +} + static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index) {