]> err.no Git - linux-2.6/blobdiff - drivers/acpi/processor_perflib.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/pci-2.6
[linux-2.6] / drivers / acpi / processor_perflib.c
index cf6167003d8a2e99deceef417fd604c4572e5e03..41aaaba74b194e1169748afa5d18fd10060dce3a 100644 (file)
@@ -34,6 +34,7 @@
 #ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/mutex.h>
 
 #include <asm/uaccess.h>
 #endif
@@ -48,7 +49,7 @@
 #define _COMPONENT             ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("acpi_processor")
 
-static DECLARE_MUTEX(performance_sem);
+static DEFINE_MUTEX(performance_mutex);
 
 /*
  * _PPC support is implemented as a CPUfreq policy notifier:
@@ -72,7 +73,7 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
        struct acpi_processor *pr;
        unsigned int ppc = 0;
 
-       down(&performance_sem);
+       mutex_lock(&performance_mutex);
 
        if (event != CPUFREQ_INCOMPATIBLE)
                goto out;
@@ -93,7 +94,7 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
                                     core_frequency * 1000);
 
       out:
-       up(&performance_sem);
+       mutex_unlock(&performance_mutex);
 
        return 0;
 }
@@ -623,7 +624,7 @@ int acpi_processor_preregister_performance(
        struct acpi_processor *match_pr;
        struct acpi_psd_package *match_pdomain;
 
-       down(&performance_sem);
+       mutex_lock(&performance_mutex);
 
        retval = 0;
 
@@ -771,7 +772,7 @@ err_ret:
                pr->performance = NULL; /* Will be set for real in register */
        }
 
-       up(&performance_sem);
+       mutex_unlock(&performance_mutex);
        return retval;
 }
 EXPORT_SYMBOL(acpi_processor_preregister_performance);
@@ -788,30 +789,32 @@ acpi_processor_register_performance(struct acpi_processor_performance
        if (!(acpi_processor_ppc_status & PPC_REGISTERED))
                return_VALUE(-EINVAL);
 
-       down(&performance_sem);
+       mutex_lock(&performance_mutex);
 
        pr = processors[cpu];
        if (!pr) {
-               up(&performance_sem);
+               mutex_unlock(&performance_mutex);
                return_VALUE(-ENODEV);
        }
 
        if (pr->performance) {
-               up(&performance_sem);
+               mutex_unlock(&performance_mutex);
                return_VALUE(-EBUSY);
        }
 
+       WARN_ON(!performance);
+
        pr->performance = performance;
 
        if (acpi_processor_get_performance_info(pr)) {
                pr->performance = NULL;
-               up(&performance_sem);
+               mutex_unlock(&performance_mutex);
                return_VALUE(-EIO);
        }
 
        acpi_cpufreq_add_file(pr);
 
-       up(&performance_sem);
+       mutex_unlock(&performance_mutex);
        return_VALUE(0);
 }
 
@@ -825,20 +828,21 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
 
        ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance");
 
-       down(&performance_sem);
+       mutex_lock(&performance_mutex);
 
        pr = processors[cpu];
        if (!pr) {
-               up(&performance_sem);
+               mutex_unlock(&performance_mutex);
                return_VOID;
        }
 
-       kfree(pr->performance->states);
+       if (pr->performance)
+               kfree(pr->performance->states);
        pr->performance = NULL;
 
        acpi_cpufreq_remove_file(pr);
 
-       up(&performance_sem);
+       mutex_unlock(&performance_mutex);
 
        return_VOID;
 }