mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] PM: fix calculation mistake in roll-over cases
@ 2011-10-25 10:20 vbyravarasu
  2011-10-25 13:08 ` Rafael J. Wysocki
  0 siblings, 1 reply; 5+ messages in thread
From: vbyravarasu @ 2011-10-25 10:20 UTC (permalink / raw)
  To: pavel, rjw, len.brown, gregkh; +Cc: linux-pm, linux-kernel, vbyravarasu

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-28  6:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-25 10:20 [PATCH] PM: fix calculation mistake in roll-over cases vbyravarasu
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

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®