Skip to contentSkip to conversation

PM / devfreq: Deprecate fixed property name by using phandle get

PATCH In review Chanwoo Choi 2 participants 8 messages Sep 8, 2020 – Sep 14, 2020 1 message not in the archive

Subsystems (6)
lore
Share & tools
lore

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

Chanwoo Choi

author maintainer
#1 lore raw

v3 cover PM / devfreq: Deprecate fixed property name by using phandle get

Pirot to that devfreq and devfreq-event framework defines the fixed 'devfreq' and 'devfreq-event' property to get the devfreq/devfreq-event phandle. But, these property name are not expressing the h/w. So, deprecate the fixed property name of both 'devfreq' and 'devfreq-event'. But, in order to keep the backward compatibility of devicetree, doesn't change the property name on devfreq device drivers and devicetree.

This patchset picks only three patches from patchset[1].

[1] https://patchwork.kernel.org/cover/11304545/
- [v2,00/11] PM / devfreq: Remove deprecated 'devfreq' and 'devfreq-events' properties

Changes from v2:
- Send the patches related to both devfreq_get_devfreq_by_phandle and devfreq_event_get_edev_by_phandle function to change the function prototype.

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

Chanwoo Choi (2):
PM / devfreq: Change prototype of devfreq_get_devfreq_by_phandle function PM / devfreq: event: Change prototype of devfreq_event_get_edev_by_phandle function

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

 drivers/devfreq/devfreq-event.c         | 14 +++---
 drivers/devfreq/devfreq.c               | 57 ++++++++++++++++++-------
 drivers/devfreq/exynos-bus.c            |  7 +--
 drivers/devfreq/rk3399_dmc.c            |  2 +-
 drivers/memory/samsung/exynos5422-dmc.c |  6 ++-
 include/linux/devfreq-event.h           | 14 ++++--
 include/linux/devfreq.h                 | 11 ++++-
 7 files changed, 78 insertions(+), 33 deletions(-)
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v3 1/3 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.

[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 561d91b2d3bf..b9b27fb3291e 100644
@@ -983,6 +983,32 @@ struct devfreq *devm_devfreq_add_device(struct device *dev,
 EXPORT_SYMBOL(devm_devfreq_add_device);
 
 #ifdef CONFIG_OF
+/*
+ * devfreq_get_devfreq_by_node - Get the devfreq device from devicetree
+ * @node - pointer to device_node
+ *
+ * return the instance of devfreq device
+ */
+struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
+{
+	struct devfreq *devfreq;
+
+	if (!node)
+		return ERR_PTR(-EINVAL);
+
+	mutex_lock(&devfreq_list_lock);
+	list_for_each_entry(devfreq, &devfreq_list, node) {
+		if (devfreq->dev.parent
+			&& devfreq->dev.parent->of_node == node) {
+			mutex_unlock(&devfreq_list_lock);
+			return devfreq;
+		}
+	}
+	mutex_unlock(&devfreq_list_lock);
+
+	return ERR_PTR(-ENODEV);
+}
+
 /*
  * devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree
  * @dev - instance to the given device
@@ -1005,26 +1031,24 @@ struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index)
 	if (!node)
 		return ERR_PTR(-ENODEV);
 
-	mutex_lock(&devfreq_list_lock);
-	list_for_each_entry(devfreq, &devfreq_list, node) {
-		if (devfreq->dev.parent
-			&& devfreq->dev.parent->of_node == node) {
-			mutex_unlock(&devfreq_list_lock);
-			of_node_put(node);
-			return devfreq;
-		}
-	}
-	mutex_unlock(&devfreq_list_lock);
+	devfreq = devfreq_get_devfreq_by_node(node);
 	of_node_put(node);
 
-	return ERR_PTR(-EPROBE_DEFER);
+	return devfreq;
 }
+
 #else
+struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
+{
+	return ERR_PTR(-ENODEV);
+}
+
 struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index)
 {
 	return ERR_PTR(-ENODEV);
 }
 #endif /* CONFIG_OF */
+EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_node);
 EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_phandle);
 
 /**
include/linux/devfreq.h +6 -0
index 12782fbb4c25..eb971b8e5051 100644
@@ -261,6 +261,7 @@ void devm_devfreq_unregister_notifier(struct device *dev,
 				struct devfreq *devfreq,
 				struct notifier_block *nb,
 				unsigned int list);
+struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node);
 struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index);
 
 #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
@@ -414,6 +415,11 @@ static inline void devm_devfreq_unregister_notifier(struct device *dev,
 {
 }
 
+static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
+{
+	return ERR_PTR(-ENODEV);
+}
+
 static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
 					int index)
 {
Signature · 1 line
2.17.1
maintainer Acked-by on v3 1/3
#3 lore raw

Re: [PATCH v3 1/3] PM / devfreq: Add devfreq_get_devfreq_by_node function

Quoted 8 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.

Quoted 7 lines

[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(-)

Best regards,
Krzysztof

author maintainer
#4 lore raw

PATCH v3 2/3 PM / devfreq: Change prototype of 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 pass the their own property name to devfreq_get_devfreq_by_phandle function.

---
 drivers/devfreq/devfreq.c    | 11 +++++++----
 drivers/devfreq/exynos-bus.c |  2 +-
 include/linux/devfreq.h      |  5 +++--
 3 files changed, 11 insertions(+), 7 deletions(-)
drivers/devfreq/devfreq.c +7 -4
index b9b27fb3291e..d22bf3ce0404 100644
@@ -1012,22 +1012,24 @@ struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
 /*
  * devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree
  * @dev - instance to the given device
+ * @phandle_name - name of property holding a phandle value
  * @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 devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
+					const char *phandle_name, int index)
 {
 	struct device_node *node;
 	struct devfreq *devfreq;
 
-	if (!dev)
+	if (!dev || !phandle_name)
 		return ERR_PTR(-EINVAL);
 
 	if (!dev->of_node)
 		return ERR_PTR(-EINVAL);
 
-	node = of_parse_phandle(dev->of_node, "devfreq", index);
+	node = of_parse_phandle(dev->of_node, phandle_name, index);
 	if (!node)
 		return ERR_PTR(-ENODEV);
 
@@ -1043,7 +1045,8 @@ 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)
+struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
+					const char *phandle_name, int index)
 {
 	return ERR_PTR(-ENODEV);
 }
drivers/devfreq/exynos-bus.c +1 -1
index 8fa8eb541373..58dbf51f0983 100644
@@ -360,7 +360,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 = devfreq_get_devfreq_by_phandle(dev, "devfreq", 0);
 	if (IS_ERR(parent_devfreq))
 		return -EPROBE_DEFER;
 
include/linux/devfreq.h +3 -2
index eb971b8e5051..2f4a74efa6be 100644
@@ -262,7 +262,8 @@ void devm_devfreq_unregister_notifier(struct device *dev,
 				struct notifier_block *nb,
 				unsigned int list);
 struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node);
-struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index);
+struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
+				const char *phandle_name, int index);
 
 #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
 /**
@@ -421,7 +422,7 @@ static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *no
 }
 
 static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
-					int index)
+					const char *phandle_name, int index)
 {
 	return ERR_PTR(-ENODEV);
 }
Signature · 1 line
2.17.1
maintainer Acked-by on v3 2/3
#5 lore raw

Re: [PATCH v3 2/3] PM / devfreq: Change prototype of devfreq_get_devfreq_by_phandle function

Quoted 9 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 pass the their own property name to devfreq_get_devfreq_by_phandle function.

Quoted 6 lines
---
 drivers/devfreq/devfreq.c    | 11 +++++++----
 drivers/devfreq/exynos-bus.c |  2 +-
 include/linux/devfreq.h      |  5 +++--
 3 files changed, 11 insertions(+), 7 deletions(-)

Best regards,
Krzysztof

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

author maintainer
#6 lore raw

PATCH v3 3/3 PM / devfreq: event: Change prototype of devfreq_event_get_edev_by_phandle function

In reply to Chanwoo Choi

Previously, devfreq core support 'devfreq-events' property in order to get the devfreq-event 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 hand over the rights to decide the property name for getting the devfreq-event device on devicetree. Each devfreq-event driver will decide the property name on devicetree binding and then pass the their own property name to devfreq_event_get_edev_by_phandle function.

And change the prototype of devfreq_event_get_edev_count function because of used deprecated 'devfreq-events' property.

---
 drivers/devfreq/devfreq-event.c         | 14 ++++++++------
 drivers/devfreq/exynos-bus.c            |  5 +++--
 drivers/devfreq/rk3399_dmc.c            |  2 +-
 drivers/memory/samsung/exynos5422-dmc.c |  6 ++++--
 include/linux/devfreq-event.h           | 14 ++++++++++----
 5 files changed, 26 insertions(+), 15 deletions(-)
drivers/devfreq/devfreq-event.c +8 -6
index 56efbeb7851e..6765c03334bc 100644
@@ -213,20 +213,21 @@ 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
+ * @phandle_name: name of property holding a phandle value
  * @index	: the index into list of devfreq-event device
  *
  * 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)
+					const char *phandle_name, int index)
 {
 	struct device_node *node;
 	struct devfreq_event_dev *edev;
 
-	if (!dev->of_node)
+	if (!dev->of_node || !phandle_name)
 		return ERR_PTR(-EINVAL);
 
-	node = of_parse_phandle(dev->of_node, "devfreq-events", index);
+	node = of_parse_phandle(dev->of_node, phandle_name, index);
 	if (!node)
 		return ERR_PTR(-ENODEV);
 
@@ -258,19 +259,20 @@ 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
+ * @phandle_name: name of property holding a phandle value
  *
  * Note that this function return the count of devfreq-event devices.
  */
-int devfreq_event_get_edev_count(struct device *dev)
+int devfreq_event_get_edev_count(struct device *dev, const char *phandle_name)
 {
 	int count;
 
-	if (!dev->of_node) {
+	if (!dev->of_node || !phandle_name) {
 		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",
+	count = of_property_count_elems_of_size(dev->of_node, phandle_name,
 						sizeof(u32));
 	if (count < 0) {
 		dev_err(dev,
drivers/devfreq/exynos-bus.c +3 -2
index 58dbf51f0983..1e684a448c9e 100644
@@ -193,7 +193,7 @@ 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 = devfreq_event_get_edev_count(dev, "devfreq-events");
 	if (count < 0) {
 		dev_err(dev, "failed to get the count of devfreq-event dev\n");
 		ret = count;
@@ -209,7 +209,8 @@ 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] = devfreq_event_get_edev_by_phandle(dev,
+							"devfreq-events", i);
 		if (IS_ERR(bus->edev[i])) {
 			ret = -EPROBE_DEFER;
 			goto err_regulator;
drivers/devfreq/rk3399_dmc.c +1 -1
index 027769e39f9b..2e912166a993 100644
@@ -341,7 +341,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 = devfreq_event_get_edev_by_phandle(dev, "devfreq-events", 0);
 	if (IS_ERR(data->edev))
 		return -EPROBE_DEFER;
 
drivers/memory/samsung/exynos5422-dmc.c +4 -2
index b9c7956e5031..714d1f6f077c 100644
@@ -1293,7 +1293,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 = devfreq_event_get_edev_count(dmc->dev,
+							"devfreq-events");
 	if (dmc->num_counters < 0) {
 		dev_err(dmc->dev, "could not get devfreq-event counters\n");
 		return dmc->num_counters;
@@ -1306,7 +1307,8 @@ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc)
 
 	for (i = 0; i < dmc->num_counters; i++) {
 		dmc->counter[i] =
-			devfreq_event_get_edev_by_phandle(dmc->dev, i);
+			devfreq_event_get_edev_by_phandle(dmc->dev,
+						"devfreq-events", i);
 		if (IS_ERR_OR_NULL(dmc->counter[i]))
 			return -EPROBE_DEFER;
 	}
include/linux/devfreq-event.h +10 -4
index f14f17f8cb7f..4a50a5c71a5f 100644
@@ -106,8 +106,11 @@ 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);
+				struct device *dev,
+				const char *phandle_name,
+				int index);
+extern int devfreq_event_get_edev_count(struct device *dev,
+				const char *phandle_name);
 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);
@@ -152,12 +155,15 @@ static inline int devfreq_event_reset_event(struct devfreq_event_dev *edev)
 }
 
 static inline struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
-					struct device *dev, int index)
+					struct device *dev,
+					const char *phandle_name,
+					int index)
 {
 	return ERR_PTR(-EINVAL);
 }
 
-static inline int devfreq_event_get_edev_count(struct device *dev)
+static inline int devfreq_event_get_edev_count(struct device *dev,
+					const char *phandle_name)
 {
 	return -EINVAL;
 }
Signature · 1 line
2.17.1
maintainer Acked-by on v3 3/3
#7 lore raw

Re: [PATCH v3 3/3] PM / devfreq: event: Change prototype of devfreq_event_get_edev_by_phandle function

Quoted 13 lines · Chanwoo Choi

Previously, devfreq core support 'devfreq-events' property in order to get the devfreq-event 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 hand over the rights to decide the property name for getting the devfreq-event device on devicetree. Each devfreq-event driver will decide the property name on devicetree binding and then pass the their own property name to devfreq_event_get_edev_by_phandle function.

And change the prototype of devfreq_event_get_edev_count function because of used deprecated 'devfreq-events' property.

Quoted 9 lines
---
 drivers/devfreq/devfreq-event.c         | 14 ++++++++------
 drivers/devfreq/exynos-bus.c            |  5 +++--
 drivers/devfreq/rk3399_dmc.c            |  2 +-
 drivers/memory/samsung/exynos5422-dmc.c |  6 ++++--
 include/linux/devfreq-event.h           | 14 ++++++++++----
 5 files changed, 26 insertions(+), 15 deletions(-)

Feel free to take it via devfreq tree. I don't expect conflicts around memory/samsung/exynos5422-dmc.c.

Best regards,
Krzysztof

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

author maintainer
#8 lore raw

Re: [PATCH v3 3/3] PM / devfreq: event: Change prototype of devfreq_event_get_edev_by_phandle function

Quoted 24 lines · Krzysztof Kozlowski
Quoted 13 lines · Chanwoo Choi

Previously, devfreq core support 'devfreq-events' property in order to get the devfreq-event 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 hand over the rights to decide the property name for getting the devfreq-event device on devicetree. Each devfreq-event driver will decide the property name on devicetree binding and then pass the their own property name to devfreq_event_get_edev_by_phandle function.

And change the prototype of devfreq_event_get_edev_count function because of used deprecated 'devfreq-events' property.

Quoted 9 lines
---
 drivers/devfreq/devfreq-event.c         | 14 ++++++++------
 drivers/devfreq/exynos-bus.c            |  5 +++--
 drivers/devfreq/rk3399_dmc.c            |  2 +-
 drivers/memory/samsung/exynos5422-dmc.c |  6 ++++--
 include/linux/devfreq-event.h           | 14 ++++++++++----
 5 files changed, 26 insertions(+), 15 deletions(-)
Quoted 5 lines

Feel free to take it via devfreq tree. I don't expect conflicts around memory/samsung/exynos5422-dmc.c.

Thanks for review. Applied them to devfreq-next.

Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics