Merge master.kernel.org:/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[pandora-kernel.git] / drivers / acpi / acpi_memhotplug.c
index 98099de..c261726 100644 (file)
 #define ACPI_MEMORY_DEVICE_COMPONENT           0x08000000UL
 #define ACPI_MEMORY_DEVICE_CLASS               "memory"
 #define ACPI_MEMORY_DEVICE_HID                 "PNP0C80"
-#define ACPI_MEMORY_DEVICE_DRIVER_NAME         "Hotplug Mem Driver"
 #define ACPI_MEMORY_DEVICE_NAME                        "Hotplug Mem Device"
 
 #define _COMPONENT             ACPI_MEMORY_DEVICE_COMPONENT
 
-ACPI_MODULE_NAME("acpi_memory")
-    MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>");
-MODULE_DESCRIPTION(ACPI_MEMORY_DEVICE_DRIVER_NAME);
+ACPI_MODULE_NAME("acpi_memhotplug");
+MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>");
+MODULE_DESCRIPTION("Hotplug Mem Driver");
 MODULE_LICENSE("GPL");
 
 /* ACPI _STA method values */
@@ -60,7 +59,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type);
 static int acpi_memory_device_start(struct acpi_device *device);
 
 static struct acpi_driver acpi_memory_device_driver = {
-       .name = ACPI_MEMORY_DEVICE_DRIVER_NAME,
+       .name = "acpi_memhotplug",
        .class = ACPI_MEMORY_DEVICE_CLASS,
        .ids = ACPI_MEMORY_DEVICE_HID,
        .ops = {
@@ -85,6 +84,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)
 {
@@ -393,10 +394,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;
@@ -414,7 +414,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;
 }
@@ -427,7 +427,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;
@@ -438,6 +438,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)) {
@@ -537,6 +546,7 @@ static int __init acpi_memory_device_init(void)
                return -ENODEV;
        }
 
+       acpi_hotmem_initialized = 1;
        return 0;
 }