Merge ../linux-2.6-watchdog-mm
[pandora-kernel.git] / drivers / acpi / acpi_memhotplug.c
index b0d4b14..cd946ed 100644 (file)
@@ -85,6 +85,8 @@ struct acpi_memory_device {
        struct list_head res_list;
 };
 
+static int acpi_hotmem_initialized;
+
 static acpi_status
 acpi_memory_get_resource(struct acpi_resource *resource, void *context)
 {
@@ -238,6 +240,10 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
                        num_enabled++;
                        continue;
                }
+
+               if (node < 0)
+                       node = memory_add_physaddr_to_nid(info->start_addr);
+
                result = add_memory(node, info->start_addr, info->length);
                if (result)
                        continue;
@@ -389,10 +395,9 @@ static int acpi_memory_device_add(struct acpi_device *device)
        if (!device)
                return -EINVAL;
 
-       mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL);
+       mem_device = kzalloc(sizeof(struct acpi_memory_device), GFP_KERNEL);
        if (!mem_device)
                return -ENOMEM;
-       memset(mem_device, 0, sizeof(struct acpi_memory_device));
 
        INIT_LIST_HEAD(&mem_device->res_list);
        mem_device->device = device;
@@ -410,7 +415,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
        /* Set the device state */
        mem_device->state = MEMORY_POWER_ON_STATE;
 
-       printk(KERN_INFO "%s \n", acpi_device_name(device));
+       printk(KERN_DEBUG "%s \n", acpi_device_name(device));
 
        return result;
 }
@@ -423,7 +428,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)
        if (!device || !acpi_driver_data(device))
                return -EINVAL;
 
-       mem_device = (struct acpi_memory_device *)acpi_driver_data(device);
+       mem_device = acpi_driver_data(device);
        kfree(mem_device);
 
        return 0;
@@ -434,6 +439,15 @@ static int acpi_memory_device_start (struct acpi_device *device)
        struct acpi_memory_device *mem_device;
        int result = 0;
 
+       /*
+        * Early boot code has recognized memory area by EFI/E820.
+        * If DSDT shows these memory devices on boot, hotplug is not necessary
+        * for them. So, it just returns until completion of this driver's
+        * start up.
+        */
+       if (!acpi_hotmem_initialized)
+               return 0;
+
        mem_device = acpi_driver_data(device);
 
        if (!acpi_memory_check_device(mem_device)) {
@@ -484,10 +498,8 @@ acpi_memory_register_notify_handler(acpi_handle handle,
 
 
        status = is_memory_device(handle);
-       if (ACPI_FAILURE(status)){
-               ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
+       if (ACPI_FAILURE(status))
                return AE_OK;   /* continue */
-       }
 
        status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
                                             acpi_memory_device_notify, NULL);
@@ -503,10 +515,8 @@ acpi_memory_deregister_notify_handler(acpi_handle handle,
 
 
        status = is_memory_device(handle);
-       if (ACPI_FAILURE(status)){
-               ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
+       if (ACPI_FAILURE(status))
                return AE_OK;   /* continue */
-       }
 
        status = acpi_remove_notify_handler(handle,
                                            ACPI_SYSTEM_NOTIFY,
@@ -537,6 +547,7 @@ static int __init acpi_memory_device_init(void)
                return -ENODEV;
        }
 
+       acpi_hotmem_initialized = 1;
        return 0;
 }