summaryrefslogtreecommitdiff
path: root/drivers/devfreq
diff options
context:
space:
mode:
authorKamil Konieczny <k.konieczny@samsung.com>2019-12-05 17:55:26 +0300
committerChanwoo Choi <cw00.choi@samsung.com>2019-12-30 03:59:05 +0300
commit14a34396819960865ff737c665c6e46b64d0e04a (patch)
treef262a702ebb8e6311d99011c2e0fb4717711672a /drivers/devfreq
parentb76b3479dab948bea0a98b6d263eb56d8f358528 (diff)
downloadlinux-14a34396819960865ff737c665c6e46b64d0e04a.tar.xz
PM / devfreq: Add clearing transitions stats
Add clearing transition table and time in states devfreq statistics by writing 0 (zero) to trans_stat file in devfreq sysfs. An example use is like following: echo 0 > /sys/class/devfreq/devfreqX/trans_stat Signed-off-by: Kamil Konieczny <k.konieczny@samsung.com> [cw00.choi: Edit return value if entering the wrong value for reset and use arrary3_size() to get the size of 3-dimensional array] Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/devfreq')
-rw-r--r--drivers/devfreq/devfreq.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 554d155106a5..af5bd521a734 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -1597,7 +1597,34 @@ static ssize_t trans_stat_show(struct device *dev,
devfreq->total_trans);
return len;
}
-static DEVICE_ATTR_RO(trans_stat);
+
+static ssize_t trans_stat_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct devfreq *df = to_devfreq(dev);
+ int err, value;
+
+ if (df->profile->max_state == 0)
+ return count;
+
+ err = kstrtoint(buf, 10, &value);
+ if (err || value != 0)
+ return -EINVAL;
+
+ mutex_lock(&df->lock);
+ memset(df->time_in_state, 0, (df->profile->max_state *
+ sizeof(*df->time_in_state)));
+ memset(df->trans_table, 0, array3_size(sizeof(unsigned int),
+ df->profile->max_state,
+ df->profile->max_state));
+ df->total_trans = 0;
+ df->last_stat_updated = get_jiffies_64();
+ mutex_unlock(&df->lock);
+
+ return count;
+}
+static DEVICE_ATTR_RW(trans_stat);
static struct attribute *devfreq_attrs[] = {
&dev_attr_name.attr,