From: Leonard Crestez <leonard.crestez@nxp.com> To: Georgi Djakov <georgi.djakov@linaro.org>, Rob Herring <robh+dt@kernel.org>, Chanwoo Choi <cw00.choi@samsung.com> Cc: "Artur Świgoń" <a.swigon@partner.samsung.com>, "Alexandre Bailon" <abailon@baylibre.com>, "Rafael J. Wysocki" <rafael@kernel.org>, "Jacky Bai" <ping.bai@nxp.com>, "Anson Huang" <Anson.Huang@nxp.com>, "Abel Vesa" <abel.vesa@nxp.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>, "Matthias Kaehlcke" <mka@chromium.org>, "Angus Ainslie" <angus@akkea.ca>, "Martin Kepplinger" <martink@posteo.de>, linux-pm@vger.kernel.org, kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC v5 04/10] PM / devfreq: Add devfreq_get_devfreq_by_node Date: Fri, 1 Nov 2019 00:52:03 +0200 [thread overview] Message-ID: <69885e720ae7d51b1080e2386b1612366d86a1f4.1572562150.git.leonard.crestez@nxp.com> (raw) In-Reply-To: <cover.1572562150.git.leonard.crestez@nxp.com> In-Reply-To: <cover.1572562150.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 dab31b63eb10..bc83d0aab279 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -931,10 +931,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 * @@ -953,25 +976,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 fb376b5b7281..d4d1ec04aeea 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
WARNING: multiple messages have this Message-ID (diff)
From: Leonard Crestez <leonard.crestez@nxp.com> To: Georgi Djakov <georgi.djakov@linaro.org>, Rob Herring <robh+dt@kernel.org>, Chanwoo Choi <cw00.choi@samsung.com> Cc: "Mark Rutland" <mark.rutland@arm.com>, "Artur Świgoń" <a.swigon@partner.samsung.com>, "Jacky Bai" <ping.bai@nxp.com>, "Rafael J. Wysocki" <rafael@kernel.org>, "Viresh Kumar" <viresh.kumar@linaro.org>, "Michael Turquette" <mturquette@baylibre.com>, "Angus Ainslie" <angus@akkea.ca>, "MyungJoo Ham" <myungjoo.ham@samsung.com>, "Abel Vesa" <abel.vesa@nxp.com>, "Anson Huang" <Anson.Huang@nxp.com>, "Krzysztof Kozlowski" <krzk@kernel.org>, "Matthias Kaehlcke" <mka@chromium.org>, linux-imx@nxp.com, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, "Martin Kepplinger" <martink@posteo.de>, linux-arm-kernel@lists.infradead.org, "Dong Aisheng" <aisheng.dong@nxp.com>, "Saravana Kannan" <saravanak@google.com>, "Stephen Boyd" <sboyd@kernel.org>, "Kyungmin Park" <kyungmin.park@samsung.com>, kernel@pengutronix.de, "Fabio Estevam" <fabio.estevam@nxp.com>, "Shawn Guo" <shawnguo@kernel.org>, "Alexandre Bailon" <abailon@baylibre.com> Subject: [PATCH RFC v5 04/10] PM / devfreq: Add devfreq_get_devfreq_by_node Date: Fri, 1 Nov 2019 00:52:03 +0200 [thread overview] Message-ID: <69885e720ae7d51b1080e2386b1612366d86a1f4.1572562150.git.leonard.crestez@nxp.com> (raw) In-Reply-To: <cover.1572562150.git.leonard.crestez@nxp.com> In-Reply-To: <cover.1572562150.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 dab31b63eb10..bc83d0aab279 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -931,10 +931,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 * @@ -953,25 +976,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 fb376b5b7281..d4d1ec04aeea 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-31 22:52 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-10-31 22:51 [PATCH RFC v5 00/10] interconnect: Add imx support via devfreq Leonard Crestez 2019-10-31 22:51 ` Leonard Crestez 2019-10-31 22:52 ` [PATCH RFC v5 01/10] dt-bindings: devfreq: Add bindings for generic imx buses Leonard Crestez 2019-10-31 22:52 ` Leonard Crestez 2019-11-04 22:49 ` Rob Herring 2019-11-04 22:49 ` Rob Herring 2019-11-11 22:28 ` Leonard Crestez 2019-11-11 22:28 ` Leonard Crestez 2019-10-31 22:52 ` [PATCH RFC v5 02/10] PM / devfreq: Add generic imx bus driver Leonard Crestez 2019-10-31 22:52 ` Leonard Crestez 2019-10-31 22:52 ` [PATCH RFC v5 03/10] PM / devfreq: imx: Register interconnect device Leonard Crestez 2019-10-31 22:52 ` Leonard Crestez 2019-10-31 22:52 ` Leonard Crestez [this message] 2019-10-31 22:52 ` [PATCH RFC v5 04/10] PM / devfreq: Add devfreq_get_devfreq_by_node Leonard Crestez 2019-10-31 22:52 ` [PATCH RFC v5 05/10] interconnect: Add imx core driver Leonard Crestez 2019-10-31 22:52 ` Leonard Crestez 2019-11-12 15:07 ` Georgi Djakov 2019-11-12 15:07 ` Georgi Djakov 2019-11-12 17:25 ` Leonard Crestez 2019-11-12 17:25 ` Leonard Crestez 2019-10-31 22:52 ` [PATCH RFC v5 06/10] interconnect: imx: Add platform driver for imx8mm Leonard Crestez 2019-10-31 22:52 ` Leonard Crestez 2019-10-31 22:52 ` [PATCH RFC v5 07/10] interconnect: imx: Add platform driver for imx8mq Leonard Crestez 2019-10-31 22:52 ` Leonard Crestez 2019-10-31 22:52 ` [PATCH RFC v5 08/10] interconnect: imx: Add platform driver for imx8mn Leonard Crestez 2019-10-31 22:52 ` Leonard Crestez 2019-10-31 22:52 ` [PATCH RFC v5 09/10] arm64: dts: imx8m: Add NOC nodes Leonard Crestez 2019-10-31 22:52 ` Leonard Crestez 2019-10-31 22:52 ` [PATCH RFC v5 10/10] arm64: dts: imx8m: Add interconnect provider properties Leonard Crestez 2019-10-31 22:52 ` 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=69885e720ae7d51b1080e2386b1612366d86a1f4.1572562150.git.leonard.crestez@nxp.com \ --to=leonard.crestez@nxp.com \ --cc=Anson.Huang@nxp.com \ --cc=a.swigon@partner.samsung.com \ --cc=abailon@baylibre.com \ --cc=abel.vesa@nxp.com \ --cc=aisheng.dong@nxp.com \ --cc=angus@akkea.ca \ --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=martink@posteo.de \ --cc=mka@chromium.org \ --cc=mturquette@baylibre.com \ --cc=myungjoo.ham@samsung.com \ --cc=ping.bai@nxp.com \ --cc=rafael@kernel.org \ --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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.