From: Lukasz Luba <lukasz.luba@arm.com>
To: linux-pm@vger.kernel.org
Cc: cw00.choi@samsung.com, kyungmin.park@samsung.com,
myungjoo.ham@samsung.com, Lukasz Luba <lukasz.luba@arm.com>
Subject: [PATCH] devfreq: do not ignore errors during store min, max frequency
Date: Thu, 27 Apr 2017 09:23:47 +0100 [thread overview]
Message-ID: <1493281427-8671-1-git-send-email-lukasz.luba@arm.com> (raw)
This patch adds functionality to make sure when a call to set a new
max or min frequency is possible.
If storing the new value was not possible, restore previous one
and forward the error value.
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
It is based on v4.11-rc8.
drivers/devfreq/devfreq.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index dea0487..8586035 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -1059,6 +1059,7 @@ static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr,
unsigned long value;
int ret;
unsigned long max;
+ unsigned long old_min;
ret = sscanf(buf, "%lu", &value);
if (ret != 1)
@@ -1071,9 +1072,22 @@ static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr,
goto unlock;
}
+ ret = devfreq_get_freq_level(df, value);
+ if (ret < 0) {
+ dev_warn(dev, "Storing min freq failed with (%d) error\n", ret);
+ goto unlock;
+ }
+
+ old_min = df->min_freq;
df->min_freq = value;
- update_devfreq(df);
- ret = count;
+ ret = update_devfreq(df);
+ if (ret) {
+ df->min_freq = old_min;
+ dev_warn(dev, "Storing min freq failed with (%d) error\n", ret);
+ } else {
+ ret = count;
+ }
+
unlock:
mutex_unlock(&df->lock);
return ret;
@@ -1086,6 +1100,7 @@ static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
unsigned long value;
int ret;
unsigned long min;
+ unsigned long old_max;
ret = sscanf(buf, "%lu", &value);
if (ret != 1)
@@ -1098,9 +1113,22 @@ static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
goto unlock;
}
+ ret = devfreq_get_freq_level(df, value);
+ if (ret < 0) {
+ dev_warn(dev, "Storing max freq failed with (%d) error\n", ret);
+ goto unlock;
+ }
+
+ old_max = df->max_freq;
df->max_freq = value;
- update_devfreq(df);
- ret = count;
+ ret = update_devfreq(df);
+ if (ret) {
+ df->max_freq = old_max;
+ dev_warn(dev, "Storing max freq failed with (%d) error\n", ret);
+ } else {
+ ret = count;
+ }
+
unlock:
mutex_unlock(&df->lock);
return ret;
--
1.9.1
next reply other threads:[~2017-04-27 8:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170427082416epcas3p3b9aeb23978707b164b4d4a46156d1216@epcms1p5>
2017-04-27 8:23 ` Lukasz Luba [this message]
2017-04-27 8:30 ` [PATCH] devfreq: do not ignore errors during store min, max frequency MyungJoo Ham
2017-04-27 11:04 ` Lukasz Luba
2017-04-27 23:41 ` MyungJoo Ham
2017-05-03 9:24 ` Lukasz Luba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1493281427-8671-1-git-send-email-lukasz.luba@arm.com \
--to=lukasz.luba@arm.com \
--cc=cw00.choi@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox