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

From: Chanwoo Choi
Date: Thu Dec 19 2019 - 19:18:56 EST


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

Reviewed-by: Lukasz Luba <lukasz.luba@xxxxxxx>
Signed-off-by: Chanwoo Choi <cw00.choi@xxxxxxxxxxx>
---
drivers/memory/samsung/exynos5422-dmc.c | 29 ++++++++++++++++++++-----
1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/memory/samsung/exynos5422-dmc.c b/drivers/memory/samsung/exynos5422-dmc.c
index f11fe29a69fc..6e8aa19e84d3 100644
--- a/drivers/memory/samsung/exynos5422-dmc.c
+++ b/drivers/memory/samsung/exynos5422-dmc.c
@@ -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;
--
2.17.1