ACPI: Remove useless type argument of driver .remove() operation
[linux-2.6-block.git] / drivers / acpi / scan.c
index 1ee62bd25828a6613a9d7067d9ea18395b7a1b6c..0989b323e65fb5b5fd32ee9388977bd49d15a8eb 100644 (file)
@@ -116,20 +116,14 @@ static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
 void acpi_bus_hot_remove_device(void *context)
 {
        struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context;
-       struct acpi_device *device;
-       acpi_handle handle = ej_event->handle;
+       struct acpi_device *device = ej_event->device;
+       acpi_handle handle = device->handle;
        acpi_handle temp;
        struct acpi_object_list arg_list;
        union acpi_object arg;
        acpi_status status = AE_OK;
        u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
 
-       if (acpi_bus_get_device(handle, &device))
-               goto err_out;
-
-       if (!device)
-               goto err_out;
-
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                "Hot-removing device %s...\n", dev_name(&device->dev)));
 
@@ -215,7 +209,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
                goto err;
        }
 
-       ej_event->handle = acpi_device->handle;
+       ej_event->device = acpi_device;
        if (acpi_device->flags.eject_pending) {
                /* event originated from ACPI eject notification */
                ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
@@ -223,7 +217,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
        } else {
                /* event originated from user */
                ej_event->event = ACPI_OST_EC_OSPM_EJECT;
-               (void) acpi_evaluate_hotplug_ost(ej_event->handle,
+               (void) acpi_evaluate_hotplug_ost(acpi_device->handle,
                        ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
        }
 
@@ -583,8 +577,7 @@ static int acpi_device_probe(struct device * dev)
                        ret = acpi_device_install_notify_handler(acpi_dev);
                        if (ret) {
                                if (acpi_drv->ops.remove)
-                                       acpi_drv->ops.remove(acpi_dev,
-                                                    acpi_dev->removal_type);
+                                       acpi_drv->ops.remove(acpi_dev);
                                return ret;
                        }
                }
@@ -606,7 +599,7 @@ static int acpi_device_remove(struct device * dev)
                if (acpi_drv->ops.notify)
                        acpi_device_remove_notify_handler(acpi_dev);
                if (acpi_drv->ops.remove)
-                       acpi_drv->ops.remove(acpi_dev, acpi_dev->removal_type);
+                       acpi_drv->ops.remove(acpi_dev);
        }
        acpi_dev->driver = NULL;
        acpi_dev->driver_data = NULL;
@@ -1325,7 +1318,7 @@ static void acpi_device_set_id(struct acpi_device *device)
                        acpi_add_id(device, ACPI_DOCK_HID);
                else if (!acpi_ibm_smbus_match(device))
                        acpi_add_id(device, ACPI_SMBUS_IBM_HID);
-               else if (!acpi_device_hid(device) &&
+               else if (list_empty(&device->pnp.ids) &&
                         ACPI_IS_ROOT_DEVICE(device->parent)) {
                        acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
                        strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
@@ -1374,22 +1367,6 @@ static int acpi_device_set_context(struct acpi_device *device)
        return -ENODEV;
 }
 
-static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
-                                  void *not_used, void **ret_not_used)
-{
-       struct acpi_device *dev = NULL;
-
-       if (acpi_bus_get_device(handle, &dev))
-               return AE_OK;
-
-       dev->removal_type = ACPI_BUS_REMOVAL_EJECT;
-       device_release_driver(&dev->dev);
-
-       acpi_device_unregister(dev);
-
-       return AE_OK;
-}
-
 static int acpi_add_single_object(struct acpi_device **child,
                                  acpi_handle handle, int type,
                                  unsigned long long sta, bool match_driver)
@@ -1599,7 +1576,19 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
        return status;
 }
 
-static int acpi_bus_scan(acpi_handle handle)
+/**
+ * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
+ * @handle: Root of the namespace scope to scan.
+ *
+ * Scan a given ACPI tree (probably recently hot-plugged) and create and add
+ * found devices.
+ *
+ * If no devices were found, -ENODEV is returned, but it does not mean that
+ * there has been a real error.  There just have been no suitable ACPI objects
+ * in the table trunk from which the kernel could create a device and add an
+ * appropriate driver.
+ */
+int acpi_bus_scan(acpi_handle handle)
 {
        void *device = NULL;
 
@@ -1616,34 +1605,40 @@ static int acpi_bus_scan(acpi_handle handle)
 
        return 0;
 }
+EXPORT_SYMBOL(acpi_bus_scan);
 
-/**
- * acpi_bus_add - Add ACPI device node objects in a given namespace scope.
- * @handle: Root of the namespace scope to scan.
- *
- * Scan a given ACPI tree (probably recently hot-plugged) and create and add
- * found devices.
- *
- * If no devices were found, -ENODEV is returned, but it does not mean that
- * there has been a real error.  There just have been no suitable ACPI objects
- * in the table trunk from which the kernel could create a device and add an
- * appropriate driver.
- */
-int acpi_bus_add(acpi_handle handle)
+static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
+                                         void *not_used, void **ret_not_used)
 {
-       int err;
+       struct acpi_device *device = NULL;
 
-       err = acpi_bus_scan(handle);
-       if (err)
-               return err;
+       if (!acpi_bus_get_device(handle, &device)) {
+               device->removal_type = ACPI_BUS_REMOVAL_EJECT;
+               device_release_driver(&device->dev);
+       }
+       return AE_OK;
+}
 
-       acpi_update_all_gpes();
-       return 0;
+static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
+                                  void *not_used, void **ret_not_used)
+{
+       struct acpi_device *device = NULL;
+
+       if (!acpi_bus_get_device(handle, &device))
+               acpi_device_unregister(device);
+
+       return AE_OK;
 }
-EXPORT_SYMBOL(acpi_bus_add);
 
 int acpi_bus_trim(struct acpi_device *start)
 {
+       /*
+        * Execute acpi_bus_device_detach() as a post-order callback to detach
+        * all ACPI drivers from the device nodes being removed.
+        */
+       acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
+                           acpi_bus_device_detach, NULL, NULL);
+       acpi_bus_device_detach(start->handle, 0, NULL, NULL);
        /*
         * Execute acpi_bus_remove() as a post-order callback to remove device
         * nodes in the given namespace scope.
@@ -1700,13 +1695,15 @@ int __init acpi_scan_init(void)
                return result;
 
        result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
-       if (!result)
-               result = acpi_bus_scan_fixed();
-
        if (result)
+               return result;
+
+       result = acpi_bus_scan_fixed();
+       if (result) {
                acpi_device_unregister(acpi_root);
-       else
-               acpi_update_all_gpes();
+               return result;
+       }
 
-       return result;
+       acpi_update_all_gpes();
+       return 0;
 }