md: set and test the ->persistent flag for md devices more consistently
[safe/jmp/linux-2.6] / drivers / acpi / pci_bind.c
index d833274..388300d 100644 (file)
@@ -36,7 +36,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT             ACPI_PCI_COMPONENT
-ACPI_MODULE_NAME("pci_bind")
+ACPI_MODULE_NAME("pci_bind");
 
 struct acpi_pci_data {
        struct acpi_pci_id id;
@@ -122,19 +122,17 @@ int acpi_pci_bind(struct acpi_device *device)
        if (!device || !device->parent)
                return -EINVAL;
 
-       pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
+       pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
        if (!pathname)
                return -ENOMEM;
-       memset(pathname, 0, ACPI_PATHNAME_MAX);
        buffer.length = ACPI_PATHNAME_MAX;
        buffer.pointer = pathname;
 
-       data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
+       data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
        if (!data) {
                kfree(pathname);
                return -ENOMEM;
        }
-       memset(data, 0, sizeof(struct acpi_pci_data));
 
        acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
@@ -223,6 +221,8 @@ int acpi_pci_bind(struct acpi_device *device)
                                  data->id.segment, data->id.bus,
                                  data->id.device, data->id.function));
                data->bus = data->dev->subordinate;
+               device->ops.bind = acpi_pci_bind;
+               device->ops.unbind = acpi_pci_unbind;
        }
 
        /*
@@ -279,10 +279,9 @@ int acpi_pci_unbind(struct acpi_device *device)
        if (!device || !device->parent)
                return -EINVAL;
 
-       pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
+       pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
        if (!pathname)
                return -ENOMEM;
-       memset(pathname, 0, ACPI_PATHNAME_MAX);
 
        buffer.length = ACPI_PATHNAME_MAX;
        buffer.pointer = pathname;
@@ -295,9 +294,6 @@ int acpi_pci_unbind(struct acpi_device *device)
            acpi_get_data(device->handle, acpi_pci_data_handler,
                          (void **)&data);
        if (ACPI_FAILURE(status)) {
-               ACPI_EXCEPTION((AE_INFO, status,
-                               "Unable to get data from device %s",
-                               acpi_device_bid(device)));
                result = -ENODEV;
                goto end;
        }
@@ -329,11 +325,9 @@ acpi_pci_bind_root(struct acpi_device *device,
        char *pathname = NULL;
        struct acpi_buffer buffer = { 0, NULL };
 
-
-       pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
+       pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
        if (!pathname)
                return -ENOMEM;
-       memset(pathname, 0, ACPI_PATHNAME_MAX);
 
        buffer.length = ACPI_PATHNAME_MAX;
        buffer.pointer = pathname;
@@ -343,15 +337,16 @@ acpi_pci_bind_root(struct acpi_device *device,
                return -EINVAL;
        }
 
-       data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
+       data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
        if (!data) {
                kfree(pathname);
                return -ENOMEM;
        }
-       memset(data, 0, sizeof(struct acpi_pci_data));
 
        data->id = *id;
        data->bus = bus;
+       device->ops.bind = acpi_pci_bind;
+       device->ops.unbind = acpi_pci_unbind;
 
        acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
 
@@ -374,55 +369,3 @@ acpi_pci_bind_root(struct acpi_device *device,
 
        return result;
 }
-
-#define ACPI_PCI_BRIDGE_DRIVER_NAME "ACPI PCI Bridge Driver"
-
-static int acpi_pci_bridge_add(struct acpi_device *device);
-static int acpi_pci_bridge_remove(struct acpi_device *device, int type);
-static int acpi_pci_bridge_match(struct acpi_device *device,
-       struct acpi_driver *driver);
-static struct acpi_driver acpi_pci_bridge_driver = {
-       .name = ACPI_PCI_BRIDGE_DRIVER_NAME,
-       .ops = {
-               .add = acpi_pci_bridge_add,
-               .remove = acpi_pci_bridge_remove,
-               .match = acpi_pci_bridge_match,
-       },
-};
-
-static int acpi_pci_bridge_match(struct acpi_device *device,
-       struct acpi_driver *driver)
-{
-       acpi_status status;
-       acpi_handle handle;
-
-       /* pci bridge has _PRT but isn't PNP0A03 */
-       status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
-       if (ACPI_FAILURE(status))
-               return -ENODEV;
-       if (!acpi_match_ids(device, "PNP0A03"))
-               return -ENODEV;
-       return 0;
-}
-
-static int acpi_pci_bridge_add(struct acpi_device *device)
-{
-       return acpi_pci_bind(device);
-}
-
-static int acpi_pci_bridge_remove(struct acpi_device *device, int type)
-{
-       return acpi_pci_unbind(device);
-}
-
-static int __init acpi_pci_bridge_init(void)
-{
-       if (acpi_pci_disabled)
-               return 0;
-       if (acpi_bus_register_driver(&acpi_pci_bridge_driver) < 0)
-               return -ENODEV;
-       return 0;
-}
-
-/* Should be called after ACPI pci root driver */
-subsys_initcall(acpi_pci_bridge_init);