Skip to contentSkip to conversation

PM / devfreq: Remove deprecated 'devfreq' and 'devfreq-events' properties

PATCH Superseded Chanwoo Choi 4 participants 21 messages Dec 20, 2019 – Jan 9, 2020 1 message not in the archive

Subsystems (8)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20191220001759epcas1p131a41a619847d80c64470f7c1920121f@epcas1p1.samsung.com

Chanwoo Choi

author maintainer
#1 lore raw

v2 cover PM / devfreq: Remove deprecated 'devfreq' and 'devfreq-events' properties

From: Chanwoo Choi <[email protected]>

The devfreq and devfreq-event subsystem provided the following two properties:
- Provide 'devfreq' property in order to get the parent devfreq device by devfreq_get_devfreq_by_phandle() if devfreq device use passive governor.
- Provide 'devfreq-events' property in order to get the devfreq-event device by devfreq_event_get_edev_by_phandle().

But, two properties name is not proper expressing the h/w and 'devfreq' word is name of linux subsystem instead of any h/w name.

Hand over the rights for deciding the property name for getting the devfreq/devfreq-event device on devicetree, to each devfreq driver.

So, replace 'devfreq' and 'devfreq-events' property with following property name according to each devfreq driver:
--------------------------------------------------------------------
Old property | New property | Device driver name |
--------------------------------------------------------------------

devfreq       | exynos,parent-bus  | exynos-bus.c                  |
              |                    |                               |
devfreq-events| exynos,ppmu-device | exynos-bus.c, exynos5422-dmc.c|
              | rockchip,dfi-device| rk3399_dmc.c                  |

--------------------------------------------------------------------

Changes from v1:
- Edit function name by removing '_by_node' postfix.
- Split out dt-binding patch to make it the separte patch.j
- Add Lukasz's tag for exynos5422-dmc

Chanwoo Choi (10):
PM / devfreq: Remove devfreq_get_devfreq_by_phandle function
PM / devfreq: event: Add devfreq_event_get_edev_by_node function
dt-bindings: devfreq: exynos-bus: Replace deprecated 'devfreq' and 'devfreq-events' property
dt-bindings: devfreq: rk3399_dmc: Replace deprecated 'devfreq-events' property
dt-bindings: memory: exynos5422-dmc: Replace the deprecated 'devfreq-events' property PM / devfreq: exynos-bus: Replace the deprecated 'devfreq' and 'devfreq-events' property PM / devfreq: rk3399_dmc: Replace the deprecated 'devfreq-events' property
memory: samsung: exynos5422-dmc: Replace the deprecated 'devfreq-events' property
ARM: dts: exynos: Replace deprecated property for Exynos bus and DMC
arm64: dts: exynos: Replace deprecated property for Exynos bus on TM2

Leonard Crestez (1):
PM / devfreq: Add devfreq_get_devfreq_by_node function

 .../bindings/devfreq/exynos-bus.txt           | 22 +++----
 .../bindings/devfreq/rk3399_dmc.txt           |  4 +-
 .../memory-controllers/exynos5422-dmc.txt     |  8 +--
 arch/arm/boot/dts/exynos3250-monk.dts         |  2 +-
 arch/arm/boot/dts/exynos3250-rinato.dts       | 18 +++---
 .../boot/dts/exynos4412-itop-scp-core.dtsi    | 16 ++---
 arch/arm/boot/dts/exynos4412-midas.dtsi       | 18 +++---
 .../boot/dts/exynos4412-odroid-common.dtsi    | 18 +++---
 arch/arm/boot/dts/exynos5422-odroid-core.dtsi | 34 +++++------
 .../dts/exynos/exynos5433-tm2-common.dtsi     | 20 +++----
 drivers/devfreq/devfreq-event.c               | 53 +++--------------
 drivers/devfreq/devfreq.c                     | 25 +++-----
 drivers/devfreq/exynos-bus.c                  | 58 ++++++++++++++++---
 drivers/devfreq/rk3399_dmc.c                  | 16 ++++-
 drivers/memory/samsung/exynos5422-dmc.c       | 37 ++++++++++--
 include/linux/devfreq-event.h                 | 14 ++---
 include/linux/devfreq.h                       |  6 +-
 17 files changed, 198 insertions(+), 171 deletions(-)
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v2 1/11 PM / devfreq: Add devfreq_get_devfreq_by_node function

From: Leonard Crestez <[email protected]>

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.

[lkp: Reported the build error]

[cw00.choi: Export devfreq_get_devfreq_by_node function and
add function to devfreq.h when CONFIG_PM_DEVFREQ is enabled.]

---
 drivers/devfreq/devfreq.c | 46 +++++++++++++++++++++++++++++----------
 include/linux/devfreq.h   |  6 +++++
 2 files changed, 41 insertions(+), 11 deletions(-)
drivers/devfreq/devfreq.c +35 -11
index 89260b17598f..cb8ca81c8973 100644
@@ -966,6 +966,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
@@ -988,26 +1014,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);
 
 /**
include/linux/devfreq.h +6 -0
index c6f82d4bec9f..1dccc47acbce 100644
@@ -253,6 +253,7 @@ 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);
 
@@ -407,6 +408,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)
 {
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/11
#3 lore raw

Re: [PATCH v2 01/11] PM / devfreq: Add devfreq_get_devfreq_by_node function

Hi Chanwoo,

Quoted 95 lines · Chanwoo Choi

From: Leonard Crestez <[email protected]>

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.

[lkp: Reported the build error]

[cw00.choi: Export devfreq_get_devfreq_by_node function and
add function to devfreq.h when CONFIG_PM_DEVFREQ is enabled.]

---
  drivers/devfreq/devfreq.c | 46 +++++++++++++++++++++++++++++----------
  include/linux/devfreq.h   |  6 +++++
  2 files changed, 41 insertions(+), 11 deletions(-)
drivers/devfreq/devfreq.c +35 -11
index 89260b17598f..cb8ca81c8973 100644
@@ -966,6 +966,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
@@ -988,26 +1014,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);
 
  /**
include/linux/devfreq.h +0 -0
index c6f82d4bec9f..1dccc47acbce 100644

include/linux/devfreq.h extern void devm_devfreq_unregister_notifier(struct device *dev, · line 256

Quoted 4 lines
include/linux/devfreq.h +1 -0
@@ -253,6 +253,7 @@ 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);

It can go without 'extern' in the header.

Quoted 6 lines
include/linux/devfreq.h +0 -0
  extern struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
  						int index);
 
@@ -407,6 +408,11 @@ static inline void devm_devfreq_unregister_notifier(struct device *dev,
  {

include/linux/devfreq.h static inline void devm_devfreq_unregister_notifier(struct device *dev, · line 418

Quoted 10 lines
include/linux/devfreq.h +5 -0
  }
 
+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)
  {

Apart from this minor thing, looks good to me.
When you fix it, feel free to add

Regards,
Lukasz

author maintainer
#4 lore raw

PATCH v2 2/11 PM / devfreq: Remove devfreq_get_devfreq_by_phandle function

In reply to Chanwoo Choi

Previously, devfreq core support 'devfreq' property in order to get the devfreq device by phandle. But, 'devfreq' property name is not proper on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq core hand over the right to decide the property name for getting the devfreq device on devicetree. Each devfreq driver will decide the property name on devicetree binding and then get the devfreq device by using devfreq_get_devfreq_by_node().

---
 drivers/devfreq/devfreq.c    | 35 -----------------------------------
 drivers/devfreq/exynos-bus.c | 12 +++++++++++-
 include/linux/devfreq.h      |  8 --------
 3 files changed, 11 insertions(+), 44 deletions(-)
drivers/devfreq/devfreq.c +0 -35
index cb8ca81c8973..c3d3c7c802a0 100644
@@ -991,48 +991,13 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
 
 	return ERR_PTR(-ENODEV);
 }
-
-/*
- * 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);
-
-	devfreq = devfreq_get_devfreq_by_node(node);
-	of_node_put(node);
-
-	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);
 
 /**
  * devm_devfreq_remove_device() - Resource-managed devfreq_remove_device()
drivers/devfreq/exynos-bus.c +11 -1
index 7f5917d59072..1bc4e3c81115 100644
@@ -86,6 +86,16 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
 	return ret;
 }
 
+static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
+{
+	struct device_node *node = of_parse_phandle(np, "devfreq", 0);
+
+	if (!node)
+		return ERR_PTR(-ENODEV);
+
+	return devfreq_get_devfreq_by_node(node);
+}
+
 /*
  * devfreq function for both simple-ondemand and passive governor
  */
@@ -353,7 +363,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
 	profile->exit = exynos_bus_passive_exit;
 
 	/* Get the instance of parent devfreq device */
-	parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
+	parent_devfreq = exynos_bus_get_parent_devfreq(dev->of_node);
 	if (IS_ERR(parent_devfreq))
 		return -EPROBE_DEFER;
 
include/linux/devfreq.h +0 -8
index 1dccc47acbce..a4351698fb64 100644
@@ -254,8 +254,6 @@ extern void devm_devfreq_unregister_notifier(struct device *dev,
 				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)
 /**
@@ -413,12 +411,6 @@ static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *no
 	return ERR_PTR(-ENODEV);
 }
 
-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;
Signature · 1 line
2.17.1
#5 lore raw

Re: [PATCH v2 02/11] PM / devfreq: Remove devfreq_get_devfreq_by_phandle function

Quoted 75 lines · Chanwoo Choi

Previously, devfreq core support 'devfreq' property in order to get the devfreq device by phandle. But, 'devfreq' property name is not proper on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq core hand over the right to decide the property name for getting the devfreq device on devicetree. Each devfreq driver will decide the property name on devicetree binding and then get the devfreq device by using devfreq_get_devfreq_by_node().

---
  drivers/devfreq/devfreq.c    | 35 -----------------------------------
  drivers/devfreq/exynos-bus.c | 12 +++++++++++-
  include/linux/devfreq.h      |  8 --------
  3 files changed, 11 insertions(+), 44 deletions(-)
drivers/devfreq/devfreq.c +0 -35
index cb8ca81c8973..c3d3c7c802a0 100644
@@ -991,48 +991,13 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
 
  	return ERR_PTR(-ENODEV);
  }
-
-/*
- * 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);
-
-	devfreq = devfreq_get_devfreq_by_node(node);
-	of_node_put(node);
-
-	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);
 
  /**
   * devm_devfreq_remove_device() - Resource-managed devfreq_remove_device()
drivers/devfreq/exynos-bus.c +0 -0
index 7f5917d59072..1bc4e3c81115 100644
@@ -86,6 +86,16 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
  	return ret;

drivers/devfreq/exynos-bus.c static int exynos_bus_get_event(struct exynos_bus *bus, · line 96

Quoted 10 lines
drivers/devfreq/exynos-bus.c +8 -0
  }
 
+static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
+{
+	struct device_node *node = of_parse_phandle(np, "devfreq", 0);
+
+	if (!node)
+		return ERR_PTR(-ENODEV);
+
+	return devfreq_get_devfreq_by_node(node);

You need to call of_node_put(node) here and in several other places.

The old devfreq_get_devfreq_by_phandle API handled this internally but devfreq_get_devfreq_by_node doesn't.

Maybe the _by_phandle API could be kept and just take the property name instead of always using "devfreq"?

Quoted 41 lines
drivers/devfreq/exynos-bus.c +3 -1
+}
+
  /*
   * devfreq function for both simple-ondemand and passive governor
   */
@@ -353,7 +363,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
  	profile->exit = exynos_bus_passive_exit;
 
  	/* Get the instance of parent devfreq device */
-	parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
+	parent_devfreq = exynos_bus_get_parent_devfreq(dev->of_node);
  	if (IS_ERR(parent_devfreq))
  		return -EPROBE_DEFER;
 
include/linux/devfreq.h +0 -8
index 1dccc47acbce..a4351698fb64 100644
@@ -254,8 +254,6 @@ extern void devm_devfreq_unregister_notifier(struct device *dev,
  				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)
  /**
@@ -413,12 +411,6 @@ static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *no
  	return ERR_PTR(-ENODEV);
  }
 
-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;
author maintainer
#6 lore raw

Re: [PATCH v2 02/11] PM / devfreq: Remove devfreq_get_devfreq_by_phandle function

Quoted 89 lines · Leonard Crestez
Quoted 75 lines · Chanwoo Choi

Previously, devfreq core support 'devfreq' property in order to get the devfreq device by phandle. But, 'devfreq' property name is not proper on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq core hand over the right to decide the property name for getting the devfreq device on devicetree. Each devfreq driver will decide the property name on devicetree binding and then get the devfreq device by using devfreq_get_devfreq_by_node().

---
  drivers/devfreq/devfreq.c    | 35 -----------------------------------
  drivers/devfreq/exynos-bus.c | 12 +++++++++++-
  include/linux/devfreq.h      |  8 --------
  3 files changed, 11 insertions(+), 44 deletions(-)
drivers/devfreq/devfreq.c +0 -35
index cb8ca81c8973..c3d3c7c802a0 100644
@@ -991,48 +991,13 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
 
  	return ERR_PTR(-ENODEV);
  }
-
-/*
- * 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);
-
-	devfreq = devfreq_get_devfreq_by_node(node);
-	of_node_put(node);
-
-	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);
 
  /**
   * devm_devfreq_remove_device() - Resource-managed devfreq_remove_device()
drivers/devfreq/exynos-bus.c +0 -0
index 7f5917d59072..1bc4e3c81115 100644
@@ -86,6 +86,16 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
  	return ret;

drivers/devfreq/exynos-bus.c static int exynos_bus_get_event(struct exynos_bus *bus, · line 96

Quoted 10 lines
drivers/devfreq/exynos-bus.c +8 -0
  }
 
+static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
+{
+	struct device_node *node = of_parse_phandle(np, "devfreq", 0);
+
+	if (!node)
+		return ERR_PTR(-ENODEV);
+
+	return devfreq_get_devfreq_by_node(node);

You need to call of_node_put(node) here and in several other places.

Quoted 2 lines

The old devfreq_get_devfreq_by_phandle API handled this internally but devfreq_get_devfreq_by_node doesn't.

Thanks. I'll fix it.

Quoted 3 lines

Maybe the _by_phandle API could be kept and just take the property name instead of always using "devfreq"?

Do you mean like below?
devfreq_get_devfreq_by_phandle(struct device *dev, int index)
-> devfreq_get_devfreq_by_phandle(struct device *dev, char *property_name, int index)

In case of devfreq-event.c,
struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
struct device *dev, char property_name, int index)
int devfreq_event_get_edev_count(struct device *dev, char *property_name)

Quoted 45 lines
Quoted 42 lines
drivers/devfreq/exynos-bus.c +3 -1
+}
+
  /*
   * devfreq function for both simple-ondemand and passive governor
   */
@@ -353,7 +363,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
  	profile->exit = exynos_bus_passive_exit;
 
  	/* Get the instance of parent devfreq device */
-	parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
+	parent_devfreq = exynos_bus_get_parent_devfreq(dev->of_node);
  	if (IS_ERR(parent_devfreq))
  		return -EPROBE_DEFER;
 
include/linux/devfreq.h +0 -8
index 1dccc47acbce..a4351698fb64 100644
@@ -254,8 +254,6 @@ extern void devm_devfreq_unregister_notifier(struct device *dev,
  				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)
  /**
@@ -413,12 +411,6 @@ static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *no
  	return ERR_PTR(-ENODEV);
  }
 
-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;
Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics
#7 lore raw

Re: [PATCH v2 02/11] PM / devfreq: Remove devfreq_get_devfreq_by_phandle function

Quoted 103 lines · Chanwoo Choi
Quoted 89 lines · Leonard Crestez
Quoted 75 lines · Chanwoo Choi

Previously, devfreq core support 'devfreq' property in order to get the devfreq device by phandle. But, 'devfreq' property name is not proper on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq core hand over the right to decide the property name for getting the devfreq device on devicetree. Each devfreq driver will decide the property name on devicetree binding and then get the devfreq device by using devfreq_get_devfreq_by_node().

---
   drivers/devfreq/devfreq.c    | 35 -----------------------------------
   drivers/devfreq/exynos-bus.c | 12 +++++++++++-
   include/linux/devfreq.h      |  8 --------
   3 files changed, 11 insertions(+), 44 deletions(-)
drivers/devfreq/devfreq.c +0 -35
index cb8ca81c8973..c3d3c7c802a0 100644
@@ -991,48 +991,13 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
 
   	return ERR_PTR(-ENODEV);
   }
-
-/*
- * 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);
-
-	devfreq = devfreq_get_devfreq_by_node(node);
-	of_node_put(node);
-
-	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);
 
   /**
    * devm_devfreq_remove_device() - Resource-managed devfreq_remove_device()
drivers/devfreq/exynos-bus.c +0 -0
index 7f5917d59072..1bc4e3c81115 100644
@@ -86,6 +86,16 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
   	return ret;

drivers/devfreq/exynos-bus.c static int exynos_bus_get_event(struct exynos_bus *bus, · line 96

Quoted 10 lines
drivers/devfreq/exynos-bus.c +8 -0
   }
 
+static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
+{
+	struct device_node *node = of_parse_phandle(np, "devfreq", 0);
+
+	if (!node)
+		return ERR_PTR(-ENODEV);
+
+	return devfreq_get_devfreq_by_node(node);

You need to call of_node_put(node) here and in several other places.

Quoted 2 lines

The old devfreq_get_devfreq_by_phandle API handled this internally but devfreq_get_devfreq_by_node doesn't.

Thanks. I'll fix it.

Quoted 3 lines

Maybe the _by_phandle API could be kept and just take the property name instead of always using "devfreq"?

Do you mean like below?
devfreq_get_devfreq_by_phandle(struct device *dev, int index)
-> devfreq_get_devfreq_by_phandle(struct device *dev, char *property_name, int index)

Quoted 6 lines

In case of devfreq-event.c,
struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
struct device *dev, char property_name, int index)
int devfreq_event_get_edev_count(struct device *dev, char *property_name)

Yes. These helpers would avoid the need for explicit of_node_put.

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
drivers/devfreq/exynos-bus.c +3 -1
+}
+
   /*
    * devfreq function for both simple-ondemand and passive governor
    */
@@ -353,7 +363,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
   	profile->exit = exynos_bus_passive_exit;
 
   	/* Get the instance of parent devfreq device */
-	parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
+	parent_devfreq = exynos_bus_get_parent_devfreq(dev->of_node);
   	if (IS_ERR(parent_devfreq))
   		return -EPROBE_DEFER;
 
include/linux/devfreq.h +0 -8
index 1dccc47acbce..a4351698fb64 100644
@@ -254,8 +254,6 @@ extern void devm_devfreq_unregister_notifier(struct device *dev,
   				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)
   /**
@@ -413,12 +411,6 @@ static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *no
   	return ERR_PTR(-ENODEV);
   }
 
-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;
author maintainer
#8 lore raw

Re: [PATCH v2 02/11] PM / devfreq: Remove devfreq_get_devfreq_by_phandle function

Quoted 104 lines · Leonard Crestez
Quoted 103 lines · Chanwoo Choi
Quoted 89 lines · Leonard Crestez
Quoted 75 lines · Chanwoo Choi

Previously, devfreq core support 'devfreq' property in order to get the devfreq device by phandle. But, 'devfreq' property name is not proper on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq core hand over the right to decide the property name for getting the devfreq device on devicetree. Each devfreq driver will decide the property name on devicetree binding and then get the devfreq device by using devfreq_get_devfreq_by_node().

---
   drivers/devfreq/devfreq.c    | 35 -----------------------------------
   drivers/devfreq/exynos-bus.c | 12 +++++++++++-
   include/linux/devfreq.h      |  8 --------
   3 files changed, 11 insertions(+), 44 deletions(-)
drivers/devfreq/devfreq.c +0 -35
index cb8ca81c8973..c3d3c7c802a0 100644
@@ -991,48 +991,13 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
 
   	return ERR_PTR(-ENODEV);
   }
-
-/*
- * 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);
-
-	devfreq = devfreq_get_devfreq_by_node(node);
-	of_node_put(node);
-
-	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);
 
   /**
    * devm_devfreq_remove_device() - Resource-managed devfreq_remove_device()
drivers/devfreq/exynos-bus.c +0 -0
index 7f5917d59072..1bc4e3c81115 100644
@@ -86,6 +86,16 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
   	return ret;

drivers/devfreq/exynos-bus.c static int exynos_bus_get_event(struct exynos_bus *bus, · line 96

Quoted 10 lines
drivers/devfreq/exynos-bus.c +8 -0
   }
 
+static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
+{
+	struct device_node *node = of_parse_phandle(np, "devfreq", 0);
+
+	if (!node)
+		return ERR_PTR(-ENODEV);
+
+	return devfreq_get_devfreq_by_node(node);

You need to call of_node_put(node) here and in several other places.

Quoted 2 lines

The old devfreq_get_devfreq_by_phandle API handled this internally but devfreq_get_devfreq_by_node doesn't.

Thanks. I'll fix it.

Quoted 3 lines

Maybe the _by_phandle API could be kept and just take the property name instead of always using "devfreq"?

Do you mean like below?
devfreq_get_devfreq_by_phandle(struct device *dev, int index)
-> devfreq_get_devfreq_by_phandle(struct device *dev, char *property_name, int index)

Quoted 8 lines
Quoted 6 lines

In case of devfreq-event.c,
struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
struct device *dev, char property_name, int index)
int devfreq_event_get_edev_count(struct device *dev, char *property_name)

Yes. These helpers would avoid the need for explicit of_node_put.

OK. Instead of removing devfreq_event_get_edev_by_phandle, change the function property of devfreq_event_get_edev_by_phandle on v3.

After getting the review for dt-binding patch, I'll send v3 patches.

Quoted 46 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
drivers/devfreq/exynos-bus.c +3 -1
+}
+
   /*
    * devfreq function for both simple-ondemand and passive governor
    */
@@ -353,7 +363,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
   	profile->exit = exynos_bus_passive_exit;
 
   	/* Get the instance of parent devfreq device */
-	parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
+	parent_devfreq = exynos_bus_get_parent_devfreq(dev->of_node);
   	if (IS_ERR(parent_devfreq))
   		return -EPROBE_DEFER;
 
include/linux/devfreq.h +0 -8
index 1dccc47acbce..a4351698fb64 100644
@@ -254,8 +254,6 @@ extern void devm_devfreq_unregister_notifier(struct device *dev,
   				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)
   /**
@@ -413,12 +411,6 @@ static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *no
   	return ERR_PTR(-ENODEV);
   }
 
-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;
Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics
maintainer
#9 lore raw

Re: [PATCH v2 02/11] PM / devfreq: Remove devfreq_get_devfreq_by_phandle function

In reply to Chanwoo Choi

Hi Chanwoo,

Quoted 91 lines · Chanwoo Choi

Previously, devfreq core support 'devfreq' property in order to get the devfreq device by phandle. But, 'devfreq' property name is not proper on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq core hand over the right to decide the property name for getting the devfreq device on devicetree. Each devfreq driver will decide the property name on devicetree binding and then get the devfreq device by using devfreq_get_devfreq_by_node().

---
  drivers/devfreq/devfreq.c    | 35 -----------------------------------
  drivers/devfreq/exynos-bus.c | 12 +++++++++++-
  include/linux/devfreq.h      |  8 --------
  3 files changed, 11 insertions(+), 44 deletions(-)
drivers/devfreq/devfreq.c +0 -35
index cb8ca81c8973..c3d3c7c802a0 100644
@@ -991,48 +991,13 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
 
  	return ERR_PTR(-ENODEV);
  }
-
-/*
- * 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);
-
-	devfreq = devfreq_get_devfreq_by_node(node);
-	of_node_put(node);
-
-	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);
 
  /**
   * devm_devfreq_remove_device() - Resource-managed devfreq_remove_device()
drivers/devfreq/exynos-bus.c +10 -0
index 7f5917d59072..1bc4e3c81115 100644
@@ -86,6 +86,16 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
  	return ret;
  }
 
+static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
+{
+	struct device_node *node = of_parse_phandle(np, "devfreq", 0);
+
+	if (!node)
+		return ERR_PTR(-ENODEV);
+
+	return devfreq_get_devfreq_by_node(node);
+}
+
  /*
   * devfreq function for both simple-ondemand and passive governor
   */

drivers/devfreq/exynos-bus.c static int exynos_bus_profile_init_passive(struct exynos_bus *bus, · line 369

Quoted 8 lines
drivers/devfreq/exynos-bus.c +1 -1
@@ -353,7 +363,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
  	profile->exit = exynos_bus_passive_exit;
 
  	/* Get the instance of parent devfreq device */
-	parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
+	parent_devfreq = exynos_bus_get_parent_devfreq(dev->of_node);
  	if (IS_ERR(parent_devfreq))
  		return -EPROBE_DEFER;
 

These changes won't apply, probably I need some base for it.

Regards,
Lukasz

author maintainer
#10 lore raw

Re: [PATCH v2 02/11] PM / devfreq: Remove devfreq_get_devfreq_by_phandle function

Quoted 92 lines · Lukasz Luba

Hi Chanwoo,

Quoted 89 lines · Chanwoo Choi

Previously, devfreq core support 'devfreq' property in order to get the devfreq device by phandle. But, 'devfreq' property name is not proper on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq core hand over the right to decide the property name for getting the devfreq device on devicetree. Each devfreq driver will decide the property name on devicetree binding and then get the devfreq device by using devfreq_get_devfreq_by_node().

---
  drivers/devfreq/devfreq.c    | 35 ----------------------------------- drivers/devfreq/exynos-bus.c | 12 +++++++++++- include/linux/devfreq.h      |  8 --------

  3 files changed, 11 insertions(+), 44 deletions(-)
drivers/devfreq/devfreq.c +0 -35
index cb8ca81c8973..c3d3c7c802a0 100644
@@ -991,48 +991,13 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
         return ERR_PTR(-ENODEV);
   }
-
-/*
- * 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);
-
-    devfreq = devfreq_get_devfreq_by_node(node);
-    of_node_put(node);
-
-    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);
     /**
    * devm_devfreq_remove_device() - Resource-managed devfreq_remove_device()
drivers/devfreq/exynos-bus.c +9 -0
index 7f5917d59072..1bc4e3c81115 100644
@@ -86,6 +86,16 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
       return ret;
   }
   +static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
+{
+    struct device_node *node = of_parse_phandle(np, "devfreq", 0);
+
+    if (!node)
+        return ERR_PTR(-ENODEV);
+
+    return devfreq_get_devfreq_by_node(node);
+}
+
   /*
    * devfreq function for both simple-ondemand and passive governor
    */
@@ -353,7 +363,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
       profile->exit = exynos_bus_passive_exit;
Quoted 8 lines
Quoted 6 lines
drivers/devfreq/exynos-bus.c +1 -1
         /* Get the instance of parent devfreq device */
-    parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
+    parent_devfreq = exynos_bus_get_parent_devfreq(dev->of_node);
       if (IS_ERR(parent_devfreq))
           return -EPROBE_DEFER;

These changes won't apply, probably I need some base for it.

I developed it on devfreq-next branch[1]
[1] https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git/log/?h=devfreq-next

And I try to apply these patchset to linux-next[2] with tags/next-20200109. But, patch10/11 of deviceetree has some merge conflict
because patch[3] related to exynos-bus was merged.
[2] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/
[3] https://patchwork.kernel.org/cover/11303235/
- [v2,0/2] Exynos5422: fix bus related OPPs for Odroid XU3/XU4/HC1

On next version, I'll rebase it on latest patches.

Quoted 6 lines

Regards,
Lukasz

Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics
maintainer
#11 lore raw

Re: [PATCH v2 02/11] PM / devfreq: Remove devfreq_get_devfreq_by_phandle function

Quoted 105 lines · Chanwoo Choi
Quoted 92 lines · Lukasz Luba

Hi Chanwoo,

Quoted 89 lines · Chanwoo Choi

Previously, devfreq core support 'devfreq' property in order to get the devfreq device by phandle. But, 'devfreq' property name is not proper on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq core hand over the right to decide the property name for getting the devfreq device on devicetree. Each devfreq driver will decide the property name on devicetree binding and then get the devfreq device by using devfreq_get_devfreq_by_node().

---
   drivers/devfreq/devfreq.c    | 35 -----------------------------------
   drivers/devfreq/exynos-bus.c | 12 +++++++++++-
   include/linux/devfreq.h      |  8 --------
   3 files changed, 11 insertions(+), 44 deletions(-)
drivers/devfreq/devfreq.c +0 -35
index cb8ca81c8973..c3d3c7c802a0 100644
@@ -991,48 +991,13 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
         return ERR_PTR(-ENODEV);
   }
-
-/*
- * 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);
-
-    devfreq = devfreq_get_devfreq_by_node(node);
-    of_node_put(node);
-
-    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);
     /**
    * devm_devfreq_remove_device() - Resource-managed devfreq_remove_device()
drivers/devfreq/exynos-bus.c +9 -0
index 7f5917d59072..1bc4e3c81115 100644
@@ -86,6 +86,16 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
       return ret;
   }
   +static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
+{
+    struct device_node *node = of_parse_phandle(np, "devfreq", 0);
+
+    if (!node)
+        return ERR_PTR(-ENODEV);
+
+    return devfreq_get_devfreq_by_node(node);
+}
+
   /*
    * devfreq function for both simple-ondemand and passive governor
    */
@@ -353,7 +363,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
       profile->exit = exynos_bus_passive_exit;
Quoted 8 lines

drivers/devfreq/exynos-bus.c static int exynos_bus_profile_init_passive(struct exynos_bus *bus, · line 369

Quoted 6 lines
drivers/devfreq/exynos-bus.c +1 -1
         /* Get the instance of parent devfreq device */
-    parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
+    parent_devfreq = exynos_bus_get_parent_devfreq(dev->of_node);
       if (IS_ERR(parent_devfreq))
           return -EPROBE_DEFER;
 

These changes won't apply, probably I need some base for it.

I developed it on devfreq-next branch[1]
[1] https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git/log/?h=devfreq-next

Quoted 8 lines

And I try to apply these patchset to linux-next[2] with tags/next-20200109. But, patch10/11 of deviceetree has some merge conflict
because patch[3] related to exynos-bus was merged.
[2] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/
[3] https://patchwork.kernel.org/cover/11303235/
- [v2,0/2] Exynos5422: fix bus related OPPs for Odroid XU3/XU4/HC1

On next version, I'll rebase it on latest patches.

Thank you for the information. I will update the base and continue the review.

Lukasz

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#12 lore raw

PATCH v2 3/11 PM / devfreq: event: Add devfreq_event_get_edev_by_node function

In reply to Chanwoo Choi

Previously, devfreq-event core supports 'devfreq-events' property in order to get the devfreq_event_dev device by phandle. But, 'devfreq-events' property name is not proper on devicetree binding because this name doesn't mean the any h/w attribute.

The devfreq-event core hands over the rights of which decide the property name for getting the devfreq device on devicetree, to each devfreq device driver. Each devfreq driver will decide the property name on devicetree binding and then get the devfreq device by using devfreq_event_get_edev_by_node().

And Remove devfreq_event_get_edev_count() function used 'devfreq-events'.

---
 drivers/devfreq/devfreq-event.c         | 53 ++++---------------------
 drivers/devfreq/exynos-bus.c            | 16 +++++++-
 drivers/devfreq/rk3399_dmc.c            | 13 +++++-
 drivers/memory/samsung/exynos5422-dmc.c | 16 ++++++--
 include/linux/devfreq-event.h           | 14 ++-----
 5 files changed, 50 insertions(+), 62 deletions(-)
drivers/devfreq/devfreq-event.c +7 -46
index 8c31b0f2e28f..d0c989acbf93 100644
@@ -210,25 +210,18 @@ int devfreq_event_reset_event(struct devfreq_event_dev *edev)
 EXPORT_SYMBOL_GPL(devfreq_event_reset_event);
 
 /**
- * devfreq_event_get_edev_by_phandle() - Get the devfreq-event dev from
- *					 devicetree.
- * @dev		: the pointer to the given device
- * @index	: the index into list of devfreq-event device
+ * devfreq_event_get_edev_by_node() - Get the devfreq-event dev from devicetree
+ * @node	: the pointer to device_node
  *
  * Note that this function return the pointer of devfreq-event device.
  */
-struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev,
-						      int index)
+struct devfreq_event_dev *devfreq_event_get_edev_by_node(
+					struct device_node *node)
 {
-	struct device_node *node;
 	struct devfreq_event_dev *edev;
 
-	if (!dev->of_node)
-		return ERR_PTR(-EINVAL);
-
-	node = of_parse_phandle(dev->of_node, "devfreq-events", index);
 	if (!node)
-		return ERR_PTR(-ENODEV);
+		return ERR_PTR(-EINVAL);
 
 	mutex_lock(&devfreq_event_list_lock);
 	list_for_each_entry(edev, &devfreq_event_list, node) {
@@ -244,44 +237,12 @@ struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev,
 out:
 	mutex_unlock(&devfreq_event_list_lock);
 
-	if (!edev) {
-		of_node_put(node);
+	if (!edev)
 		return ERR_PTR(-ENODEV);
-	}
-
-	of_node_put(node);
 
 	return edev;
 }
-EXPORT_SYMBOL_GPL(devfreq_event_get_edev_by_phandle);
-
-/**
- * devfreq_event_get_edev_count() - Get the count of devfreq-event dev
- * @dev		: the pointer to the given device
- *
- * Note that this function return the count of devfreq-event devices.
- */
-int devfreq_event_get_edev_count(struct device *dev)
-{
-	int count;
-
-	if (!dev->of_node) {
-		dev_err(dev, "device does not have a device node entry\n");
-		return -EINVAL;
-	}
-
-	count = of_property_count_elems_of_size(dev->of_node, "devfreq-events",
-						sizeof(u32));
-	if (count < 0) {
-		dev_err(dev,
-			"failed to get the count of devfreq-event in %pOF node\n",
-			dev->of_node);
-		return count;
-	}
-
-	return count;
-}
-EXPORT_SYMBOL_GPL(devfreq_event_get_edev_count);
+EXPORT_SYMBOL_GPL(devfreq_event_get_edev_by_node);
 
 static void devfreq_event_release_edev(struct device *dev)
 {
drivers/devfreq/exynos-bus.c +14 -2
index 1bc4e3c81115..c4931ef53f15 100644
@@ -96,6 +96,17 @@ static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
 	return devfreq_get_devfreq_by_node(node);
 }
 
+static struct devfreq_event_dev *exynos_bus_get_edev(struct device_node *np,
+							int index)
+{
+	struct device_node *node = of_parse_phandle(np, "devfreq-events",
+							index);
+
+	if (!node)
+		return ERR_PTR(-ENODEV);
+	return devfreq_event_get_edev_by_node(node);
+}
+
 /*
  * devfreq function for both simple-ondemand and passive governor
  */
@@ -202,7 +213,8 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
 	 * Get the devfreq-event devices to get the current utilization of
 	 * buses. This raw data will be used in devfreq ondemand governor.
 	 */
-	count = devfreq_event_get_edev_count(dev);
+	count = of_property_count_elems_of_size(dev->of_node,
+					"devfreq-events", sizeof(u32));
 	if (count < 0) {
 		dev_err(dev, "failed to get the count of devfreq-event dev\n");
 		ret = count;
@@ -218,7 +230,7 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
 	}
 
 	for (i = 0; i < count; i++) {
-		bus->edev[i] = devfreq_event_get_edev_by_phandle(dev, i);
+		bus->edev[i] = exynos_bus_get_edev(dev->of_node, i);
 		if (IS_ERR(bus->edev[i])) {
 			ret = -EPROBE_DEFER;
 			goto err_regulator;
drivers/devfreq/rk3399_dmc.c +12 -1
index 2f1027c5b647..e712c8662d2f 100644
@@ -303,6 +303,17 @@ static int of_get_ddr_timings(struct dram_timing *timing,
 	return ret;
 }
 
+static struct devfreq_event_dev *of_get_edev(struct device_node *np,
+							int index)
+{
+	struct device_node *node = of_parse_phandle(np, "devfreq-events",
+							index);
+
+	if (!node)
+		return ERR_PTR(-ENODEV);
+	return devfreq_event_get_edev_by_node(node);
+}
+
 static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 {
 	struct arm_smccc_res res;
@@ -339,7 +350,7 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 		return PTR_ERR(data->dmc_clk);
 	}
 
-	data->edev = devfreq_event_get_edev_by_phandle(dev, 0);
+	data->edev = of_get_edev(dev->of_node, 0);
 	if (IS_ERR(data->edev))
 		return -EPROBE_DEFER;
 
drivers/memory/samsung/exynos5422-dmc.c +13 -3
index 47dbf6d1789f..f11fe29a69fc 100644
@@ -1267,6 +1267,16 @@ static int exynos5_dmc_init_clks(struct exynos5_dmc *dmc)
 	return 0;
 }
 
+static struct devfreq_event_dev *exynos5_dmc_get_edev(struct device_node *np,
+							int index)
+{
+	struct device_node *node = of_parse_phandle(np, "devfreq-events",
+							index);
+	if (!node)
+		return ERR_PTR(-ENODEV);
+	return devfreq_event_get_edev_by_node(node);
+}
+
 /**
  * exynos5_performance_counters_init() - Initializes performance DMC's counters
  * @dmc:	DMC for which it does the setup
@@ -1281,7 +1291,8 @@ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc)
 	int counters_size;
 	int ret, i;
 
-	dmc->num_counters = devfreq_event_get_edev_count(dmc->dev);
+	dmc->num_counters = of_property_count_elems_of_size(dmc->dev->of_node,
+					"devfreq-events", sizeof(u32));
 	if (dmc->num_counters < 0) {
 		dev_err(dmc->dev, "could not get devfreq-event counters\n");
 		return dmc->num_counters;
@@ -1293,8 +1304,7 @@ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc)
 		return -ENOMEM;
 
 	for (i = 0; i < dmc->num_counters; i++) {
-		dmc->counter[i] =
-			devfreq_event_get_edev_by_phandle(dmc->dev, i);
+		dmc->counter[i] = exynos5_dmc_get_edev(dmc->dev->of_node, i);
 		if (IS_ERR_OR_NULL(dmc->counter[i]))
 			return -EPROBE_DEFER;
 	}
include/linux/devfreq-event.h +4 -10
index f14f17f8cb7f..967414ac6f7c 100644
@@ -105,9 +105,8 @@ extern int devfreq_event_set_event(struct devfreq_event_dev *edev);
 extern int devfreq_event_get_event(struct devfreq_event_dev *edev,
 				struct devfreq_event_data *edata);
 extern int devfreq_event_reset_event(struct devfreq_event_dev *edev);
-extern struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
-				struct device *dev, int index);
-extern int devfreq_event_get_edev_count(struct device *dev);
+extern struct devfreq_event_dev *devfreq_event_get_edev_by_node(
+				struct device_node *node);
 extern struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
 				struct devfreq_event_desc *desc);
 extern int devfreq_event_remove_edev(struct devfreq_event_dev *edev);
@@ -151,17 +150,12 @@ static inline int devfreq_event_reset_event(struct devfreq_event_dev *edev)
 	return -EINVAL;
 }
 
-static inline struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
-					struct device *dev, int index)
+static inline struct devfreq_event_dev *devfreq_event_get_edev_by_node(
+					struct device_node *node)
 {
 	return ERR_PTR(-EINVAL);
 }
 
-static inline int devfreq_event_get_edev_count(struct device *dev)
-{
-	return -EINVAL;
-}
-
 static inline struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
 					struct devfreq_event_desc *desc)
 {
Signature · 1 line
2.17.1
author maintainer
#13 lore raw

PATCH v2 4/11 dt-bindings: devfreq: exynos-bus: Replace deprecated 'devfreq' and 'devfreq-events' property

In reply to Chanwoo Choi

In order to remove the deprecated 'devfreq' and 'devfreq-events' property, replace with new following properties
- Replace 'devfreq' with 'exynos,parent-bus' property
- Replace 'devfreq-events' with 'exynos,ppmu-device' property

---
 .../bindings/devfreq/exynos-bus.txt           | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/devfreq/exynos-bus.txt +11 -11
index e71f752cc18f..c6c2dd0e77c8 100644
@@ -41,11 +41,11 @@ Required properties for all bus devices:
 
 Required properties only for parent bus device:
 - vdd-supply: the regulator to provide the buses with the voltage.
-- devfreq-events: the devfreq-event device to monitor the current utilization
+- exynos,ppmu-device: the devfreq-event device to monitor the current utilization
   of buses.
 
 Required properties only for passive bus device:
-- devfreq: the parent bus device.
+- exynos,parent-bus: the parent bus device.
 
 Optional properties only for parent bus device:
 - exynos,saturation-ratio: the percentage value which is used to calibrate
@@ -374,48 +374,48 @@ Example2 :
 	in exynos3250-rinato.dts is listed below:
 
 	&bus_dmc {
-		devfreq-events = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
+		exynos,ppmu-device = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
 		vdd-supply = <&buck1_reg>;	/* VDD_MIF */
 		status = "okay";
 	};
 
 	&bus_leftbus {
-		devfreq-events = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
+		exynos,ppmu-device = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
 		vdd-supply = <&buck3_reg>;
 		status = "okay";
 	};
 
 	&bus_rightbus {
-		devfreq = <&bus_leftbus>;
+		exynos,parent-bus = <&bus_leftbus>;
 		status = "okay";
 	};
 
 	&bus_lcd0 {
-		devfreq = <&bus_leftbus>;
+		exynos,parent-bus = <&bus_leftbus>;
 		status = "okay";
 	};
 
 	&bus_fsys {
-		devfreq = <&bus_leftbus>;
+		exynos,parent-bus = <&bus_leftbus>;
 		status = "okay";
 	};
 
 	&bus_mcuisp {
-		devfreq = <&bus_leftbus>;
+		exynos,parent-bus = <&bus_leftbus>;
 		status = "okay";
 	};
 
 	&bus_isp {
-		devfreq = <&bus_leftbus>;
+		exynos,parent-bus = <&bus_leftbus>;
 		status = "okay";
 	};
 
 	&bus_peril {
-		devfreq = <&bus_leftbus>;
+		exynos,parent-bus = <&bus_leftbus>;
 		status = "okay";
 	};
 
 	&bus_mfc {
-		devfreq = <&bus_leftbus>;
+		exynos,parent-bus = <&bus_leftbus>;
 		status = "okay";
 	};
Signature · 1 line
2.17.1
maintainer Acked-by on v2 4/11
#14 lore raw

Re: [PATCH v2 04/11] dt-bindings: devfreq: exynos-bus: Replace deprecated 'devfreq' and 'devfreq-events' property

Quoted 9 lines · Chanwoo Choi

In order to remove the deprecated 'devfreq' and 'devfreq-events' property, replace with new following properties
- Replace 'devfreq' with 'exynos,parent-bus' property
- Replace 'devfreq-events' with 'exynos,ppmu-device' property

---
 .../bindings/devfreq/exynos-bus.txt           | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Best regards,
Krzysztof

author maintainer
#15 lore raw

PATCH v2 5/11 dt-bindings: devfreq: rk3399_dmc: Replace deprecated 'devfreq-events' property

In reply to Chanwoo Choi

In order to remove the deprecated 'devfreq-events' property, replace with new 'rockchip,dfi-device' property.

But, to guarantee the backward-compatibility, keep the support of 'devfreq-events' property.

---
 Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt +2 -2
index 0ec68141f85a..e484768a4077 100644
@@ -2,7 +2,7 @@
 
 Required properties:
 - compatible:		 Must be "rockchip,rk3399-dmc".
-- devfreq-events:	 Node to get DDR loading, Refer to
+- rockchip,dfi-device:	 Node to get DDR loading, Refer to
 			 Documentation/devicetree/bindings/devfreq/event/
 			 rockchip-dfi.txt
 - clocks:		 Phandles for clock specified in "clock-names" property
@@ -173,7 +173,7 @@ Example:
 
 	dmc: dmc {
 		compatible = "rockchip,rk3399-dmc";
-		devfreq-events = <&dfi>;
+		rockchip,dfi-device = <&dfi>;
 		interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&cru SCLK_DDRCLK>;
 		clock-names = "dmc_clk";
Signature · 1 line
2.17.1
author maintainer
#16 lore raw

PATCH v2 6/11 dt-bindings: memory: exynos5422-dmc: Replace the deprecated 'devfreq-events' property

In reply to Chanwoo Choi

Replace the deprecated 'devfreq-events' property with 'exynos,ppmu-device' property. But, to guarantee the backward-compatibility, keep the support of 'devfreq-events' property.

---
 .../bindings/memory-controllers/exynos5422-dmc.txt        | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/memory-controllers/exynos5422-dmc.txt +4 -4
index 02e4a1f862f1..fbecbcc00adb 100644
@@ -17,14 +17,14 @@ Required properties for DMC device for Exynos5422:
 - clock-names : should include "fout_spll", "mout_sclk_spll", "ff_dout_spll2",
   "fout_bpll", "mout_bpll", "sclk_bpll", "mout_mx_mspll_ccore",
   "mout_mclk_cdrex"  entries
-- devfreq-events : phandles for PPMU devices connected to this DMC.
+- exynos,ppmu-device : phandles for PPMU devices connected to this DMC.
 - vdd-supply : phandle for voltage regulator which is connected.
 - reg : registers of two CDREX controllers.
 - operating-points-v2 : phandle for OPPs described in v2 definition.
 - device-handle : phandle of the connected DRAM memory device. For more
 	information please refer to documentation file:
 	Documentation/devicetree/bindings/ddr/lpddr3.txt
-- devfreq-events : phandles of the PPMU events used by the controller.
+- exynos,ppmu-device : phandles of the PPMU events used by the controller.
 - samsung,syscon-clk : phandle of the clock register set used by the controller,
 	these registers are used for enabling a 'pause' feature and are not
 	exposed by clock framework but they must be used in a safe way.
@@ -73,8 +73,8 @@ Example:
 			      "mout_mx_mspll_ccore",
 			      "mout_mclk_cdrex";
 		operating-points-v2 = <&dmc_opp_table>;
-		devfreq-events = <&ppmu_event3_dmc0_0>,	<&ppmu_event3_dmc0_1>,
-				 <&ppmu_event3_dmc1_0>, <&ppmu_event3_dmc1_1>;
+		exynos,ppmu-device = <&ppmu_event3_dmc0_0>, <&ppmu_event3_dmc0_1>,
+				     <&ppmu_event3_dmc1_0>, <&ppmu_event3_dmc1_1>;
 		device-handle = <&samsung_K3QF2F20DB>;
 		vdd-supply = <&buck1_reg>;
 		samsung,syscon-clk = <&clock>;
Signature · 1 line
2.17.1
author maintainer
#17 lore raw

PATCH v2 7/11 PM / devfreq: exynos-bus: Replace the deprecated 'devfreq' and 'devfreq-events' property

In reply to Chanwoo Choi

Replace the deprecated 'devfreq' and 'devfreq-events' property with new following properties.
- 'devfreq' is changed to 'exynos,parent-bus' property
- 'devfreq-events' is changed to 'exynos,ppmu-device' property But, to guarantee the backward-compatibility, keep the support both 'devfreq' and 'devfreq-events' property.

---
 drivers/devfreq/exynos-bus.c | 52 +++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 15 deletions(-)
drivers/devfreq/exynos-bus.c +37 -15
index c4931ef53f15..9fdb188915e8 100644
@@ -88,22 +88,35 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
 
 static struct devfreq *exynos_bus_get_parent_devfreq(struct device_node *np)
 {
-	struct device_node *node = of_parse_phandle(np, "devfreq", 0);
-
-	if (!node)
-		return ERR_PTR(-ENODEV);
-
+	struct device_node *node = of_parse_phandle(np, "exynos,parent-bus", 0);
+
+	if (!node) {
+		/*
+		 * Check the deprecated 'devfreq' property
+		 * to support backward-compatibility.
+		 */
+		node = of_parse_phandle(np, "devfreq", 0);
+		if (!node)
+			return ERR_PTR(-ENODEV);
+	}
 	return devfreq_get_devfreq_by_node(node);
 }
 
 static struct devfreq_event_dev *exynos_bus_get_edev(struct device_node *np,
 							int index)
 {
-	struct device_node *node = of_parse_phandle(np, "devfreq-events",
-							index);
-
-	if (!node)
-		return ERR_PTR(-ENODEV);
+	struct device_node *node = of_parse_phandle(np,
+					"exynos,ppmu-device", index);
+
+	if (!node) {
+		/*
+		 * Check the deprecated 'devfreq-events' property
+		 * to support backward-compatibility.
+		 */
+		node = of_parse_phandle(np, "devfreq-events", index);
+		if (!node)
+			return ERR_PTR(-ENODEV);
+	}
 	return devfreq_event_get_edev_by_node(node);
 }
 
@@ -214,11 +227,20 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
 	 * buses. This raw data will be used in devfreq ondemand governor.
 	 */
 	count = of_property_count_elems_of_size(dev->of_node,
-					"devfreq-events", sizeof(u32));
+					"exynos,ppmu-device", sizeof(u32));
 	if (count < 0) {
-		dev_err(dev, "failed to get the count of devfreq-event dev\n");
-		ret = count;
-		goto err_regulator;
+		/*
+		 * Check the deprecated 'devfreq-events' property
+		 * to support backward-compatibility.
+		 */
+		count = of_property_count_elems_of_size(dev->of_node,
+					"devfreq-events", sizeof(u32));
+		if (count < 0) {
+			dev_err(dev,
+				"failed to get the count of devfreq-event dev\n");
+			ret = count;
+			goto err_regulator;
+		}
 	}
 	bus->edev_count = count;
 
@@ -423,7 +445,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
 	if (!profile)
 		return -ENOMEM;
 
-	node = of_parse_phandle(dev->of_node, "devfreq", 0);
+	node = of_parse_phandle(dev->of_node, "exynos,parent-bus", 0);
 	if (node) {
 		of_node_put(node);
 		passive = true;
Signature · 1 line
2.17.1
author maintainer
#18 lore raw

PATCH v2 8/11 PM / devfreq: rk3399_dmc: Replace the deprecated 'devfreq-events' property

In reply to Chanwoo Choi

Replace the deprecated 'devfreq-events' property with 'rockchip,dfi-device' property. But, to guarantee the backward-compatibility, keep the support of 'devfreq-events' property.

---
 drivers/devfreq/rk3399_dmc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/devfreq/rk3399_dmc.c +6 -3
index e712c8662d2f..2294de13a3dc 100644
@@ -306,11 +306,14 @@ static int of_get_ddr_timings(struct dram_timing *timing,
 static struct devfreq_event_dev *of_get_edev(struct device_node *np,
 							int index)
 {
-	struct device_node *node = of_parse_phandle(np, "devfreq-events",
+	struct device_node *node = of_parse_phandle(np, "rockchip,dfi-device",
 							index);
 
-	if (!node)
-		return ERR_PTR(-ENODEV);
+	if (!node) {
+		node = of_parse_phandle(np, "devfreq-events", index);
+		if (!node)
+			return ERR_PTR(-ENODEV);
+	}
 	return devfreq_event_get_edev_by_node(node);
 }
 
Signature · 1 line
2.17.1
author maintainer
#19 lore raw

PATCH v2 9/11 memory: samsung: exynos5422-dmc: Replace the deprecated 'devfreq-events' property

In reply to Chanwoo Choi

Replace the deprecated 'devfreq-events' property with 'exynos,ppmu-device' property. But, to guarantee the backward-compatibility, keep the support of 'devfreq-events' property.

---
 drivers/memory/samsung/exynos5422-dmc.c | 29 ++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 6 deletions(-)
drivers/memory/samsung/exynos5422-dmc.c +23 -6
index f11fe29a69fc..6e8aa19e84d3 100644
@@ -1270,10 +1270,17 @@ static int exynos5_dmc_init_clks(struct exynos5_dmc *dmc)
 static struct devfreq_event_dev *exynos5_dmc_get_edev(struct device_node *np,
 							int index)
 {
-	struct device_node *node = of_parse_phandle(np, "devfreq-events",
+	struct device_node *node = of_parse_phandle(np, "exynos,ppmu-device",
 							index);
-	if (!node)
-		return ERR_PTR(-ENODEV);
+	if (!node) {
+		 /*
+		  * Check the deprecated 'devfreq-events' property
+		  * to support backward-compatibility.
+		 */
+		node = of_parse_phandle(np, "devfreq-events", index);
+		if (!node)
+			return ERR_PTR(-ENODEV);
+	}
 	return devfreq_event_get_edev_by_node(node);
 }
 
@@ -1292,10 +1299,20 @@ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc)
 	int ret, i;
 
 	dmc->num_counters = of_property_count_elems_of_size(dmc->dev->of_node,
-					"devfreq-events", sizeof(u32));
+					"exynos,ppmu-device", sizeof(u32));
 	if (dmc->num_counters < 0) {
-		dev_err(dmc->dev, "could not get devfreq-event counters\n");
-		return dmc->num_counters;
+		 /*
+		  * Check the deprecated 'devfreq-events' property
+		  * to support backward-compatibility.
+		 */
+		dmc->num_counters = of_property_count_elems_of_size(
+					dmc->dev->of_node,
+					"devfreq-events", sizeof(u32));
+		if (dmc->num_counters < 0) {
+			dev_err(dmc->dev,
+				"could not get devfreq-event counters\n");
+			return dmc->num_counters;
+		}
 	}
 
 	counters_size = sizeof(struct devfreq_event_dev) * dmc->num_counters;
Signature · 1 line
2.17.1
author maintainer
#20 lore raw

PATCH v2 10/11 ARM: dts: exynos: Replace deprecated property for Exynos bus and DMC

In reply to Chanwoo Choi

Replace the property related to devfreq and devfreq-event device to remove the deprecated property name.
- Replace 'devfreq' with 'exynos,parent-bus' property for getting the parent devfreq device of exynos-bus.
- Replace 'devfreq-events' with 'exynos,ppmu-device' property for getting the devfreq-event device to monitor bus utilization.

---
 arch/arm/boot/dts/exynos3250-monk.dts         |  2 +-
 arch/arm/boot/dts/exynos3250-rinato.dts       | 18 +++++-----
 .../boot/dts/exynos4412-itop-scp-core.dtsi    | 16 ++++-----
 arch/arm/boot/dts/exynos4412-midas.dtsi       | 18 +++++-----
 .../boot/dts/exynos4412-odroid-common.dtsi    | 18 +++++-----
 arch/arm/boot/dts/exynos5422-odroid-core.dtsi | 34 +++++++++----------
 6 files changed, 53 insertions(+), 53 deletions(-)
arch/arm/boot/dts/exynos3250-monk.dts +1 -1
index 248bd372fe70..c6b1fcd4ba97 100644
@@ -158,7 +158,7 @@
 };
 
 &bus_dmc {
-	devfreq-events = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
+	exynos,ppmu-device = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
 	vdd-supply = <&buck1_reg>;
 	status = "okay";
 };
arch/arm/boot/dts/exynos3250-rinato.dts +9 -9
index 86c26a4edfd7..7ad80354d8df 100644
@@ -153,49 +153,49 @@
 };
 
 &bus_dmc {
-	devfreq-events = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
+	exynos,ppmu-device = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
 	vdd-supply = <&buck1_reg>;
 	status = "okay";
 };
 
 &bus_leftbus {
-	devfreq-events = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
+	exynos,ppmu-device = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
 	vdd-supply = <&buck3_reg>;
 	status = "okay";
 };
 
 &bus_rightbus {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_lcd0 {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_fsys {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_mcuisp {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_isp {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_peril {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_mfc {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi +8 -8
index dfceb155b3a7..e275a52eb0d3 100644
@@ -70,44 +70,44 @@
 };
 
 &bus_dmc {
-	devfreq-events = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
+	exynos,ppmu-device = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
 	vdd-supply = <&buck1_reg>;
 	status = "okay";
 };
 
 &bus_acp {
-	devfreq = <&bus_dmc>;
+	exynos,parent-bus = <&bus_dmc>;
 	status = "okay";
 };
 
 &bus_c2c {
-	devfreq = <&bus_dmc>;
+	exynos,parent-bus = <&bus_dmc>;
 	status = "okay";
 };
 
 &bus_leftbus {
-	devfreq-events = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
+	exynos,ppmu-device = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
 	vdd-supply = <&buck3_reg>;
 	status = "okay";
 };
 
 &bus_rightbus {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_fsys {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_peri {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_mfc {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
arch/arm/boot/dts/exynos4412-midas.dtsi +9 -9
index 83be3a797411..1869eed05167 100644
@@ -288,49 +288,49 @@
 };
 
 &bus_dmc {
-	devfreq-events = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
+	exynos,ppmu-device = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
 	vdd-supply = <&buck1_reg>;
 	status = "okay";
 };
 
 &bus_acp {
-	devfreq = <&bus_dmc>;
+	exynos,parent-bus = <&bus_dmc>;
 	status = "okay";
 };
 
 &bus_c2c {
-	devfreq = <&bus_dmc>;
+	exynos,parent-bus = <&bus_dmc>;
 	status = "okay";
 };
 
 &bus_leftbus {
-	devfreq-events = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
+	exynos,ppmu-device = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
 	vdd-supply = <&buck3_reg>;
 	status = "okay";
 };
 
 &bus_rightbus {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_display {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_fsys {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_peri {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_mfc {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
arch/arm/boot/dts/exynos4412-odroid-common.dtsi +9 -9
index ea55f377d17c..bb5a7cbcc308 100644
@@ -88,49 +88,49 @@
 };
 
 &bus_dmc {
-	devfreq-events = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
+	exynos,ppmu-device = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
 	vdd-supply = <&buck1_reg>;
 	status = "okay";
 };
 
 &bus_acp {
-	devfreq = <&bus_dmc>;
+	exynos,parent-bus = <&bus_dmc>;
 	status = "okay";
 };
 
 &bus_c2c {
-	devfreq = <&bus_dmc>;
+	exynos,parent-bus = <&bus_dmc>;
 	status = "okay";
 };
 
 &bus_leftbus {
-	devfreq-events = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
+	exynos,ppmu-device = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
 	vdd-supply = <&buck3_reg>;
 	status = "okay";
 };
 
 &bus_rightbus {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_display {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_fsys {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_peri {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
 &bus_mfc {
-	devfreq = <&bus_leftbus>;
+	exynos,parent-bus = <&bus_leftbus>;
 	status = "okay";
 };
 
arch/arm/boot/dts/exynos5422-odroid-core.dtsi +17 -17
index 059fa32d1a8f..8510e2787a9c 100644
@@ -134,7 +134,7 @@
 };
 
 &bus_wcore {
-	devfreq-events = <&nocp_mem0_0>, <&nocp_mem0_1>,
+	exynos,ppmu-device = <&nocp_mem0_0>, <&nocp_mem0_1>,
 			<&nocp_mem1_0>, <&nocp_mem1_1>;
 	vdd-supply = <&buck3_reg>;
 	exynos,saturation-ratio = <100>;
@@ -142,77 +142,77 @@
 };
 
 &bus_noc {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_fsys_apb {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_fsys {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_fsys2 {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_mfc {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_gen {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_peri {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_g2d {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_g2d_acp {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_jpeg {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_jpeg_apb {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_disp1_fimd {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_disp1 {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_gscl_scaler {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
 &bus_mscl {
-	devfreq = <&bus_wcore>;
+	exynos,parent-bus = <&bus_wcore>;
 	status = "okay";
 };
 
@@ -225,7 +225,7 @@
 };
 
 &dmc {
-	devfreq-events = <&ppmu_event3_dmc0_0>,	<&ppmu_event3_dmc0_1>,
+	exynos,ppmu-device = <&ppmu_event3_dmc0_0>, <&ppmu_event3_dmc0_1>,
 			<&ppmu_event3_dmc1_0>, <&ppmu_event3_dmc1_1>;
 	device-handle = <&samsung_K3QF2F20DB>;
 	operating-points-v2 = <&dmc_opp_table>;
Signature · 1 line
2.17.1
author maintainer
#21 lore raw

PATCH v2 11/11 arm64: dts: exynos: Replace deprecated property for Exynos bus on TM2

In reply to Chanwoo Choi

Replace the property related to devfreq and devfreq-event device to remove the deprecated property name.
- Replace 'devfreq' with 'exynos,parent-bus' property for getting the parent devfreq device of exynos-bus.
- Replace 'devfreq-events' with 'exynos,ppmu-device' property for getting the devfreq-event device to monitor bus utilization.

---
 .../dts/exynos/exynos5433-tm2-common.dtsi     | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi +10 -10
index 6f90b0e62cba..6bdd5b0940a5 100644
@@ -166,54 +166,54 @@
 };
 
 &bus_g2d_400 {
-	devfreq-events = <&ppmu_event0_d0_general>, <&ppmu_event0_d1_general>;
+	exynos,ppmu-device = <&ppmu_event0_d0_general>, <&ppmu_event0_d1_general>;
 	vdd-supply = <&buck4_reg>;
 	exynos,saturation-ratio = <10>;
 	status = "okay";
 };
 
 &bus_g2d_266 {
-	devfreq = <&bus_g2d_400>;
+	exynos,parent-bus = <&bus_g2d_400>;
 	status = "okay";
 };
 
 &bus_gscl {
-	devfreq = <&bus_g2d_400>;
+	exynos,parent-bus = <&bus_g2d_400>;
 	status = "okay";
 };
 
 &bus_hevc {
-	devfreq = <&bus_g2d_400>;
+	exynos,parent-bus = <&bus_g2d_400>;
 	status = "okay";
 };
 
 &bus_jpeg {
-	devfreq = <&bus_g2d_400>;
+	exynos,parent-bus = <&bus_g2d_400>;
 	status = "okay";
 };
 
 &bus_mfc {
-	devfreq = <&bus_g2d_400>;
+	exynos,parent-bus = <&bus_g2d_400>;
 	status = "okay";
 };
 
 &bus_mscl {
-	devfreq = <&bus_g2d_400>;
+	exynos,parent-bus = <&bus_g2d_400>;
 	status = "okay";
 };
 
 &bus_noc0 {
-	devfreq = <&bus_g2d_400>;
+	exynos,parent-bus = <&bus_g2d_400>;
 	status = "okay";
 };
 
 &bus_noc1 {
-	devfreq = <&bus_g2d_400>;
+	exynos,parent-bus = <&bus_g2d_400>;
 	status = "okay";
 };
 
 &bus_noc2 {
-	devfreq = <&bus_g2d_400>;
+	exynos,parent-bus = <&bus_g2d_400>;
 	status = "okay";
 };
 
Signature · 1 line
2.17.1