summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2013-06-12 15:08:54 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-15 02:09:47 +0200
commit5df0aa7341bd94ca2023a60c64c63faeb6ec209d (patch)
treea4e6acbd29f402899f80cef9cba2d21ca6b44a78
parentf6bb51a53a7535c79d6c65862d6b48e83340b337 (diff)
downloadblackbird-op-linux-5df0aa7341bd94ca2023a60c64c63faeb6ec209d.tar.gz
blackbird-op-linux-5df0aa7341bd94ca2023a60c64c63faeb6ec209d.zip
cpuidle: Introduce __cpuidle_device_init()
Add __cpuidle_device_init() for initializing the cpuidle_device structure. [rjw: Changelog] Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/cpuidle/cpuidle.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index d78c6d89272f..5b63185da59b 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -276,7 +276,7 @@ static void poll_idle_init(struct cpuidle_driver *drv) {}
*/
int cpuidle_enable_device(struct cpuidle_device *dev)
{
- int ret, i;
+ int ret;
struct cpuidle_driver *drv;
if (!dev)
@@ -306,12 +306,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
(ret = cpuidle_curr_governor->enable(drv, dev)))
goto fail_sysfs;
- for (i = 0; i < dev->state_count; i++) {
- dev->states_usage[i].usage = 0;
- dev->states_usage[i].time = 0;
- }
- dev->last_residency = 0;
-
smp_wmb();
dev->enabled = 1;
@@ -364,6 +358,14 @@ static void __cpuidle_unregister_device(struct cpuidle_device *dev)
module_put(drv->owner);
}
+static int __cpuidle_device_init(struct cpuidle_device *dev)
+{
+ memset(dev->states_usage, 0, sizeof(dev->states_usage));
+ dev->last_residency = 0;
+
+ return 0;
+}
+
/**
* __cpuidle_register_device - internal register function called before register
* and enable routines
@@ -405,6 +407,10 @@ int cpuidle_register_device(struct cpuidle_device *dev)
mutex_lock(&cpuidle_lock);
+ ret = __cpuidle_device_init(dev);
+ if (ret)
+ goto out_unlock;
+
ret = __cpuidle_register_device(dev);
if (ret)
goto out_unlock;
OpenPOWER on IntegriCloud