Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1278239

[RFC PATCH 06/15] PM / devfreq: Add devfreq_get_devfreq_by_phandle()

From Chanwoo Choi <cw00.choi@samsung.com>
Newsgroups linux.kernel
Subject [RFC PATCH 06/15] PM / devfreq: Add devfreq_get_devfreq_by_phandle()
Date 2015-11-26 15:00 +0100
Message-ID <qz5fB-5UD-25@gated-at.bofh.it> (permalink)
References <qz55T-5QV-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <cw00.choi@samsung.com>
---
 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 <linux/list.h>
 #include <linux/printk.h>
 #include <linux/hrtimer.h>
+#include <linux/of.h>
 #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;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 00/15] PM / devferq: Add generic exynos bus frequency  driver and new passive governor Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 14:50 +0100
  [RFC PATCH 12/15] ARM: dts: Add support of bus frequency using VDD_INT  for exynos3250-rinato Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 14:50 +0100
  [RFC PATCH 07/15] PM / devfreq: Show the related information according  to governor type Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 14:50 +0100
  [RFC PATCH 14/15] ARM: dts: Add bus nodes using VDD_INT for Exynos4x12 Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 14:50 +0100
  [RFC PATCH 03/15] ARM: dts: Add DMC bus node for Exynos3250 Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 14:50 +0100
  [RFC PATCH 08/15] PM / devfreq: exynos: Add support of bus frequency  of sub-blocks using passive governor Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 15:00 +0100
  [RFC PATCH 11/15] ARM: dts: Add bus nodes using VDD_INT for Exynos3250 Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 15:00 +0100
  [RFC PATCH 02/15] PM / devfreq: exynos: Add documentation for generic  exynos bus frequency driver Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 15:00 +0100
    Re: [RFC PATCH 02/15] PM / devfreq: exynos: Add documentation for  generic exynos bus frequency driver Rob Herring <robh@kernel.org> - 2015-11-27 21:40 +0100
      Re: [RFC PATCH 02/15] PM / devfreq: exynos: Add documentation for  generic exynos bus frequency driver Chanwoo Choi <cwchoi00@gmail.com> - 2015-11-28 03:20 +0100
  [RFC PATCH 06/15] PM / devfreq: Add devfreq_get_devfreq_by_phandle() Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 15:00 +0100
  [RFC PATCH 01/15] PM / devfreq: exynos: Add generic exynos bus  frequency driver Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 15:00 +0100
    Re: [RFC PATCH 01/15] PM / devfreq: exynos: Add generic exynos bus  frequency driver MyungJoo Ham <myungjoo.ham@samsung.com> - 2015-11-26 15:10 +0100
      Re: [RFC PATCH 01/15] PM / devfreq: exynos: Add generic exynos bus  frequency driver Chanwoo Choi <cwchoi00@gmail.com> - 2015-11-26 17:20 +0100
        Re: [RFC PATCH 01/15] PM / devfreq: exynos: Add generic exynos bus  frequency driver Anand Moon <linux.amoon@gmail.com> - 2015-11-26 18:20 +0100
          Re: [RFC PATCH 01/15] PM / devfreq: exynos: Add generic exynos bus  frequency driver Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-27 01:40 +0100
  [RFC PATCH 05/15] PM / devfreq: Add new passive governor Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 15:00 +0100
  [RFC PATCH 09/15] PM / devfreq: exynos: Update documentation for bus  devices using passive governor Chanwoo Choi <cw00.choi@samsung.com> - 2015-11-26 15:00 +0100

csiph-web