linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bo Yan <byan@nvidia.com>
To: viresh.kumar@linaro.org, rjw@rjwysocki.net, linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Bo Yan <byan@nvidia.com>
Subject: [PATCH] cpufreq: cpufreq_stats: make last_index signed int
Date: Fri, 15 Sep 2017 13:13:22 -0700	[thread overview]
Message-ID: <1505506402-11497-1-git-send-email-byan@nvidia.com> (raw)

It is possible for last_index to get a -1 if current frequency
is not found in the freq table when stats is created. If the
function "cpufreq_stats_update" is called before last_index is
updated with a valid value, the "-1" will be used as index to
update stats->time_in_state, triggering an exception.

Change the type of last_index of cpufreq_stats from unsigned int
to signed int.

Move last_time to location right before time_in_state. This helps
save 4 bytes in a LP64 programming model.

Signed-off-by: Bo Yan <byan@nvidia.com>
---
 drivers/cpufreq/cpufreq_stats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index e75880eb037d..a6838f5a2004 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -18,10 +18,10 @@ static DEFINE_SPINLOCK(cpufreq_stats_lock);
 
 struct cpufreq_stats {
 	unsigned int total_trans;
-	unsigned long long last_time;
 	unsigned int max_state;
 	unsigned int state_num;
-	unsigned int last_index;
+	int last_index;
+	unsigned long long last_time;
 	u64 *time_in_state;
 	unsigned int *freq_table;
 	unsigned int *trans_table;
-- 
2.7.4

             reply	other threads:[~2017-09-15 20:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-15 20:13 Bo Yan [this message]
2017-09-18  1:50 ` [PATCH] cpufreq: cpufreq_stats: make last_index signed int Viresh Kumar
2017-09-18 17:39   ` Bo Yan
2017-09-19 18:54     ` Viresh Kumar

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=1505506402-11497-1-git-send-email-byan@nvidia.com \
    --to=byan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).