Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 212367
b: refs/heads/master
c: 4769373
h: refs/heads/master
i:
  212365: 67c0640
  212363: d782848
  212359: a3d7414
  212351: 522d3db
v: v3
  • Loading branch information
Alan Stern authored and Rafael J. Wysocki committed Oct 16, 2010
1 parent 9c59b17 commit 03deb7c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 69d44ffbd772bede8c2a6d182e6e14f94826520b
refs/heads/master: 4769373ca2c8d0b999749a070c48fd8648888831
77 changes: 38 additions & 39 deletions trunk/drivers/base/power/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,44 @@ static int __pm_runtime_resume(struct device *dev, bool from_wq);
static int __pm_request_idle(struct device *dev);
static int __pm_request_resume(struct device *dev);

/**
* update_pm_runtime_accounting - Update the time accounting of power states
* @dev: Device to update the accounting for
*
* In order to be able to have time accounting of the various power states
* (as used by programs such as PowerTOP to show the effectiveness of runtime
* PM), we need to track the time spent in each state.
* update_pm_runtime_accounting must be called each time before the
* runtime_status field is updated, to account the time in the old state
* correctly.
*/
void update_pm_runtime_accounting(struct device *dev)
{
unsigned long now = jiffies;
int delta;

delta = now - dev->power.accounting_timestamp;

if (delta < 0)
delta = 0;

dev->power.accounting_timestamp = now;

if (dev->power.disable_depth > 0)
return;

if (dev->power.runtime_status == RPM_SUSPENDED)
dev->power.suspended_jiffies += delta;
else
dev->power.active_jiffies += delta;
}

static void __update_runtime_status(struct device *dev, enum rpm_status status)
{
update_pm_runtime_accounting(dev);
dev->power.runtime_status = status;
}

/**
* pm_runtime_deactivate_timer - Deactivate given device's suspend timer.
* @dev: Device to handle.
Expand Down Expand Up @@ -123,45 +161,6 @@ int pm_runtime_idle(struct device *dev)
}
EXPORT_SYMBOL_GPL(pm_runtime_idle);


/**
* update_pm_runtime_accounting - Update the time accounting of power states
* @dev: Device to update the accounting for
*
* In order to be able to have time accounting of the various power states
* (as used by programs such as PowerTOP to show the effectiveness of runtime
* PM), we need to track the time spent in each state.
* update_pm_runtime_accounting must be called each time before the
* runtime_status field is updated, to account the time in the old state
* correctly.
*/
void update_pm_runtime_accounting(struct device *dev)
{
unsigned long now = jiffies;
int delta;

delta = now - dev->power.accounting_timestamp;

if (delta < 0)
delta = 0;

dev->power.accounting_timestamp = now;

if (dev->power.disable_depth > 0)
return;

if (dev->power.runtime_status == RPM_SUSPENDED)
dev->power.suspended_jiffies += delta;
else
dev->power.active_jiffies += delta;
}

static void __update_runtime_status(struct device *dev, enum rpm_status status)
{
update_pm_runtime_accounting(dev);
dev->power.runtime_status = status;
}

/**
* __pm_runtime_suspend - Carry out run-time suspend of given device.
* @dev: Device to suspend.
Expand Down

0 comments on commit 03deb7c

Please sign in to comment.