Skip to content

Commit 11a3b0a

Browse files
cniedermaiervireshk
authored andcommitted
cpufreq: imx6q: don't warn for disabling a non-existing frequency
It is confusing if a warning is given for disabling a non-existent frequency of the operating performance points (OPP). In this case the function dev_pm_opp_disable() returns -ENODEV. Check the return value and avoid the output of a warning in this case. Avoid code duplication by using a separate function. Signed-off-by: Christoph Niedermaier <cniedermaier@dh-electronics.com> [ Viresh : Updated commit subject ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent dcfce7c commit 11a3b0a

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

drivers/cpufreq/imx6q-cpufreq.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ static struct cpufreq_driver imx6q_cpufreq_driver = {
209209
.suspend = cpufreq_generic_suspend,
210210
};
211211

212+
static void imx6x_disable_freq_in_opp(struct device *dev, unsigned long freq)
213+
{
214+
int ret = dev_pm_opp_disable(dev, freq);
215+
216+
if (ret < 0 && ret != -ENODEV)
217+
dev_warn(dev, "failed to disable %ldMHz OPP\n", freq / 1000000);
218+
}
219+
212220
#define OCOTP_CFG3 0x440
213221
#define OCOTP_CFG3_SPEED_SHIFT 16
214222
#define OCOTP_CFG3_SPEED_1P2GHZ 0x3
@@ -254,17 +262,15 @@ static int imx6q_opp_check_speed_grading(struct device *dev)
254262
val &= 0x3;
255263

256264
if (val < OCOTP_CFG3_SPEED_996MHZ)
257-
if (dev_pm_opp_disable(dev, 996000000))
258-
dev_warn(dev, "failed to disable 996MHz OPP\n");
265+
imx6x_disable_freq_in_opp(dev, 996000000);
259266

260267
if (of_machine_is_compatible("fsl,imx6q") ||
261268
of_machine_is_compatible("fsl,imx6qp")) {
262269
if (val != OCOTP_CFG3_SPEED_852MHZ)
263-
if (dev_pm_opp_disable(dev, 852000000))
264-
dev_warn(dev, "failed to disable 852MHz OPP\n");
270+
imx6x_disable_freq_in_opp(dev, 852000000);
271+
265272
if (val != OCOTP_CFG3_SPEED_1P2GHZ)
266-
if (dev_pm_opp_disable(dev, 1200000000))
267-
dev_warn(dev, "failed to disable 1.2GHz OPP\n");
273+
imx6x_disable_freq_in_opp(dev, 1200000000);
268274
}
269275

270276
return 0;
@@ -316,20 +322,16 @@ static int imx6ul_opp_check_speed_grading(struct device *dev)
316322
val >>= OCOTP_CFG3_SPEED_SHIFT;
317323
val &= 0x3;
318324

319-
if (of_machine_is_compatible("fsl,imx6ul")) {
325+
if (of_machine_is_compatible("fsl,imx6ul"))
320326
if (val != OCOTP_CFG3_6UL_SPEED_696MHZ)
321-
if (dev_pm_opp_disable(dev, 696000000))
322-
dev_warn(dev, "failed to disable 696MHz OPP\n");
323-
}
327+
imx6x_disable_freq_in_opp(dev, 696000000);
324328

325329
if (of_machine_is_compatible("fsl,imx6ull")) {
326330
if (val != OCOTP_CFG3_6ULL_SPEED_792MHZ)
327-
if (dev_pm_opp_disable(dev, 792000000))
328-
dev_warn(dev, "failed to disable 792MHz OPP\n");
331+
imx6x_disable_freq_in_opp(dev, 792000000);
329332

330333
if (val != OCOTP_CFG3_6ULL_SPEED_900MHZ)
331-
if (dev_pm_opp_disable(dev, 900000000))
332-
dev_warn(dev, "failed to disable 900MHz OPP\n");
334+
imx6x_disable_freq_in_opp(dev, 900000000);
333335
}
334336

335337
return ret;

0 commit comments

Comments
 (0)