Pull acpi_bus_register_driver into release branch
[pandora-kernel.git] / drivers / acpi / scan.c
index 31218e1..fc676ac 100644 (file)
@@ -23,7 +23,6 @@ static LIST_HEAD(acpi_device_list);
 DEFINE_SPINLOCK(acpi_device_lock);
 LIST_HEAD(acpi_wakeup_device_list);
 
-static int acpi_bus_trim(struct acpi_device *start, int rmdevice);
 
 static void acpi_device_release(struct kobject *kobj)
 {
@@ -78,7 +77,7 @@ static struct kobj_type ktype_acpi_ns = {
        .release = acpi_device_release,
 };
 
-static int namespace_hotplug(struct kset *kset, struct kobject *kobj,
+static int namespace_uevent(struct kset *kset, struct kobject *kobj,
                             char **envp, int num_envp, char *buffer,
                             int buffer_size)
 {
@@ -89,8 +88,8 @@ static int namespace_hotplug(struct kset *kset, struct kobject *kobj,
        if (!dev->driver)
                return 0;
 
-       if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len,
-                               "PHYSDEVDRIVER=%s", dev->driver->name))
+       if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
+                          "PHYSDEVDRIVER=%s", dev->driver->name))
                return -ENOMEM;
 
        envp[i] = NULL;
@@ -98,8 +97,8 @@ static int namespace_hotplug(struct kset *kset, struct kobject *kobj,
        return 0;
 }
 
-static struct kset_hotplug_ops namespace_hotplug_ops = {
-       .hotplug = &namespace_hotplug,
+static struct kset_uevent_ops namespace_uevent_ops = {
+       .uevent = &namespace_uevent,
 };
 
 static struct kset acpi_namespace_kset = {
@@ -108,7 +107,7 @@ static struct kset acpi_namespace_kset = {
                 },
        .subsys = &acpi_subsys,
        .ktype = &ktype_acpi_ns,
-       .hotplug_ops = &namespace_hotplug_ops,
+       .uevent_ops = &namespace_uevent_ops,
 };
 
 static void acpi_device_register(struct acpi_device *device,
@@ -143,7 +142,7 @@ static void acpi_device_register(struct acpi_device *device,
        create_sysfs_device_files(device);
 }
 
-static int acpi_device_unregister(struct acpi_device *device, int type)
+static void acpi_device_unregister(struct acpi_device *device, int type)
 {
        spin_lock(&acpi_device_lock);
        if (device->parent) {
@@ -159,7 +158,6 @@ static int acpi_device_unregister(struct acpi_device *device, int type)
        acpi_detach_data(device->handle, acpi_bus_data_handler);
        remove_sysfs_device_files(device);
        kobject_unregister(&device->kobj);
-       return 0;
 }
 
 void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
@@ -235,12 +233,9 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
 
 int acpi_match_ids(struct acpi_device *device, char *ids)
 {
-       int error = 0;
-       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-
        if (device->flags.hardware_id)
                if (strstr(ids, device->pnp.hardware_id))
-                       goto Done;
+                       return 0;
 
        if (device->flags.compatible_ids) {
                struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
@@ -249,15 +244,10 @@ int acpi_match_ids(struct acpi_device *device, char *ids)
                /* compare multiple _CID entries against driver ids */
                for (i = 0; i < cid_list->count; i++) {
                        if (strstr(ids, cid_list->id[i].value))
-                               goto Done;
+                               return 0;
                }
        }
-       error = -ENOENT;
-
-      Done:
-       if (buffer.pointer)
-               acpi_os_free(buffer.pointer);
-       return error;
+       return -ENOENT;
 }
 
 static acpi_status
@@ -347,7 +337,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
 }
 
 /* --------------------------------------------------------------------------
-               ACPI hotplug sysfs device file support
+               ACPI sysfs device file support
    -------------------------------------------------------------------------- */
 static ssize_t acpi_eject_store(struct acpi_device *device,
                                const char *buf, size_t count);
@@ -442,10 +432,7 @@ acpi_eject_store(struct acpi_device *device, const char *buf, size_t count)
        islockable = device->flags.lockable;
        handle = device->handle;
 
-       if (type == ACPI_TYPE_PROCESSOR)
-               result = acpi_bus_trim(device, 0);
-       else
-               result = acpi_bus_trim(device, 1);
+       result = acpi_bus_trim(device, 1);
 
        if (!result)
                result = acpi_eject_operation(handle, islockable);
@@ -475,8 +462,10 @@ static LIST_HEAD(acpi_bus_drivers);
 static DECLARE_MUTEX(acpi_bus_drivers_lock);
 
 /**
- * acpi_bus_match 
- * --------------
+ * acpi_bus_match - match device IDs to driver's supported IDs
+ * @device: the device that we are trying to match to a driver
+ * @driver: driver whose device id table is being checked
+ *
  * Checks the device's hardware (_HID) or compatible (_CID) ids to see if it
  * matches the specified driver's criteria.
  */
@@ -489,8 +478,10 @@ acpi_bus_match(struct acpi_device *device, struct acpi_driver *driver)
 }
 
 /**
- * acpi_bus_driver_init 
- * --------------------
+ * acpi_bus_driver_init - add a device to a driver
+ * @device: the device to add and initialize
+ * @driver: driver for the device
+ *
  * Used to initialize a device via its device driver.  Called whenever a 
  * driver is bound to a device.  Invokes the driver's add() and start() ops.
  */
@@ -545,10 +536,9 @@ static int acpi_start_single_object(struct acpi_device *device)
        return_VALUE(result);
 }
 
-static int acpi_driver_attach(struct acpi_driver *drv)
+static void acpi_driver_attach(struct acpi_driver *drv)
 {
        struct list_head *node, *next;
-       int count = 0;
 
        ACPI_FUNCTION_TRACE("acpi_driver_attach");
 
@@ -565,7 +555,6 @@ static int acpi_driver_attach(struct acpi_driver *drv)
                        if (!acpi_bus_driver_init(dev, drv)) {
                                acpi_start_single_object(dev);
                                atomic_inc(&drv->references);
-                               count++;
                                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                                  "Found driver [%s] for device [%s]\n",
                                                  drv->name, dev->pnp.bus_id));
@@ -574,10 +563,9 @@ static int acpi_driver_attach(struct acpi_driver *drv)
                spin_lock(&acpi_device_lock);
        }
        spin_unlock(&acpi_device_lock);
-       return_VALUE(count);
 }
 
-static int acpi_driver_detach(struct acpi_driver *drv)
+static void acpi_driver_detach(struct acpi_driver *drv)
 {
        struct list_head *node, *next;
 
@@ -599,69 +587,58 @@ static int acpi_driver_detach(struct acpi_driver *drv)
                }
        }
        spin_unlock(&acpi_device_lock);
-       return_VALUE(0);
 }
 
 /**
- * acpi_bus_register_driver 
- * ------------------------ 
+ * acpi_bus_register_driver - register a driver with the ACPI bus
+ * @driver: driver being registered
+ *
  * Registers a driver with the ACPI bus.  Searches the namespace for all
- * devices that match the driver's criteria and binds.  Returns the
- * number of devices that were claimed by the driver, or a negative
- * error status for failure.
+ * devices that match the driver's criteria and binds.  Returns zero for
+ * success or a negative error status for failure.
  */
 int acpi_bus_register_driver(struct acpi_driver *driver)
 {
-       int count;
-
        ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
 
        if (acpi_disabled)
                return_VALUE(-ENODEV);
 
-       if (!driver)
-               return_VALUE(-EINVAL);
-
        spin_lock(&acpi_device_lock);
        list_add_tail(&driver->node, &acpi_bus_drivers);
        spin_unlock(&acpi_device_lock);
-       count = acpi_driver_attach(driver);
+       acpi_driver_attach(driver);
 
-       return_VALUE(count);
+       return_VALUE(0);
 }
 
 EXPORT_SYMBOL(acpi_bus_register_driver);
 
 /**
- * acpi_bus_unregister_driver 
- * --------------------------
+ * acpi_bus_unregister_driver - unregisters a driver with the APIC bus
+ * @driver: driver to unregister
+ *
  * Unregisters a driver with the ACPI bus.  Searches the namespace for all
  * devices that match the driver's criteria and unbinds.
  */
-int acpi_bus_unregister_driver(struct acpi_driver *driver)
+void acpi_bus_unregister_driver(struct acpi_driver *driver)
 {
-       int error = 0;
+       acpi_driver_detach(driver);
 
-       ACPI_FUNCTION_TRACE("acpi_bus_unregister_driver");
-
-       if (driver) {
-               acpi_driver_detach(driver);
-
-               if (!atomic_read(&driver->references)) {
-                       spin_lock(&acpi_device_lock);
-                       list_del_init(&driver->node);
-                       spin_unlock(&acpi_device_lock);
-               }
-       } else
-               error = -EINVAL;
-       return_VALUE(error);
+       if (!atomic_read(&driver->references)) {
+               spin_lock(&acpi_device_lock);
+               list_del_init(&driver->node);
+               spin_unlock(&acpi_device_lock);
+       }
+       return;
 }
 
 EXPORT_SYMBOL(acpi_bus_unregister_driver);
 
 /**
- * acpi_bus_find_driver 
- * --------------------
+ * acpi_bus_find_driver - check if there is a driver installed for the device
+ * @device: device that we are trying to find a supporting driver for
+ *
  * Parses the list of registered drivers looking for a driver applicable for
  * the specified device.
  */
@@ -844,7 +821,7 @@ static void acpi_device_set_id(struct acpi_device *device,
         * ----
         * Fix for the system root bus device -- the only root-level device.
         */
-       if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
+       if (((acpi_handle)parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
                hid = ACPI_BUS_HID;
                strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
                strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
@@ -1277,7 +1254,7 @@ int acpi_bus_start(struct acpi_device *device)
 
 EXPORT_SYMBOL(acpi_bus_start);
 
-static int acpi_bus_trim(struct acpi_device *start, int rmdevice)
+int acpi_bus_trim(struct acpi_device *start, int rmdevice)
 {
        acpi_status status;
        struct acpi_device *parent, *child;
@@ -1330,6 +1307,8 @@ static int acpi_bus_trim(struct acpi_device *start, int rmdevice)
        }
        return err;
 }
+EXPORT_SYMBOL_GPL(acpi_bus_trim);
+
 
 static int acpi_bus_scan_fixed(struct acpi_device *root)
 {