ACPI: don't pass handle for fixed hardware notifications
[sfrench/cifs-2.6.git] / drivers / acpi / scan.c
index 0ab526de7c55757b35c70fc9404724ca32967358..408ebde18986d95d47ac6dbbe33e23d1fb58e349 100644 (file)
@@ -309,6 +309,10 @@ static void acpi_device_release(struct device *dev)
        struct acpi_device *acpi_dev = to_acpi_device(dev);
 
        kfree(acpi_dev->pnp.cid_list);
+       if (acpi_dev->flags.hardware_id)
+               kfree(acpi_dev->pnp.hardware_id);
+       if (acpi_dev->flags.unique_id)
+               kfree(acpi_dev->pnp.unique_id);
        kfree(acpi_dev);
 }
 
@@ -366,7 +370,8 @@ static acpi_status acpi_device_notify_fixed(void *data)
 {
        struct acpi_device *device = data;
 
-       acpi_device_notify(device->handle, ACPI_FIXED_HARDWARE_EVENT, device);
+       /* Fixed hardware devices have no handles */
+       acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
        return AE_OK;
 }
 
@@ -426,9 +431,6 @@ static int acpi_device_probe(struct device * dev)
                if (acpi_drv->ops.notify) {
                        ret = acpi_device_install_notify_handler(acpi_dev);
                        if (ret) {
-                               if (acpi_drv->ops.stop)
-                                       acpi_drv->ops.stop(acpi_dev,
-                                                  acpi_dev->removal_type);
                                if (acpi_drv->ops.remove)
                                        acpi_drv->ops.remove(acpi_dev,
                                                     acpi_dev->removal_type);
@@ -452,8 +454,6 @@ static int acpi_device_remove(struct device * dev)
        if (acpi_drv) {
                if (acpi_drv->ops.notify)
                        acpi_device_remove_notify_handler(acpi_dev);
-               if (acpi_drv->ops.stop)
-                       acpi_drv->ops.stop(acpi_dev, acpi_dev->removal_type);
                if (acpi_drv->ops.remove)
                        acpi_drv->ops.remove(acpi_dev, acpi_dev->removal_type);
        }
@@ -687,7 +687,7 @@ acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
 }
 EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
 
-void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
+void acpi_bus_data_handler(acpi_handle handle, void *context)
 {
 
        /* TBD */
@@ -781,6 +781,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
        kfree(buffer.pointer);
 
        device->wakeup.flags.valid = 1;
+       device->wakeup.prepare_count = 0;
        /* Call _PSW/_DSW object to disable its ability to wake the sleeping
         * system for the ACPI device with the _PRW object.
         * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
@@ -1137,8 +1138,9 @@ static void acpi_device_set_id(struct acpi_device *device,
                        strcpy(device->pnp.hardware_id, hid);
                        device->flags.hardware_id = 1;
                }
-       } else
-               device->pnp.hardware_id = NULL;
+       }
+       if (!device->flags.hardware_id)
+               device->pnp.hardware_id = "";
 
        if (uid) {
                device->pnp.unique_id = ACPI_ALLOCATE_ZEROED(strlen (uid) + 1);
@@ -1146,8 +1148,9 @@ static void acpi_device_set_id(struct acpi_device *device,
                        strcpy(device->pnp.unique_id, uid);
                        device->flags.unique_id = 1;
                }
-       } else
-               device->pnp.unique_id = NULL;
+       }
+       if (!device->flags.unique_id)
+               device->pnp.unique_id = "";
 
        if (cid_list || cid_add) {
                struct acpica_device_id_list *list;
@@ -1308,16 +1311,6 @@ acpi_add_single_object(struct acpi_device **child,
         */
        acpi_device_set_id(device, parent, handle, type);
 
-       /*
-        * The ACPI device is attached to acpi handle before getting
-        * the power/wakeup/peformance flags. Otherwise OS can't get
-        * the corresponding ACPI device by the acpi handle in the course
-        * of getting the power/wakeup/performance flags.
-        */
-       result = acpi_device_set_context(device, type);
-       if (result)
-               goto end;
-
        /*
         * Power Management
         * ----------------
@@ -1348,6 +1341,8 @@ acpi_add_single_object(struct acpi_device **child,
                        goto end;
        }
 
+       if ((result = acpi_device_set_context(device, type)))
+               goto end;
 
        result = acpi_device_register(device, parent);
 
@@ -1362,10 +1357,8 @@ acpi_add_single_object(struct acpi_device **child,
 end:
        if (!result)
                *child = device;
-       else {
-               kfree(device->pnp.cid_list);
-               kfree(device);
-       }
+       else
+               acpi_device_release(&device->dev);
 
        return result;
 }