ACPI: delete unused acpi_device_get_debug_info()
[sfrench/cifs-2.6.git] / drivers / acpi / scan.c
index f8316a05ede72fe459a66341343f5cd40fa6ae09..2e0fc8c3b58b88612bccdde575714a546e9b9798 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/kernel.h>
 #include <linux/acpi.h>
 
 #include <acpi/acpi_drivers.h>
@@ -113,6 +114,8 @@ static struct kset acpi_namespace_kset = {
 static void acpi_device_register(struct acpi_device *device,
                                 struct acpi_device *parent)
 {
+       int err;
+
        /*
         * Linkage
         * -------
@@ -138,7 +141,10 @@ static void acpi_device_register(struct acpi_device *device,
                device->kobj.parent = &parent->kobj;
        device->kobj.ktype = &ktype_acpi_ns;
        device->kobj.kset = &acpi_namespace_kset;
-       kobject_register(&device->kobj);
+       err = kobject_register(&device->kobj);
+       if (err < 0)
+               printk(KERN_WARNING "%s: kobject_register error: %d\n",
+                       __FUNCTION__, err);
        create_sysfs_device_files(device);
 }
 
@@ -162,11 +168,10 @@ static void acpi_device_unregister(struct acpi_device *device, int type)
 
 void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
 {
-       ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
 
        /* TBD */
 
-       return_VOID;
+       return;
 }
 
 static int acpi_bus_get_power_flags(struct acpi_device *device)
@@ -175,7 +180,6 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
        acpi_handle handle = NULL;
        u32 i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
 
        /*
         * Power Management Flags
@@ -228,7 +232,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
 
        device->power.state = ACPI_STATE_UNKNOWN;
 
-       return_VALUE(0);
+       return 0;
 }
 
 int acpi_match_ids(struct acpi_device *device, char *ids)
@@ -306,24 +310,22 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        union acpi_object *package = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags");
 
        /* _PRW */
        status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRW\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRW"));
                goto end;
        }
 
        package = (union acpi_object *)buffer.pointer;
        status = acpi_bus_extract_wakeup_device_power_package(device, package);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error extracting _PRW package\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package"));
                goto end;
        }
 
-       acpi_os_free(buffer.pointer);
+       kfree(buffer.pointer);
 
        device->wakeup.flags.valid = 1;
        /* Power button, Lid switch always enable wakeup */
@@ -333,7 +335,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
       end:
        if (ACPI_FAILURE(status))
                device->flags.wake_capable = 0;
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -489,19 +491,18 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
 
        if (!device || !driver)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!driver->ops.add)
-               return_VALUE(-ENOSYS);
+               return -ENOSYS;
 
        result = driver->ops.add(device);
        if (result) {
                device->driver = NULL;
                acpi_driver_data(device) = NULL;
-               return_VALUE(result);
+               return result;
        }
 
        device->driver = driver;
@@ -513,7 +514,7 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                          "Driver successfully bound to device\n"));
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_start_single_object(struct acpi_device *device)
@@ -521,10 +522,9 @@ static int acpi_start_single_object(struct acpi_device *device)
        int result = 0;
        struct acpi_driver *driver;
 
-       ACPI_FUNCTION_TRACE("acpi_start_single_object");
 
        if (!(driver = device->driver))
-               return_VALUE(0);
+               return 0;
 
        if (driver->ops.start) {
                result = driver->ops.start(device);
@@ -532,14 +532,13 @@ static int acpi_start_single_object(struct acpi_device *device)
                        driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 static void acpi_driver_attach(struct acpi_driver *drv)
 {
        struct list_head *node, *next;
 
-       ACPI_FUNCTION_TRACE("acpi_driver_attach");
 
        spin_lock(&acpi_device_lock);
        list_for_each_safe(node, next, &acpi_device_list) {
@@ -568,7 +567,6 @@ static void acpi_driver_detach(struct acpi_driver *drv)
 {
        struct list_head *node, *next;
 
-       ACPI_FUNCTION_TRACE("acpi_driver_detach");
 
        spin_lock(&acpi_device_lock);
        list_for_each_safe(node, next, &acpi_device_list) {
@@ -598,17 +596,16 @@ static void acpi_driver_detach(struct acpi_driver *drv)
  */
 int acpi_bus_register_driver(struct acpi_driver *driver)
 {
-       ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
 
        if (acpi_disabled)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        spin_lock(&acpi_device_lock);
        list_add_tail(&driver->node, &acpi_bus_drivers);
        spin_unlock(&acpi_device_lock);
        acpi_driver_attach(driver);
 
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_bus_register_driver);
@@ -646,7 +643,6 @@ static int acpi_bus_find_driver(struct acpi_device *device)
        int result = 0;
        struct list_head *node, *next;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
 
        spin_lock(&acpi_device_lock);
        list_for_each_safe(node, next, &acpi_bus_drivers) {
@@ -666,19 +662,41 @@ static int acpi_bus_find_driver(struct acpi_device *device)
        spin_unlock(&acpi_device_lock);
 
       Done:
-       return_VALUE(result);
+       return result;
 }
 
 /* --------------------------------------------------------------------------
                                  Device Enumeration
    -------------------------------------------------------------------------- */
 
+acpi_status
+acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
+{
+       acpi_status status;
+       acpi_handle tmp;
+       struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+       union acpi_object *obj;
+
+       status = acpi_get_handle(handle, "_EJD", &tmp);
+       if (ACPI_FAILURE(status))
+               return status;
+
+       status = acpi_evaluate_object(handle, "_EJD", NULL, &buffer);
+       if (ACPI_SUCCESS(status)) {
+               obj = buffer.pointer;
+               status = acpi_get_handle(NULL, obj->string.pointer, ejd);
+               kfree(buffer.pointer);
+       }
+       return status;
+}
+EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
+
+
 static int acpi_bus_get_flags(struct acpi_device *device)
 {
        acpi_status status = AE_OK;
        acpi_handle temp = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
 
        /* Presence of _STA indicates 'dynamic_status' */
        status = acpi_get_handle(device->handle, "_STA", &temp);
@@ -724,7 +742,7 @@ static int acpi_bus_get_flags(struct acpi_device *device)
 
        /* TBD: Peformance management */
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void acpi_device_get_busid(struct acpi_device *device,
@@ -842,7 +860,7 @@ static void acpi_device_set_id(struct acpi_device *device,
                        printk(KERN_ERR "Memory allocation error\n");
        }
 
-       acpi_os_free(buffer.pointer);
+       kfree(buffer.pointer);
 }
 
 static int acpi_device_set_context(struct acpi_device *device, int type)
@@ -870,58 +888,14 @@ static int acpi_device_set_context(struct acpi_device *device, int type)
        return result;
 }
 
-static void acpi_device_get_debug_info(struct acpi_device *device,
-                                      acpi_handle handle, int type)
-{
-#ifdef CONFIG_ACPI_DEBUG_OUTPUT
-       char *type_string = NULL;
-       char name[80] = { '?', '\0' };
-       struct acpi_buffer buffer = { sizeof(name), name };
-
-       switch (type) {
-       case ACPI_BUS_TYPE_DEVICE:
-               type_string = "Device";
-               acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
-               break;
-       case ACPI_BUS_TYPE_POWER:
-               type_string = "Power Resource";
-               acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
-               break;
-       case ACPI_BUS_TYPE_PROCESSOR:
-               type_string = "Processor";
-               acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
-               break;
-       case ACPI_BUS_TYPE_SYSTEM:
-               type_string = "System";
-               acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
-               break;
-       case ACPI_BUS_TYPE_THERMAL:
-               type_string = "Thermal Zone";
-               acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
-               break;
-       case ACPI_BUS_TYPE_POWER_BUTTON:
-               type_string = "Power Button";
-               sprintf(name, "PWRB");
-               break;
-       case ACPI_BUS_TYPE_SLEEP_BUTTON:
-               type_string = "Sleep Button";
-               sprintf(name, "SLPB");
-               break;
-       }
-
-       printk(KERN_DEBUG "Found %s %s [%p]\n", type_string, name, handle);
-#endif                         /*CONFIG_ACPI_DEBUG_OUTPUT */
-}
-
 static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
 {
        int result = 0;
        struct acpi_driver *driver;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_remove");
 
        if (!dev)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        driver = dev->driver;
 
@@ -930,12 +904,12 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
                if (driver->ops.stop) {
                        result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT);
                        if (result)
-                               return_VALUE(result);
+                               return result;
                }
 
                result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT);
                if (result) {
-                       return_VALUE(result);
+                       return result;
                }
 
                atomic_dec(&dev->driver->references);
@@ -944,7 +918,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
        }
 
        if (!rmdevice)
-               return_VALUE(0);
+               return 0;
 
        if (dev->flags.bus_address) {
                if ((dev->parent) && (dev->parent->ops.unbind))
@@ -953,7 +927,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
 
        acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int
@@ -963,17 +937,15 @@ acpi_add_single_object(struct acpi_device **child,
        int result = 0;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_add_single_object");
 
        if (!child)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
-       device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);
+       device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL);
        if (!device) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
-               return_VALUE(-ENOMEM);
+               printk(KERN_ERR PREFIX "Memory allocation error\n");
+               return -ENOMEM;
        }
-       memset(device, 0, sizeof(struct acpi_device));
 
        device->handle = handle;
        device->parent = parent;
@@ -1061,8 +1033,6 @@ acpi_add_single_object(struct acpi_device **child,
        if ((result = acpi_device_set_context(device, type)))
                goto end;
 
-       acpi_device_get_debug_info(device, handle, type);
-
        acpi_device_register(device, parent);
 
        /*
@@ -1096,7 +1066,7 @@ acpi_add_single_object(struct acpi_device **child,
                kfree(device);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
@@ -1109,10 +1079,9 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
        acpi_object_type type = 0;
        u32 level = 1;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_scan");
 
        if (!start)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        parent = start;
        phandle = start->handle;
@@ -1209,7 +1178,7 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
                }
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 int
@@ -1219,7 +1188,6 @@ acpi_bus_add(struct acpi_device **child,
        int result;
        struct acpi_bus_ops ops;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_add");
 
        result = acpi_add_single_object(child, parent, handle, type);
        if (!result) {
@@ -1227,7 +1195,7 @@ acpi_bus_add(struct acpi_device **child,
                ops.acpi_op_add = 1;
                result = acpi_bus_scan(*child, &ops);
        }
-       return_VALUE(result);
+       return result;
 }
 
 EXPORT_SYMBOL(acpi_bus_add);
@@ -1237,10 +1205,9 @@ int acpi_bus_start(struct acpi_device *device)
        int result;
        struct acpi_bus_ops ops;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_start");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        result = acpi_start_single_object(device);
        if (!result) {
@@ -1248,7 +1215,7 @@ int acpi_bus_start(struct acpi_device *device)
                ops.acpi_op_start = 1;
                result = acpi_bus_scan(device, &ops);
        }
-       return_VALUE(result);
+       return result;
 }
 
 EXPORT_SYMBOL(acpi_bus_start);
@@ -1314,10 +1281,9 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
        int result = 0;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
 
        if (!root)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        /*
         * Enumerate all fixed-feature devices.
@@ -1338,7 +1304,7 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
                        result = acpi_start_single_object(device);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 
@@ -1427,7 +1393,7 @@ static int acpi_device_resume(struct device * dev)
 }
 
 
-struct bus_type acpi_bus_type = {
+static struct bus_type acpi_bus_type = {
        .name           = "acpi",
        .suspend        = acpi_device_suspend,
        .resume         = acpi_device_resume,
@@ -1440,12 +1406,13 @@ static int __init acpi_scan_init(void)
        int result;
        struct acpi_bus_ops ops;
 
-       ACPI_FUNCTION_TRACE("acpi_scan_init");
 
        if (acpi_disabled)
-               return_VALUE(0);
+               return 0;
 
-       kset_register(&acpi_namespace_kset);
+       result = kset_register(&acpi_namespace_kset);
+       if (result < 0)
+               printk(KERN_ERR PREFIX "kset_register error: %d\n", result);
 
        result = bus_register(&acpi_bus_type);
        if (result) {
@@ -1488,7 +1455,7 @@ static int __init acpi_scan_init(void)
                acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
 
       Done:
-       return_VALUE(result);
+       return result;
 }
 
 subsys_initcall(acpi_scan_init);