[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210103035639.24076-1-tiny.windzz@gmail.com>
Date: Sun, 3 Jan 2021 03:56:39 +0000
From: Yangtao Li <tiny.windzz@...il.com>
To: myungjoo.ham@...sung.com, kyungmin.park@...sung.com,
cw00.choi@...sung.com, krzk@...nel.org, shawnguo@...nel.org,
s.hauer@...gutronix.de, kernel@...gutronix.de, festevam@...il.com,
linux-imx@....com, digetx@...il.com, thierry.reding@...il.com,
jonathanh@...dia.com, yuq825@...il.com, airlied@...ux.ie,
daniel@...ll.ch, robdclark@...il.com, sean@...rly.run,
robh@...nel.org, tomeu.vizoso@...labora.com, steven.price@....com,
alyssa.rosenzweig@...labora.com, stanimir.varbanov@...aro.org,
agross@...nel.org, bjorn.andersson@...aro.org, mchehab@...nel.org,
lukasz.luba@....com, adrian.hunter@...el.com,
ulf.hansson@...aro.org, vireshk@...nel.org, nm@...com,
sboyd@...nel.org, broonie@...nel.org, gregkh@...uxfoundation.org,
jirislaby@...nel.org, rjw@...ysocki.net, jcrouse@...eaurora.org,
hoegsberg@...gle.com, eric@...olt.net, tzimmermann@...e.de,
marijn.suijten@...ainline.org, gustavoars@...nel.org,
emil.velikov@...labora.com, jonathan@...ek.ca,
akhilpo@...eaurora.org, smasetty@...eaurora.org,
airlied@...hat.com, masneyb@...tation.org, kalyan_t@...eaurora.org,
tanmay@...eaurora.org, tiny.windzz@...il.com,
ddavenport@...omium.org, jsanka@...eaurora.org,
rnayak@...eaurora.org, tongtiangen@...wei.com,
miaoqinglang@...wei.com, khsieh@...eaurora.org,
abhinavk@...eaurora.org, chandanu@...eaurora.org,
groeck@...omium.org, varar@...eaurora.org, mka@...omium.org,
harigovi@...eaurora.org, rikard.falkeborn@...il.com,
natechancellor@...il.com, georgi.djakov@...aro.org,
akashast@...eaurora.org, parashar@...eaurora.org,
dianders@...omium.org
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-samsung-soc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-tegra@...r.kernel.org,
dri-devel@...ts.freedesktop.org, lima@...ts.freedesktop.org,
linux-arm-msm@...r.kernel.org, freedreno@...ts.freedesktop.org,
linux-media@...r.kernel.org, linux-mmc@...r.kernel.org,
linux-spi@...r.kernel.org, linux-serial@...r.kernel.org
Subject: [PATCH 30/31] PM / devfreq: exynos: convert to use devm_pm_opp_* API
Use devm_pm_opp_* API to simplify code, and remove opp_table
from exynos_bus.
Signed-off-by: Yangtao Li <tiny.windzz@...il.com>
---
drivers/devfreq/exynos-bus.c | 42 ++++++++----------------------------
1 file changed, 9 insertions(+), 33 deletions(-)
diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index e689101abc93..51752e5ce980 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -33,7 +33,6 @@ struct exynos_bus {
unsigned long curr_freq;
- struct opp_table *opp_table;
struct clk *clk;
unsigned int ratio;
};
@@ -159,10 +158,7 @@ static void exynos_bus_exit(struct device *dev)
platform_device_unregister(bus->icc_pdev);
- dev_pm_opp_of_remove_table(dev);
clk_disable_unprepare(bus->clk);
- dev_pm_opp_put_regulators(bus->opp_table);
- bus->opp_table = NULL;
}
static void exynos_bus_passive_exit(struct device *dev)
@@ -171,7 +167,6 @@ static void exynos_bus_passive_exit(struct device *dev)
platform_device_unregister(bus->icc_pdev);
- dev_pm_opp_of_remove_table(dev);
clk_disable_unprepare(bus->clk);
}
@@ -183,15 +178,13 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
const char *vdd = "vdd";
int i, ret, count, size;
- opp_table = dev_pm_opp_set_regulators(dev, &vdd, 1);
+ opp_table = devm_pm_opp_set_regulators(dev, &vdd, 1);
if (IS_ERR(opp_table)) {
ret = PTR_ERR(opp_table);
dev_err(dev, "failed to set regulators %d\n", ret);
return ret;
}
- bus->opp_table = opp_table;
-
/*
* Get the devfreq-event devices to get the current utilization of
* buses. This raw data will be used in devfreq ondemand governor.
@@ -199,25 +192,20 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
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;
- goto err_regulator;
+ return count;
}
bus->edev_count = count;
size = sizeof(*bus->edev) * count;
bus->edev = devm_kzalloc(dev, size, GFP_KERNEL);
- if (!bus->edev) {
- ret = -ENOMEM;
- goto err_regulator;
- }
+ if (!bus->edev)
+ return -ENOMEM;
for (i = 0; i < count; 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;
- }
+ if (IS_ERR(bus->edev[i]))
+ return -EPROBE_DEFER;
}
/*
@@ -234,12 +222,6 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
bus->ratio = DEFAULT_SATURATION_RATIO;
return 0;
-
-err_regulator:
- dev_pm_opp_put_regulators(bus->opp_table);
- bus->opp_table = NULL;
-
- return ret;
}
static int exynos_bus_parse_of(struct device_node *np,
@@ -264,7 +246,7 @@ static int exynos_bus_parse_of(struct device_node *np,
}
/* Get the freq and voltage from OPP table to scale the bus freq */
- ret = dev_pm_opp_of_add_table(dev);
+ ret = devm_pm_opp_of_add_table(dev);
if (ret < 0) {
dev_err(dev, "failed to get OPP table\n");
goto err_clk;
@@ -276,15 +258,13 @@ static int exynos_bus_parse_of(struct device_node *np,
if (IS_ERR(opp)) {
dev_err(dev, "failed to find dev_pm_opp\n");
ret = PTR_ERR(opp);
- goto err_opp;
+ goto err_clk;
}
bus->curr_freq = dev_pm_opp_get_freq(opp);
dev_pm_opp_put(opp);
return 0;
-err_opp:
- dev_pm_opp_of_remove_table(dev);
err_clk:
clk_disable_unprepare(bus->clk);
@@ -425,7 +405,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
/* Parse the device-tree to get the resource information */
ret = exynos_bus_parse_of(np, bus);
if (ret < 0)
- goto err_reg;
+ return ret;
if (passive)
ret = exynos_bus_profile_init_passive(bus, profile);
@@ -456,11 +436,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
return 0;
err:
- dev_pm_opp_of_remove_table(dev);
clk_disable_unprepare(bus->clk);
-err_reg:
- dev_pm_opp_put_regulators(bus->opp_table);
- bus->opp_table = NULL;
return ret;
}
--
2.25.1
Powered by blists - more mailing lists