Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 230868
b: refs/heads/master
c: d8c216c
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki authored and Len Brown committed Jan 12, 2011
1 parent af1c739 commit 92735f2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 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: ddbd550d503c9cdefcd6674a0ef168d57d3f0917
refs/heads/master: d8c216cfa57e8a579f41729cbb88c97835d9ac8d
82 changes: 41 additions & 41 deletions trunk/drivers/cpuidle/cpuidle.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,45 @@ void cpuidle_resume_and_unlock(void)

EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock);

#ifdef CONFIG_ARCH_HAS_CPU_RELAX
static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st)
{
ktime_t t1, t2;
s64 diff;
int ret;

t1 = ktime_get();
local_irq_enable();
while (!need_resched())
cpu_relax();

t2 = ktime_get();
diff = ktime_to_us(ktime_sub(t2, t1));
if (diff > INT_MAX)
diff = INT_MAX;

ret = (int) diff;
return ret;
}

static void poll_idle_init(struct cpuidle_device *dev)
{
struct cpuidle_state *state = &dev->states[0];

cpuidle_set_statedata(state, NULL);

snprintf(state->name, CPUIDLE_NAME_LEN, "C0");
snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
state->exit_latency = 0;
state->target_residency = 0;
state->power_usage = -1;
state->flags = CPUIDLE_FLAG_POLL;
state->enter = poll_idle;
}
#else
static void poll_idle_init(struct cpuidle_device *dev) {}
#endif /* CONFIG_ARCH_HAS_CPU_RELAX */

/**
* cpuidle_enable_device - enables idle PM for a CPU
* @dev: the CPU
Expand All @@ -178,6 +217,8 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
return ret;
}

poll_idle_init(dev);

if ((ret = cpuidle_add_state_sysfs(dev)))
return ret;

Expand Down Expand Up @@ -232,45 +273,6 @@ void cpuidle_disable_device(struct cpuidle_device *dev)

EXPORT_SYMBOL_GPL(cpuidle_disable_device);

#ifdef CONFIG_ARCH_HAS_CPU_RELAX
static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st)
{
ktime_t t1, t2;
s64 diff;
int ret;

t1 = ktime_get();
local_irq_enable();
while (!need_resched())
cpu_relax();

t2 = ktime_get();
diff = ktime_to_us(ktime_sub(t2, t1));
if (diff > INT_MAX)
diff = INT_MAX;

ret = (int) diff;
return ret;
}

static void poll_idle_init(struct cpuidle_device *dev)
{
struct cpuidle_state *state = &dev->states[0];

cpuidle_set_statedata(state, NULL);

snprintf(state->name, CPUIDLE_NAME_LEN, "C0");
snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
state->exit_latency = 0;
state->target_residency = 0;
state->power_usage = -1;
state->flags = CPUIDLE_FLAG_POLL;
state->enter = poll_idle;
}
#else
static void poll_idle_init(struct cpuidle_device *dev) {}
#endif /* CONFIG_ARCH_HAS_CPU_RELAX */

/**
* __cpuidle_register_device - internal register function called before register
* and enable routines
Expand All @@ -291,8 +293,6 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)

init_completion(&dev->kobj_unregister);

poll_idle_init(dev);

/*
* cpuidle driver should set the dev->power_specified bit
* before registering the device if the driver provides
Expand Down

0 comments on commit 92735f2

Please sign in to comment.