Skip to content

Commit 864a270

Browse files
TinyWindzzvireshk
authored andcommitted
drm/lima: Convert to use resource-managed OPP API
Use resource-managed OPP API to simplify code. Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 411281d commit 864a270

2 files changed

Lines changed: 11 additions & 39 deletions

File tree

drivers/gpu/drm/lima/lima_devfreq.c

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,12 @@ void lima_devfreq_fini(struct lima_device *ldev)
9999
devm_devfreq_remove_device(ldev->dev, devfreq->devfreq);
100100
devfreq->devfreq = NULL;
101101
}
102-
103-
dev_pm_opp_of_remove_table(ldev->dev);
104-
105-
dev_pm_opp_put_regulators(devfreq->regulators_opp_table);
106-
dev_pm_opp_put_clkname(devfreq->clkname_opp_table);
107-
devfreq->regulators_opp_table = NULL;
108-
devfreq->clkname_opp_table = NULL;
109102
}
110103

111104
int lima_devfreq_init(struct lima_device *ldev)
112105
{
113106
struct thermal_cooling_device *cooling;
114107
struct device *dev = ldev->dev;
115-
struct opp_table *opp_table;
116108
struct devfreq *devfreq;
117109
struct lima_devfreq *ldevfreq = &ldev->devfreq;
118110
struct dev_pm_opp *opp;
@@ -125,40 +117,28 @@ int lima_devfreq_init(struct lima_device *ldev)
125117

126118
spin_lock_init(&ldevfreq->lock);
127119

128-
opp_table = dev_pm_opp_set_clkname(dev, "core");
129-
if (IS_ERR(opp_table)) {
130-
ret = PTR_ERR(opp_table);
131-
goto err_fini;
132-
}
133-
134-
ldevfreq->clkname_opp_table = opp_table;
135-
136-
opp_table = dev_pm_opp_set_regulators(dev,
137-
(const char *[]){ "mali" },
138-
1);
139-
if (IS_ERR(opp_table)) {
140-
ret = PTR_ERR(opp_table);
120+
ret = devm_pm_opp_set_clkname(dev, "core");
121+
if (ret)
122+
return ret;
141123

124+
ret = devm_pm_opp_set_regulators(dev, (const char *[]){ "mali" }, 1);
125+
if (ret) {
142126
/* Continue if the optional regulator is missing */
143127
if (ret != -ENODEV)
144-
goto err_fini;
145-
} else {
146-
ldevfreq->regulators_opp_table = opp_table;
128+
return ret;
147129
}
148130

149-
ret = dev_pm_opp_of_add_table(dev);
131+
ret = devm_pm_opp_of_add_table(dev);
150132
if (ret)
151-
goto err_fini;
133+
return ret;
152134

153135
lima_devfreq_reset(ldevfreq);
154136

155137
cur_freq = clk_get_rate(ldev->clk_gpu);
156138

157139
opp = devfreq_recommended_opp(dev, &cur_freq, 0);
158-
if (IS_ERR(opp)) {
159-
ret = PTR_ERR(opp);
160-
goto err_fini;
161-
}
140+
if (IS_ERR(opp))
141+
return PTR_ERR(opp);
162142

163143
lima_devfreq_profile.initial_freq = cur_freq;
164144
dev_pm_opp_put(opp);
@@ -167,8 +147,7 @@ int lima_devfreq_init(struct lima_device *ldev)
167147
DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
168148
if (IS_ERR(devfreq)) {
169149
dev_err(dev, "Couldn't initialize GPU devfreq\n");
170-
ret = PTR_ERR(devfreq);
171-
goto err_fini;
150+
return PTR_ERR(devfreq);
172151
}
173152

174153
ldevfreq->devfreq = devfreq;
@@ -180,10 +159,6 @@ int lima_devfreq_init(struct lima_device *ldev)
180159
ldevfreq->cooling = cooling;
181160

182161
return 0;
183-
184-
err_fini:
185-
lima_devfreq_fini(ldev);
186-
return ret;
187162
}
188163

189164
void lima_devfreq_record_busy(struct lima_devfreq *devfreq)

drivers/gpu/drm/lima/lima_devfreq.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88
#include <linux/ktime.h>
99

1010
struct devfreq;
11-
struct opp_table;
1211
struct thermal_cooling_device;
1312

1413
struct lima_device;
1514

1615
struct lima_devfreq {
1716
struct devfreq *devfreq;
18-
struct opp_table *clkname_opp_table;
19-
struct opp_table *regulators_opp_table;
2017
struct thermal_cooling_device *cooling;
2118

2219
ktime_t busy_time;

0 commit comments

Comments
 (0)