]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/cpuidle/cpuidle.c
smp_call_function: get rid of the unused nonatomic/retry argument
[linux-2.6-omap-h63xx.git] / drivers / cpuidle / cpuidle.c
index d73663a52324b89b93a7eb68f2fe0df9d21fbe26..5405769020a1c13aa727e9a70e4e2dad99d1aef8 100644 (file)
@@ -38,6 +38,8 @@ static void cpuidle_kick_cpus(void)
 static void cpuidle_kick_cpus(void) {}
 #endif
 
+static int __cpuidle_register_device(struct cpuidle_device *dev);
+
 /**
  * cpuidle_idle_call - the main idle loop
  *
@@ -67,7 +69,7 @@ static void cpuidle_idle_call(void)
        /* enter the state and update stats */
        dev->last_residency = target_state->enter(dev, target_state);
        dev->last_state = target_state;
-       target_state->time += dev->last_residency;
+       target_state->time += (unsigned long long)dev->last_residency;
        target_state->usage++;
 
        /* give the governor an opportunity to reflect on the outcome */
@@ -138,6 +140,12 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
        if (!dev->state_count)
                return -EINVAL;
 
+       if (dev->registered == 0) {
+               ret = __cpuidle_register_device(dev);
+               if (ret)
+                       return ret;
+       }
+
        if ((ret = cpuidle_add_state_sysfs(dev)))
                return ret;
 
@@ -224,7 +232,7 @@ static void poll_idle_init(struct cpuidle_device *dev)
        state->exit_latency = 0;
        state->target_residency = 0;
        state->power_usage = -1;
-       state->flags = CPUIDLE_FLAG_POLL | CPUIDLE_FLAG_TIME_VALID;
+       state->flags = CPUIDLE_FLAG_POLL;
        state->enter = poll_idle;
 }
 #else
@@ -232,10 +240,13 @@ static void poll_idle_init(struct cpuidle_device *dev) {}
 #endif /* CONFIG_ARCH_HAS_CPU_RELAX */
 
 /**
- * cpuidle_register_device - registers a CPU's idle PM feature
+ * __cpuidle_register_device - internal register function called before register
+ * and enable routines
  * @dev: the cpu
+ *
+ * cpuidle_lock mutex must be held before this is called
  */
-int cpuidle_register_device(struct cpuidle_device *dev)
+static int __cpuidle_register_device(struct cpuidle_device *dev)
 {
        int ret;
        struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
@@ -247,18 +258,34 @@ int cpuidle_register_device(struct cpuidle_device *dev)
 
        init_completion(&dev->kobj_unregister);
 
-       mutex_lock(&cpuidle_lock);
-
        poll_idle_init(dev);
 
        per_cpu(cpuidle_devices, dev->cpu) = dev;
        list_add(&dev->device_list, &cpuidle_detected_devices);
        if ((ret = cpuidle_add_sysfs(sys_dev))) {
-               mutex_unlock(&cpuidle_lock);
                module_put(cpuidle_curr_driver->owner);
                return ret;
        }
 
+       dev->registered = 1;
+       return 0;
+}
+
+/**
+ * cpuidle_register_device - registers a CPU's idle PM feature
+ * @dev: the cpu
+ */
+int cpuidle_register_device(struct cpuidle_device *dev)
+{
+       int ret;
+
+       mutex_lock(&cpuidle_lock);
+
+       if ((ret = __cpuidle_register_device(dev))) {
+               mutex_unlock(&cpuidle_lock);
+               return ret;
+       }
+
        cpuidle_enable_device(dev);
        cpuidle_install_idle_handler();
 
@@ -278,6 +305,9 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
 {
        struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
 
+       if (dev->registered == 0)
+               return;
+
        cpuidle_pause_and_lock();
 
        cpuidle_disable_device(dev);
@@ -310,7 +340,7 @@ static void smp_callback(void *v)
 static int cpuidle_latency_notify(struct notifier_block *b,
                unsigned long l, void *v)
 {
-       smp_call_function(smp_callback, NULL, 0, 1);
+       smp_call_function(smp_callback, NULL, 1);
        return NOTIFY_OK;
 }