[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1319538052-2480-1-git-send-email-vbyravarasu@nvidia.com>
Date: Tue, 25 Oct 2011 15:50:52 +0530
From: vbyravarasu@...dia.com
To: pavel@....cz, rjw@...k.pl, len.brown@...el.com, gregkh@...e.de
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
vbyravarasu@...dia.com
Subject: [PATCH] PM: fix calculation mistake in roll-over cases
From: venu byravarasu <vbyravarasu@...dia.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@...dia.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists