From: Leonard Crestez <leonard.crestez@nxp.com>
To: "Georgi Djakov" <georgi.djakov@linaro.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Artur Świgoń" <a.swigon@partner.samsung.com>,
"Chanwoo Choi" <cw00.choi@samsung.com>
Cc: Alexandre Bailon <abailon@baylibre.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Saravana Kannan <saravanak@google.com>,
Mark Rutland <mark.rutland@arm.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Shawn Guo <shawnguo@kernel.org>,
Dong Aisheng <aisheng.dong@nxp.com>,
Fabio Estevam <fabio.estevam@nxp.com>,
Stephen Boyd <sboyd@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
kernel@pengutronix.de, linux-imx@nxp.com,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: [RFCv4 1/7] PM / devfreq: Add devfreq_get_devfreq_by_node
Date: Fri, 23 Aug 2019 17:36:54 +0300 [thread overview]
Message-ID: <71a13730eee8744d8468aee8fa355958706035dd.1566570260.git.leonard.crestez@nxp.com> (raw)
In-Reply-To: <cover.1566570260.git.leonard.crestez@nxp.com>
In-Reply-To: <cover.1566570260.git.leonard.crestez@nxp.com>
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.
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
---
drivers/devfreq/devfreq.c | 42 +++++++++++++++++++++++++++++----------
include/linux/devfreq.h | 1 +
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 687deadd08ed..57352a757d79 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -907,10 +907,33 @@ struct devfreq *devm_devfreq_add_device(struct device *dev,
return devfreq;
}
EXPORT_SYMBOL(devm_devfreq_add_device);
#ifdef CONFIG_OF
+/*
+ * devfreq_get_devfreq_by_node - Get the devfreq device from devicetree
+ * @np - pointer to device_node
+ *
+ * return the instance of devfreq device
+ */
+struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
+{
+ struct devfreq *devfreq;
+
+ 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);
+}
+
/*
* devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree
* @dev - instance to the given device
* @index - index into list of devfreq
*
@@ -929,25 +952,22 @@ struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index)
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);
- 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 */
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index d2c5bb7add0a..4b5cc80abbe3 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -242,10 +242,11 @@ extern int devm_devfreq_register_notifier(struct device *dev,
unsigned int list);
extern void devm_devfreq_unregister_notifier(struct device *dev,
struct devfreq *devfreq,
struct notifier_block *nb,
unsigned int list);
+extern struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node);
extern struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
int index);
#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
/**
--
2.17.1
next prev parent reply other threads:[~2019-08-23 14:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-23 14:36 [RFCv4 0/7] interconnect: Add imx support via devfreq Leonard Crestez
2019-08-23 14:36 ` Leonard Crestez [this message]
2019-08-23 14:36 ` [RFCv4 2/7] interconnect: Add of_icc_add_proxy Leonard Crestez
2019-08-23 14:36 ` [RFCv4 3/7] dt-bindings: devfreq: imx: Describe interconnect properties Leonard Crestez
2019-09-17 20:19 ` Rob Herring
2019-09-23 17:42 ` Leonard Crestez
2019-09-23 21:03 ` Rob Herring
2019-09-24 14:39 ` Leonard Crestez
2019-08-23 14:36 ` [RFCv4 4/7] interconnect: Add imx core driver Leonard Crestez
2019-08-23 14:36 ` [RFCv4 5/7] interconnect: imx: Add platform driver for imx8mm Leonard Crestez
2019-08-23 14:36 ` [RFCv4 6/7] soc: imx8mm: Register interconnect platform device Leonard Crestez
2019-08-23 14:37 ` [RFCv4 7/7] arm64: dts: imx8mm: Add interconnect properties Leonard Crestez
2019-09-16 12:34 ` [RFCv4 0/7] interconnect: Add imx support via devfreq Leonard Crestez
2019-09-25 2:37 ` Georgi Djakov
2019-09-25 22:52 ` Leonard Crestez
2019-09-26 0:51 ` Georgi Djakov
2019-09-30 12:31 ` Leonard Crestez
2019-09-21 6:06 ` Martin Kepplinger
2019-09-23 21:22 ` Leonard Crestez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=71a13730eee8744d8468aee8fa355958706035dd.1566570260.git.leonard.crestez@nxp.com \
--to=leonard.crestez@nxp.com \
--cc=a.swigon@partner.samsung.com \
--cc=abailon@baylibre.com \
--cc=aisheng.dong@nxp.com \
--cc=cw00.choi@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=fabio.estevam@nxp.com \
--cc=georgi.djakov@linaro.org \
--cc=kernel@pengutronix.de \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-pm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mturquette@baylibre.com \
--cc=myungjoo.ham@samsung.com \
--cc=robh+dt@kernel.org \
--cc=saravanak@google.com \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).