mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: vbyravarasu@nvidia.com
To: pavel@ucw.cz, rjw@sisk.pl, len.brown@intel.com, gregkh@suse.de
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	vbyravarasu@nvidia.com
Subject: [PATCH] PM: fix calculation mistake in roll-over cases
Date: Tue, 25 Oct 2011 15:50:52 +0530	[thread overview]
Message-ID: <1319538052-2480-1-git-send-email-vbyravarasu@nvidia.com> (raw)

From: venu byravarasu <vbyravarasu@nvidia.com>

In case of jiffies roll over, delta is made zero.
Hence fixing it, after taking roll over into consideration.

Signed-off-by: venu byravarasu <vbyravarasu@nvidia.com>
---
When jiffies roll over, calculation of time spent in the
current state (stored in variable 'delta') is incorrect.
Hence fixing it, after taking roll over into consideration.

 drivers/base/power/runtime.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 1079e03..bd93fb0 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -30,12 +30,13 @@ static int rpm_suspend(struct device *dev, int rpmflags);
 void update_pm_runtime_accounting(struct device *dev)
 {
 	unsigned long now = jiffies;
-	int delta;
+	unsigned long delta;
+	unsigned long max_num = ~0;
 
 	delta = now - dev->power.accounting_timestamp;
 
-	if (delta < 0)
-		delta = 0;
+	if (now < dev->power.accounting_timestamp)
+		delta = max_num - dev->power.accounting_timestamp + now;
 
 	dev->power.accounting_timestamp = now;
 
-- 
1.7.1.1


             reply	other threads:[~2011-10-25 10:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-25 10:20 vbyravarasu [this message]
2011-10-25 13:08 ` Rafael J. Wysocki
2011-10-27 17:42   ` Venu Byravarasu
2011-10-27 18:30     ` Alan Stern
2011-10-28  6:34       ` Venu Byravarasu

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=1319538052-2480-1-git-send-email-vbyravarasu@nvidia.com \
    --to=vbyravarasu@nvidia.com \
    --cc=gregkh@suse.de \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@sisk.pl \
    /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

all inboxes | Powered by JetHome®