Merge branches 'acpi-dptf' and 'acpi-messages'
[linux-2.6-microblaze.git] / drivers / acpi / processor_throttling.c
index e61b8f0..a822fe4 100644 (file)
@@ -6,9 +6,11 @@
  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  *  Copyright (C) 2004       Dominik Brodowski <linux@brodo.de>
  *  Copyright (C) 2004  Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
- *                     - Added processor hotplug support
+ *                      - Added processor hotplug support
  */
 
+#define pr_fmt(fmt) "ACPI: " fmt
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -20,8 +22,6 @@
 #include <asm/io.h>
 #include <linux/uaccess.h>
 
-#define PREFIX "ACPI: "
-
 /* ignore_tpc:
  *  0 -> acpi processor driver doesn't ignore _TPC values
  *  1 -> acpi processor driver ignores _TPC values
@@ -195,15 +195,13 @@ void acpi_processor_throttling_init(void)
 {
        if (acpi_processor_update_tsd_coord())
                pr_debug("Assume no T-state coordination\n");
-
-       return;
 }
 
 static int acpi_processor_throttling_notifier(unsigned long event, void *data)
 {
        struct throttling_tstate *p_tstate = data;
        struct acpi_processor *pr;
-       unsigned int cpu ;
+       unsigned int cpu;
        int target_state;
        struct acpi_processor_limit *p_limit;
        struct acpi_processor_throttling *p_throttling;
@@ -236,8 +234,7 @@ static int acpi_processor_throttling_notifier(unsigned long event, void *data)
                if (pr->throttling_platform_limit > target_state)
                        target_state = pr->throttling_platform_limit;
                if (target_state >= p_throttling->state_count) {
-                       printk(KERN_WARNING
-                               "Exceed the limit of T-state \n");
+                       pr_warn("Exceed the limit of T-state \n");
                        target_state = p_throttling->state_count - 1;
                }
                p_tstate->target_state = target_state;
@@ -256,8 +253,7 @@ static int acpi_processor_throttling_notifier(unsigned long event, void *data)
                                  cpu, target_state);
                break;
        default:
-               printk(KERN_WARNING
-                       "Unsupported Throttling notifier event\n");
+               pr_warn("Unsupported Throttling notifier event\n");
                break;
        }
 
@@ -408,7 +404,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
        acpi_status status = 0;
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        union acpi_object *ptc = NULL;
-       union acpi_object obj = { 0 };
+       union acpi_object obj;
        struct acpi_processor_throttling *throttling;
 
        status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
@@ -422,7 +418,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
        ptc = (union acpi_object *)buffer.pointer;
        if (!ptc || (ptc->type != ACPI_TYPE_PACKAGE)
            || (ptc->package.count != 2)) {
-               printk(KERN_ERR PREFIX "Invalid _PTC data\n");
+               pr_err("Invalid _PTC data\n");
                result = -EFAULT;
                goto end;
        }
@@ -436,8 +432,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
        if ((obj.type != ACPI_TYPE_BUFFER)
            || (obj.buffer.length < sizeof(struct acpi_ptc_register))
            || (obj.buffer.pointer == NULL)) {
-               printk(KERN_ERR PREFIX
-                      "Invalid _PTC data (control_register)\n");
+               pr_err("Invalid _PTC data (control_register)\n");
                result = -EFAULT;
                goto end;
        }
@@ -453,7 +448,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
        if ((obj.type != ACPI_TYPE_BUFFER)
            || (obj.buffer.length < sizeof(struct acpi_ptc_register))
            || (obj.buffer.pointer == NULL)) {
-               printk(KERN_ERR PREFIX "Invalid _PTC data (status_register)\n");
+               pr_err("Invalid _PTC data (status_register)\n");
                result = -EFAULT;
                goto end;
        }
@@ -465,19 +460,19 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
 
        if ((throttling->control_register.bit_width +
                throttling->control_register.bit_offset) > 32) {
-               printk(KERN_ERR PREFIX "Invalid _PTC control register\n");
+               pr_err("Invalid _PTC control register\n");
                result = -EFAULT;
                goto end;
        }
 
        if ((throttling->status_register.bit_width +
                throttling->status_register.bit_offset) > 32) {
-               printk(KERN_ERR PREFIX "Invalid _PTC status register\n");
+               pr_err("Invalid _PTC status register\n");
                result = -EFAULT;
                goto end;
        }
 
-      end:
+end:
        kfree(buffer.pointer);
 
        return result;
@@ -506,7 +501,7 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 
        tss = buffer.pointer;
        if (!tss || (tss->type != ACPI_TYPE_PACKAGE)) {
-               printk(KERN_ERR PREFIX "Invalid _TSS data\n");
+               pr_err("Invalid _TSS data\n");
                result = -EFAULT;
                goto end;
        }
@@ -546,15 +541,14 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
                }
 
                if (!tx->freqpercentage) {
-                       printk(KERN_ERR PREFIX
-                              "Invalid _TSS data: freq is zero\n");
+                       pr_err("Invalid _TSS data: freq is zero\n");
                        result = -EFAULT;
                        kfree(pr->throttling.states_tss);
                        goto end;
                }
        }
 
-      end:
+end:
        kfree(buffer.pointer);
 
        return result;
@@ -587,13 +581,13 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
 
        tsd = buffer.pointer;
        if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) {
-               printk(KERN_ERR PREFIX "Invalid _TSD data\n");
+               pr_err("Invalid _TSD data\n");
                result = -EFAULT;
                goto end;
        }
 
        if (tsd->package.count != 1) {
-               printk(KERN_ERR PREFIX "Invalid _TSD data\n");
+               pr_err("Invalid _TSD data\n");
                result = -EFAULT;
                goto end;
        }
@@ -606,19 +600,19 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
        status = acpi_extract_package(&(tsd->package.elements[0]),
                                      &format, &state);
        if (ACPI_FAILURE(status)) {
-               printk(KERN_ERR PREFIX "Invalid _TSD data\n");
+               pr_err("Invalid _TSD data\n");
                result = -EFAULT;
                goto end;
        }
 
        if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) {
-               printk(KERN_ERR PREFIX "Unknown _TSD:num_entries\n");
+               pr_err("Unknown _TSD:num_entries\n");
                result = -EFAULT;
                goto end;
        }
 
        if (pdomain->revision != ACPI_TSD_REV0_REVISION) {
-               printk(KERN_ERR PREFIX "Unknown _TSD:revision\n");
+               pr_err("Unknown _TSD:revision\n");
                result = -EFAULT;
                goto end;
        }
@@ -639,7 +633,7 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
                pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL;
        }
 
-      end:
+end:
        kfree(buffer.pointer);
        return result;
 }
@@ -711,13 +705,12 @@ static int acpi_throttling_rdmsr(u64 *value)
 
        if ((this_cpu_read(cpu_info.x86_vendor) != X86_VENDOR_INTEL) ||
                !this_cpu_has(X86_FEATURE_ACPI)) {
-               printk(KERN_ERR PREFIX
-                       "HARDWARE addr space,NOT supported yet\n");
+               pr_err("HARDWARE addr space,NOT supported yet\n");
        } else {
                msr_low = 0;
                msr_high = 0;
                rdmsr_safe(MSR_IA32_THERM_CONTROL,
-                       (u32 *)&msr_low , (u32 *) &msr_high);
+                       (u32 *)&msr_low, (u32 *) &msr_high);
                msr = (msr_high << 32) | msr_low;
                *value = (u64) msr;
                ret = 0;
@@ -732,8 +725,7 @@ static int acpi_throttling_wrmsr(u64 value)
 
        if ((this_cpu_read(cpu_info.x86_vendor) != X86_VENDOR_INTEL) ||
                !this_cpu_has(X86_FEATURE_ACPI)) {
-               printk(KERN_ERR PREFIX
-                       "HARDWARE addr space,NOT supported yet\n");
+               pr_err("HARDWARE addr space,NOT supported yet\n");
        } else {
                msr = value;
                wrmsr_safe(MSR_IA32_THERM_CONTROL,
@@ -745,15 +737,13 @@ static int acpi_throttling_wrmsr(u64 value)
 #else
 static int acpi_throttling_rdmsr(u64 *value)
 {
-       printk(KERN_ERR PREFIX
-               "HARDWARE addr space,NOT supported yet\n");
+       pr_err("HARDWARE addr space,NOT supported yet\n");
        return -1;
 }
 
 static int acpi_throttling_wrmsr(u64 value)
 {
-       printk(KERN_ERR PREFIX
-               "HARDWARE addr space,NOT supported yet\n");
+       pr_err("HARDWARE addr space,NOT supported yet\n");
        return -1;
 }
 #endif
@@ -784,7 +774,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
                ret = acpi_throttling_rdmsr(value);
                break;
        default:
-               printk(KERN_ERR PREFIX "Unknown addr space %d\n",
+               pr_err("Unknown addr space %d\n",
                       (u32) (throttling->status_register.space_id));
        }
        return ret;
@@ -817,7 +807,7 @@ static int acpi_write_throttling_state(struct acpi_processor *pr,
                ret = acpi_throttling_wrmsr(value);
                break;
        default:
-               printk(KERN_ERR PREFIX "Unknown addr space %d\n",
+               pr_err("Unknown addr space %d\n",
                       (u32) (throttling->control_register.space_id));
        }
        return ret;
@@ -926,7 +916,7 @@ static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
        }
        /* TBD: Support duty_cycle values that span bit 4. */
        else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
-               printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
+               pr_warn("duty_cycle spans bit 4\n");
                return -EINVAL;
        }
 
@@ -1185,8 +1175,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
         */
        if (acpi_processor_get_throttling_control(pr) ||
                acpi_processor_get_throttling_states(pr) ||
-               acpi_processor_get_platform_limit(pr))
-       {
+               acpi_processor_get_platform_limit(pr)) {
                pr->throttling.acpi_processor_get_throttling =
                    &acpi_processor_get_throttling_fadt;
                pr->throttling.acpi_processor_set_throttling =
@@ -1246,7 +1235,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
                        goto end;
        }
 
-      end:
+end:
        if (result)
                pr->flags.throttling = 0;