[CPUFREQ] CPU frequency display in /proc/cpuinfo
[powerpc.git] / drivers / cpufreq / cpufreq.c
index 25acf47..a9163d0 100644 (file)
@@ -38,7 +38,6 @@ static struct cpufreq_driver          *cpufreq_driver;
 static struct cpufreq_policy   *cpufreq_cpu_data[NR_CPUS];
 static DEFINE_SPINLOCK(cpufreq_driver_lock);
 
-
 /* internal prototypes */
 static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event);
 static void handle_update(void *data);
@@ -694,8 +693,8 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
        unsigned int cpu = sys_dev->id;
        unsigned long flags;
        struct cpufreq_policy *data;
-       struct sys_device *cpu_sys_dev;
 #ifdef CONFIG_SMP
+       struct sys_device *cpu_sys_dev;
        unsigned int j;
 #endif
 
@@ -823,6 +822,30 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne
 }
 
 
+/** 
+ * cpufreq_quick_get - get the CPU frequency (in kHz) frpm policy->cur
+ * @cpu: CPU number
+ *
+ * This is the last known freq, without actually getting it from the driver.
+ * Return value will be same as what is shown in scaling_cur_freq in sysfs.
+ */
+unsigned int cpufreq_quick_get(unsigned int cpu)
+{
+       struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
+       unsigned int ret = 0;
+
+       if (policy) {
+               down(&policy->lock);
+               ret = policy->cur;
+               up(&policy->lock);
+               cpufreq_cpu_put(policy);
+       }
+
+       return (ret);
+}
+EXPORT_SYMBOL(cpufreq_quick_get);
+
+
 /** 
  * cpufreq_get - get the current CPU frequency (in kHz)
  * @cpu: CPU number
@@ -1114,25 +1137,14 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
 {
        int retval = -EINVAL;
 
-       /*
-        * Converted the lock_cpu_hotplug to preempt_disable()
-        * and preempt_enable(). This is a bit kludgy and relies on how cpu
-        * hotplug works. All we need is a guarantee that cpu hotplug won't make
-        * progress on any cpu. Once we do preempt_disable(), this would ensure
-        * that hotplug threads don't get onto this cpu, thereby delaying
-        * the cpu remove process.
-        *
-        * We removed the lock_cpu_hotplug since we need to call this function
-        * via cpu hotplug callbacks, which result in locking the cpu hotplug
-        * thread itself. Agree this is not very clean, cpufreq community
-        * could improve this if required. - Ashok Raj <ashok.raj@intel.com>
-        */
-       preempt_disable();
+       lock_cpu_hotplug();
        dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu,
                target_freq, relation);
        if (cpu_online(policy->cpu) && cpufreq_driver->target)
                retval = cpufreq_driver->target(policy, target_freq, relation);
-       preempt_enable();
+
+       unlock_cpu_hotplug();
+
        return retval;
 }
 EXPORT_SYMBOL_GPL(__cpufreq_driver_target);