Merge branch 'topic/core-cleanup' into for-linus
[safe/jmp/linux-2.6] / drivers / acpi / bus.c
index 65f7e33..743576b 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/device.h>
 #include <linux/proc_fs.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #ifdef CONFIG_X86
 #include <asm/mpspec.h>
 #endif
@@ -190,16 +191,16 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
                 * Get the device's power state either directly (via _PSC) or
                 * indirectly (via power resources).
                 */
-               if (device->power.flags.explicit_get) {
+               if (device->power.flags.power_resources) {
+                       result = acpi_power_get_inferred_state(device);
+                       if (result)
+                               return result;
+               } else if (device->power.flags.explicit_get) {
                        status = acpi_evaluate_integer(device->handle, "_PSC",
                                                       NULL, &psc);
                        if (ACPI_FAILURE(status))
                                return -ENODEV;
                        device->power.state = (int)psc;
-               } else if (device->power.flags.power_resources) {
-                       result = acpi_power_get_inferred_state(device);
-                       if (result)
-                               return result;
                }
 
                *state = device->power.state;
@@ -397,6 +398,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
        union acpi_object *out_obj;
        u8 uuid[16];
        u32 errors;
+       struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
 
        if (!context)
                return AE_ERROR;
@@ -419,16 +421,16 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
        in_params[3].buffer.length      = context->cap.length;
        in_params[3].buffer.pointer     = context->cap.pointer;
 
-       status = acpi_evaluate_object(handle, "_OSC", &input, &context->ret);
+       status = acpi_evaluate_object(handle, "_OSC", &input, &output);
        if (ACPI_FAILURE(status))
                return status;
 
-       /* return buffer should have the same length as cap buffer */
-       if (context->ret.length != context->cap.length)
+       if (!output.length)
                return AE_NULL_OBJECT;
 
-       out_obj = context->ret.pointer;
-       if (out_obj->type != ACPI_TYPE_BUFFER) {
+       out_obj = output.pointer;
+       if (out_obj->type != ACPI_TYPE_BUFFER
+               || out_obj->buffer.length != context->cap.length) {
                acpi_print_osc_error(handle, context,
                        "_OSC evaluation returned wrong type");
                status = AE_TYPE;
@@ -457,11 +459,20 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
                goto out_kfree;
        }
 out_success:
-       return AE_OK;
+       context->ret.length = out_obj->buffer.length;
+       context->ret.pointer = kmalloc(context->ret.length, GFP_KERNEL);
+       if (!context->ret.pointer) {
+               status =  AE_NO_MEMORY;
+               goto out_kfree;
+       }
+       memcpy(context->ret.pointer, out_obj->buffer.pointer,
+               context->ret.length);
+       status =  AE_OK;
 
 out_kfree:
-       kfree(context->ret.pointer);
-       context->ret.pointer = NULL;
+       kfree(output.pointer);
+       if (status != AE_OK)
+               context->ret.pointer = NULL;
        return status;
 }
 EXPORT_SYMBOL(acpi_run_osc);
@@ -480,9 +491,14 @@ static void acpi_bus_osc_support(void)
 
        capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
        capbuf[OSC_SUPPORT_TYPE] = OSC_SB_PR3_SUPPORT; /* _PR3 is in use */
-#ifdef CONFIG_ACPI_PROCESSOR_AGGREGATOR
+#if defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) ||\
+                       defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
        capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PAD_SUPPORT;
 #endif
+
+#if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE)
+       capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PPC_OST_SUPPORT;
+#endif
        if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
                return;
        if (ACPI_SUCCESS(acpi_run_osc(handle, &context)))
@@ -511,7 +527,7 @@ int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id,
        if (!event_is_open)
                return 0;
 
-       event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
+       event = kzalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
        if (!event)
                return -ENOMEM;
 
@@ -888,6 +904,8 @@ static int __init acpi_bus_init(void)
                goto error1;
        }
 
+       acpi_early_processor_set_pdc();
+
        /*
         * Maybe EC region is required at bus_scan/acpi_get_devices. So it
         * is necessary to enable it as early as possible.