[CPUFREQ] Typo in powernow-k8
[deliverable/linux.git] / arch / i386 / kernel / cpu / cpufreq / powernow-k8.c
index e85e90524df70de1bde8bcdc02e382d9338dd858..88425bd55e1216f2450181a3186d0b971402fa62 100644 (file)
@@ -20,7 +20,7 @@
  *  of the "BIOS and Kernel Developer's Guide for the AMD Athlon 64 and AMD
  *  Opteron Processors" available for download from www.amd.com
  *
- *  Tables for specific CPUs can be infrerred from
+ *  Tables for specific CPUs can be inferred from
  *     http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/30430.pdf
  */
 
 
 #ifdef CONFIG_X86_POWERNOW_K8_ACPI
 #include <linux/acpi.h>
+#include <linux/mutex.h>
 #include <acpi/processor.h>
 #endif
 
 #define PFX "powernow-k8: "
 #define BFX PFX "BIOS error: "
-#define VERSION "version 1.60.0"
+#define VERSION "version 1.60.2"
 #include "powernow-k8.h"
 
 /* serialize freq changes  */
-static DECLARE_MUTEX(fidvid_sem);
+static DEFINE_MUTEX(fidvid_mutex);
 
 static struct powernow_k8_data *powernow_data[NR_CPUS];
 
@@ -895,7 +896,7 @@ static int transition_frequency(struct powernow_k8_data *data, unsigned int inde
        for_each_cpu_mask(i, cpu_core_map[data->cpu]) {
                freqs.cpu = i;
                cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
-        }
+       }
        return res;
 }
 
@@ -904,11 +905,16 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
 {
        cpumask_t oldmask = CPU_MASK_ALL;
        struct powernow_k8_data *data = powernow_data[pol->cpu];
-       u32 checkfid = data->currfid;
-       u32 checkvid = data->currvid;
+       u32 checkfid;
+       u32 checkvid;
        unsigned int newstate;
        int ret = -EIO;
-       int i;
+
+       if (!data)
+               return -EINVAL;
+
+       checkfid = data->currfid;
+       checkvid = data->currvid;
 
        /* only run on specific CPU from here on */
        oldmask = current->cpus_allowed;
@@ -944,23 +950,17 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
        if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate))
                goto err_out;
 
-       down(&fidvid_sem);
+       mutex_lock(&fidvid_mutex);
 
        powernow_k8_acpi_pst_values(data, newstate);
 
        if (transition_frequency(data, newstate)) {
                printk(KERN_ERR PFX "transition frequency failed\n");
                ret = 1;
-               up(&fidvid_sem);
+               mutex_unlock(&fidvid_mutex);
                goto err_out;
        }
-
-       /* Update all the fid/vids of our siblings */
-       for_each_cpu_mask(i, cpu_core_map[pol->cpu]) {
-               powernow_data[i]->currvid = data->currvid;
-               powernow_data[i]->currfid = data->currfid;
-       }       
-       up(&fidvid_sem);
+       mutex_unlock(&fidvid_mutex);
 
        pol->cur = find_khz_freq_from_fid(data->currfid);
        ret = 0;
@@ -975,6 +975,9 @@ static int powernowk8_verify(struct cpufreq_policy *pol)
 {
        struct powernow_k8_data *data = powernow_data[pol->cpu];
 
+       if (!data)
+               return -EINVAL;
+
        return cpufreq_frequency_table_verify(pol, data->powernow_table);
 }
 
@@ -983,7 +986,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
 {
        struct powernow_k8_data *data;
        cpumask_t oldmask = CPU_MASK_ALL;
-       int rc, i;
+       int rc;
 
        if (!cpu_online(pol->cpu))
                return -ENODEV;
@@ -1069,9 +1072,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
        printk("cpu_init done, current fid 0x%x, vid 0x%x\n",
               data->currfid, data->currvid);
 
-       for_each_cpu_mask(i, cpu_core_map[pol->cpu]) {
-               powernow_data[i] = data;
-       }
+       powernow_data[pol->cpu] = data;
 
        return 0;
 
@@ -1102,10 +1103,15 @@ static int __devexit powernowk8_cpu_exit (struct cpufreq_policy *pol)
 
 static unsigned int powernowk8_get (unsigned int cpu)
 {
-       struct powernow_k8_data *data = powernow_data[cpu];
+       struct powernow_k8_data *data;
        cpumask_t oldmask = current->cpus_allowed;
        unsigned int khz = 0;
 
+       data = powernow_data[first_cpu(cpu_core_map[cpu])];
+
+       if (!data)
+               return -EINVAL;
+
        set_cpus_allowed(current, cpumask_of_cpu(cpu));
        if (smp_processor_id() != cpu) {
                printk(KERN_ERR PFX "limiting to CPU %d failed in powernowk8_get\n", cpu);
@@ -1144,16 +1150,14 @@ static int __cpuinit powernowk8_init(void)
 {
        unsigned int i, supported_cpus = 0;
 
-       for (i=0; i<NR_CPUS; i++) {
-               if (!cpu_online(i))
-                       continue;
+       for_each_online_cpu(i) {
                if (check_supported_cpu(i))
                        supported_cpus++;
        }
 
        if (supported_cpus == num_online_cpus()) {
-               printk(KERN_INFO PFX "Found %d AMD Athlon 64 / Opteron processors (" VERSION ")\n",
-                       supported_cpus);
+               printk(KERN_INFO PFX "Found %d AMD Athlon 64 / Opteron "
+                       "processors (" VERSION ")\n", supported_cpus);
                return cpufreq_register_driver(&cpufreq_amd64_driver);
        }
 
This page took 0.032558 seconds and 5 git commands to generate.