lkml.org 
[lkml]   [2019]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 2/3] devfreq: add clearing transitions stats
Date
Add clearing transition table and time in states devfreq statistics
by writing to trans_stat file in devfreq sysfs.

Signed-off-by: Kamil Konieczny <k.konieczny@samsung.com>
---
Changes in v2:
instead of creating new sysfs file, add new functionality to trans_stat
and clear stats when anything is writen to it

drivers/devfreq/devfreq.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 0e2030403e4a..901af3b66a76 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -1478,7 +1478,27 @@ 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);
+ unsigned int cnt = df->profile->max_state;
+
+ if (cnt == 0)
+ return count;
+
+ mutex_lock(&df->lock);
+ memset(df->time_in_state, 0, cnt * sizeof(u64));
+ memset(df->trans_table, 0, cnt * cnt * sizeof(int));
+ df->last_stat_updated = get_jiffies_64();
+ df->total_trans = 0;
+ mutex_unlock(&df->lock);
+
+ return count;
+}
+static DEVICE_ATTR_RW(trans_stat);

static struct attribute *devfreq_attrs[] = {
&dev_attr_name.attr,
--
2.24.0
\
 
 \ /
  Last update: 2019-12-04 16:00    [W:0.073 / U:0.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site