From 2c8429d958e45da982bc2f480ba8213ab4d95713 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Mon, 26 Jun 2006 23:42:39 -0300 Subject: [PATCH] --- yaml --- r: 31459 b: refs/heads/master c: 38a2713ada91d5e7e4c0a1a0b12e45e2ec7079c3 h: refs/heads/master i: 31457: 6e87314e8430e9d580990abc0d93bc827f62eef8 31455: 1a2f3e2f0dc10607ffe5262ba17bede290bfd7c1 v: v3 --- [refs] | 2 +- trunk/arch/i386/Kconfig | 2 +- .../i386/kernel/cpu/cpufreq/acpi-cpufreq.c | 8 +- .../kernel/cpu/cpufreq/speedstep-centrino.c | 8 +- trunk/drivers/acpi/Kconfig | 7 - trunk/drivers/acpi/Makefile | 1 - trunk/drivers/acpi/ac.c | 63 +- trunk/drivers/acpi/acpi_memhotplug.c | 137 ++-- trunk/drivers/acpi/asus_acpi.c | 2 +- trunk/drivers/acpi/battery.c | 122 +-- trunk/drivers/acpi/bus.c | 128 +-- trunk/drivers/acpi/button.c | 72 +- trunk/drivers/acpi/container.c | 36 +- trunk/drivers/acpi/debug.c | 19 +- trunk/drivers/acpi/dispatcher/dsinit.c | 30 + trunk/drivers/acpi/dispatcher/dsmethod.c | 330 ++++---- trunk/drivers/acpi/dispatcher/dswexec.c | 4 +- trunk/drivers/acpi/dispatcher/dswload.c | 49 +- trunk/drivers/acpi/dock.c | 739 ------------------ trunk/drivers/acpi/ec.c | 168 ++-- trunk/drivers/acpi/event.c | 19 +- trunk/drivers/acpi/events/evgpe.c | 14 +- trunk/drivers/acpi/events/evxface.c | 47 +- trunk/drivers/acpi/executer/exconfig.c | 8 - trunk/drivers/acpi/executer/excreate.c | 27 +- trunk/drivers/acpi/executer/exdump.c | 8 +- trunk/drivers/acpi/executer/exfldio.c | 71 +- trunk/drivers/acpi/executer/exmutex.c | 12 +- trunk/drivers/acpi/executer/exsystem.c | 82 +- trunk/drivers/acpi/fan.c | 51 +- trunk/drivers/acpi/hardware/hwregs.c | 77 +- trunk/drivers/acpi/hotkey.c | 132 ++-- trunk/drivers/acpi/motherboard.c | 5 +- trunk/drivers/acpi/namespace/nsaccess.c | 27 +- trunk/drivers/acpi/osl.c | 72 +- trunk/drivers/acpi/parser/psparse.c | 18 +- trunk/drivers/acpi/pci_bind.c | 87 ++- trunk/drivers/acpi/pci_irq.c | 91 ++- trunk/drivers/acpi/pci_link.c | 189 +++-- trunk/drivers/acpi/pci_root.c | 39 +- trunk/drivers/acpi/power.c | 145 ++-- trunk/drivers/acpi/processor_core.c | 161 ++-- trunk/drivers/acpi/processor_idle.c | 129 +-- trunk/drivers/acpi/processor_perflib.c | 132 ++-- trunk/drivers/acpi/processor_thermal.c | 48 +- trunk/drivers/acpi/processor_throttling.c | 45 +- trunk/drivers/acpi/scan.c | 109 ++- trunk/drivers/acpi/system.c | 21 +- trunk/drivers/acpi/thermal.c | 218 ++++-- trunk/drivers/acpi/utilities/utdelete.c | 36 +- trunk/drivers/acpi/utilities/utglobal.c | 1 - trunk/drivers/acpi/utilities/utmisc.c | 3 - trunk/drivers/acpi/utilities/utmutex.c | 39 +- trunk/drivers/acpi/utils.c | 104 +-- trunk/drivers/acpi/video.c | 270 ++++--- .../drivers/media/video/cx88/cx88-blackbird.c | 43 + trunk/drivers/media/video/cx88/cx88-video.c | 59 +- trunk/drivers/media/video/cx88/cx88.h | 2 + trunk/drivers/pci/hotplug/Makefile | 3 +- trunk/drivers/pci/hotplug/acpiphp.h | 36 +- trunk/drivers/pci/hotplug/acpiphp_core.c | 19 +- trunk/drivers/pci/hotplug/acpiphp_dock.c | 438 +++++++++++ trunk/drivers/pci/hotplug/acpiphp_glue.c | 123 +-- trunk/include/acpi/acconfig.h | 2 +- trunk/include/acpi/acdispat.h | 2 +- trunk/include/acpi/acglobal.h | 26 +- trunk/include/acpi/acinterp.h | 5 +- trunk/include/acpi/aclocal.h | 36 +- trunk/include/acpi/acmacros.h | 2 - trunk/include/acpi/acobject.h | 8 +- trunk/include/acpi/acpi_bus.h | 2 +- trunk/include/acpi/acpi_drivers.h | 17 - trunk/include/acpi/acpiosxf.h | 40 +- trunk/include/acpi/actypes.h | 49 +- trunk/include/acpi/platform/aclinux.h | 2 - trunk/include/acpi/processor.h | 1 - trunk/include/linux/cpufreq.h | 6 +- trunk/include/linux/kobject.h | 2 - trunk/lib/kobject_uevent.c | 4 - 79 files changed, 2737 insertions(+), 2654 deletions(-) delete mode 100644 trunk/drivers/acpi/dock.c create mode 100644 trunk/drivers/pci/hotplug/acpiphp_dock.c diff --git a/[refs] b/[refs] index 25f7b4437ca9..e476f73aad08 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3e8d6ad9bf1f02fdb9fd119c3c266d4b73b7175d +refs/heads/master: 38a2713ada91d5e7e4c0a1a0b12e45e2ec7079c3 diff --git a/trunk/arch/i386/Kconfig b/trunk/arch/i386/Kconfig index 27d8dddbaa47..1718429286d4 100644 --- a/trunk/arch/i386/Kconfig +++ b/trunk/arch/i386/Kconfig @@ -176,7 +176,7 @@ endchoice config ACPI_SRAT bool default y - depends on ACPI && NUMA && (X86_SUMMIT || X86_GENERICARCH) + depends on NUMA && (X86_SUMMIT || X86_GENERICARCH) select ACPI_NUMA config HAVE_ARCH_PARSE_SRAT diff --git a/trunk/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/trunk/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c index cf0ddc9ee0cd..5fd65325b81a 100644 --- a/trunk/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/trunk/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c @@ -418,14 +418,8 @@ acpi_cpufreq_cpu_init ( goto err_free; perf = data->acpi_data; + policy->cpus = perf->shared_cpu_map; policy->shared_type = perf->shared_type; - /* - * Will let policy->cpus know about dependency only when software - * coordination is required. - */ - if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || - policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) - policy->cpus = perf->shared_cpu_map; if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) { acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS; diff --git a/trunk/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/trunk/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c index 8d765509ef59..f7e4356f6820 100644 --- a/trunk/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c +++ b/trunk/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c @@ -399,14 +399,8 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy) dprintk(PFX "obtaining ACPI data failed\n"); return -EIO; } + policy->cpus = p->shared_cpu_map; policy->shared_type = p->shared_type; - /* - * Will let policy->cpus know about dependency only when software - * coordination is required. - */ - if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || - policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) - policy->cpus = p->shared_cpu_map; /* verify the acpi_data */ if (p->state_count <= 1) { diff --git a/trunk/drivers/acpi/Kconfig b/trunk/drivers/acpi/Kconfig index bc2652d72fdc..610d2cc02cf8 100644 --- a/trunk/drivers/acpi/Kconfig +++ b/trunk/drivers/acpi/Kconfig @@ -133,13 +133,6 @@ config ACPI_FAN This driver adds support for ACPI fan devices, allowing user-mode applications to perform basic fan control (on, off, status). -config ACPI_DOCK - tristate "Dock" - depends on !ACPI_IBM_DOCK - default y - help - This driver adds support for ACPI controlled docking stations - config ACPI_PROCESSOR tristate "Processor" default y diff --git a/trunk/drivers/acpi/Makefile b/trunk/drivers/acpi/Makefile index f0a68ecf1e57..5984b4f6715a 100644 --- a/trunk/drivers/acpi/Makefile +++ b/trunk/drivers/acpi/Makefile @@ -42,7 +42,6 @@ obj-$(CONFIG_ACPI_BATTERY) += battery.o obj-$(CONFIG_ACPI_BUTTON) += button.o obj-$(CONFIG_ACPI_EC) += ec.o obj-$(CONFIG_ACPI_FAN) += fan.o -obj-$(CONFIG_ACPI_DOCK) += dock.o obj-$(CONFIG_ACPI_VIDEO) += video.o obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o diff --git a/trunk/drivers/acpi/ac.c b/trunk/drivers/acpi/ac.c index 36ca365bcead..7839b831df94 100644 --- a/trunk/drivers/acpi/ac.c +++ b/trunk/drivers/acpi/ac.c @@ -84,18 +84,20 @@ static int acpi_ac_get_state(struct acpi_ac *ac) { acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_ac_get_state"); if (!ac) - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error reading AC Adapter state\n")); ac->state = ACPI_AC_STATUS_UNKNOWN; - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -108,13 +110,14 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset) { struct acpi_ac *ac = (struct acpi_ac *)seq->private; + ACPI_FUNCTION_TRACE("acpi_ac_seq_show"); if (!ac) - return 0; + return_VALUE(0); if (acpi_ac_get_state(ac)) { seq_puts(seq, "ERROR: Unable to read AC Adapter state\n"); - return 0; + return_VALUE(0); } seq_puts(seq, "state: "); @@ -130,7 +133,7 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset) break; } - return 0; + return_VALUE(0); } static int acpi_ac_open_fs(struct inode *inode, struct file *file) @@ -142,12 +145,13 @@ static int acpi_ac_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; + ACPI_FUNCTION_TRACE("acpi_ac_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_ac_dir); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; } @@ -155,18 +159,21 @@ static int acpi_ac_add_fs(struct acpi_device *device) entry = create_proc_entry(ACPI_AC_FILE_STATE, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_AC_FILE_STATE)); else { entry->proc_fops = &acpi_ac_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return 0; + return_VALUE(0); } static int acpi_ac_remove_fs(struct acpi_device *device) { + ACPI_FUNCTION_TRACE("acpi_ac_remove_fs"); if (acpi_device_dir(device)) { remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device)); @@ -175,7 +182,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -187,12 +194,13 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) struct acpi_ac *ac = (struct acpi_ac *)data; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_ac_notify"); if (!ac) - return; + return_VOID; if (acpi_bus_get_device(ac->handle, &device)) - return; + return_VOID; switch (event) { case ACPI_AC_NOTIFY_STATUS: @@ -205,7 +213,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) break; } - return; + return_VOID; } static int acpi_ac_add(struct acpi_device *device) @@ -214,13 +222,14 @@ static int acpi_ac_add(struct acpi_device *device) acpi_status status = AE_OK; struct acpi_ac *ac = NULL; + ACPI_FUNCTION_TRACE("acpi_ac_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL); if (!ac) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(ac, 0, sizeof(struct acpi_ac)); ac->handle = device->handle; @@ -240,6 +249,8 @@ static int acpi_ac_add(struct acpi_device *device) ACPI_DEVICE_NOTIFY, acpi_ac_notify, ac); if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -254,7 +265,7 @@ static int acpi_ac_add(struct acpi_device *device) kfree(ac); } - return result; + return_VALUE(result); } static int acpi_ac_remove(struct acpi_device *device, int type) @@ -262,49 +273,55 @@ static int acpi_ac_remove(struct acpi_device *device, int type) acpi_status status = AE_OK; struct acpi_ac *ac = NULL; + ACPI_FUNCTION_TRACE("acpi_ac_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); ac = (struct acpi_ac *)acpi_driver_data(device); status = acpi_remove_notify_handler(ac->handle, ACPI_DEVICE_NOTIFY, acpi_ac_notify); + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); acpi_ac_remove_fs(device); kfree(ac); - return 0; + return_VALUE(0); } static int __init acpi_ac_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_ac_init"); acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); if (!acpi_ac_dir) - return -ENODEV; + return_VALUE(-ENODEV); acpi_ac_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_ac_driver); if (result < 0) { remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } static void __exit acpi_ac_exit(void) { + ACPI_FUNCTION_TRACE("acpi_ac_exit"); acpi_bus_unregister_driver(&acpi_ac_driver); remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); - return; + return_VOID; } module_init(acpi_ac_init); diff --git a/trunk/drivers/acpi/acpi_memhotplug.c b/trunk/drivers/acpi/acpi_memhotplug.c index cd57372a6729..1012284ff4f7 100644 --- a/trunk/drivers/acpi/acpi_memhotplug.c +++ b/trunk/drivers/acpi/acpi_memhotplug.c @@ -128,6 +128,7 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) acpi_status status; struct acpi_memory_info *info, *n; + ACPI_FUNCTION_TRACE("acpi_memory_get_device_resources"); status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS, acpi_memory_get_resource, mem_device); @@ -149,21 +150,23 @@ acpi_memory_get_device(acpi_handle handle, struct acpi_device *device = NULL; struct acpi_device *pdevice = NULL; + ACPI_FUNCTION_TRACE("acpi_memory_get_device"); if (!acpi_bus_get_device(handle, &device) && device) goto end; status = acpi_get_parent(handle, &phandle); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent")); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_get_parent\n")); + return_VALUE(-EINVAL); } /* Get the parent device */ status = acpi_bus_get_device(phandle, &pdevice); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Cannot get acpi bus device")); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error in acpi_bus_get_device\n")); + return_VALUE(-EINVAL); } /* @@ -172,29 +175,30 @@ acpi_memory_get_device(acpi_handle handle, */ status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Cannot add acpi bus")); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_bus_add\n")); + return_VALUE(-EINVAL); } end: *mem_device = acpi_driver_data(device); if (!(*mem_device)) { printk(KERN_ERR "\n driver data not found"); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } static int acpi_memory_check_device(struct acpi_memory_device *mem_device) { unsigned long current_status; + ACPI_FUNCTION_TRACE("acpi_memory_check_device"); /* Get device present/absent information from the _STA */ if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA", NULL, ¤t_status))) - return -ENODEV; + return_VALUE(-ENODEV); /* * Check for device status. Device should be * present/enabled/functioning. @@ -202,9 +206,9 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device) if (!((current_status & ACPI_MEMORY_STA_PRESENT) && (current_status & ACPI_MEMORY_STA_ENABLED) && (current_status & ACPI_MEMORY_STA_FUNCTIONAL))) - return -ENODEV; + return_VALUE(-ENODEV); - return 0; + return_VALUE(0); } static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) @@ -213,11 +217,13 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) struct acpi_memory_info *info; int node; + ACPI_FUNCTION_TRACE("acpi_memory_enable_device"); /* Get the range from the _CRS */ result = acpi_memory_get_device_resources(mem_device); if (result) { - printk(KERN_ERR PREFIX "get_device_resources failed\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "\nget_device_resources failed\n")); mem_device->state = MEMORY_INVALID_STATE; return result; } @@ -248,7 +254,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) num_enabled++; } if (!num_enabled) { - printk(KERN_ERR PREFIX "add_memory failed\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n")); mem_device->state = MEMORY_INVALID_STATE; return -EINVAL; } @@ -263,6 +269,7 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) union acpi_object arg; unsigned long current_status; + ACPI_FUNCTION_TRACE("acpi_memory_powerdown_device"); /* Issue the _EJ0 command */ arg_list.count = 1; @@ -273,21 +280,21 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) "_EJ0", &arg_list, NULL); /* Return on _EJ0 failure */ if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "_EJ0 failed")); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_EJ0 failed.\n")); + return_VALUE(-ENODEV); } /* Evalute _STA to check if the device is disabled */ status = acpi_evaluate_integer(mem_device->handle, "_STA", NULL, ¤t_status); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); /* Check for device status. Device should be disabled */ if (current_status & ACPI_MEMORY_STA_ENABLED) - return -EINVAL; + return_VALUE(-EINVAL); - return 0; + return_VALUE(0); } static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) @@ -295,6 +302,7 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) int result; struct acpi_memory_info *info, *n; + ACPI_FUNCTION_TRACE("acpi_memory_disable_device"); /* * Ask the VM to offline this memory range. @@ -312,6 +320,8 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) /* Power-off and eject the device */ result = acpi_memory_powerdown_device(mem_device); if (result) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Device Power Down failed.\n")); /* Set the status of the device to invalid */ mem_device->state = MEMORY_INVALID_STATE; return result; @@ -326,6 +336,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) struct acpi_memory_device *mem_device; struct acpi_device *device; + ACPI_FUNCTION_TRACE("acpi_memory_device_notify"); switch (event) { case ACPI_NOTIFY_BUS_CHECK: @@ -337,14 +348,15 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "\nReceived DEVICE CHECK notification for device\n")); if (acpi_memory_get_device(handle, &mem_device)) { - printk(KERN_ERR PREFIX "Cannot find driver data\n"); - return; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error in finding driver data\n")); + return_VOID; } if (!acpi_memory_check_device(mem_device)) { if (acpi_memory_enable_device(mem_device)) - printk(KERN_ERR PREFIX - "Cannot enable memory device\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error in acpi_memory_enable_device\n")); } break; case ACPI_NOTIFY_EJECT_REQUEST: @@ -352,12 +364,14 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) "\nReceived EJECT REQUEST notification for device\n")); if (acpi_bus_get_device(handle, &device)) { - printk(KERN_ERR PREFIX "Device doesn't exist\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Device doesn't exist\n")); break; } mem_device = acpi_driver_data(device); if (!mem_device) { - printk(KERN_ERR PREFIX "Driver Data is NULL\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Driver Data is NULL\n")); break; } @@ -368,8 +382,8 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) * with generic sysfs driver */ if (acpi_memory_disable_device(mem_device)) - printk(KERN_ERR PREFIX - "Disable memory device\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error in acpi_memory_disable_device\n")); /* * TBD: Invoke acpi_bus_remove to cleanup data structures */ @@ -380,7 +394,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) break; } - return; + return_VOID; } static int acpi_memory_device_add(struct acpi_device *device) @@ -388,13 +402,14 @@ static int acpi_memory_device_add(struct acpi_device *device) int result; struct acpi_memory_device *mem_device = NULL; + ACPI_FUNCTION_TRACE("acpi_memory_device_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL); if (!mem_device) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(mem_device, 0, sizeof(struct acpi_memory_device)); INIT_LIST_HEAD(&mem_device->res_list); @@ -407,7 +422,7 @@ static int acpi_memory_device_add(struct acpi_device *device) result = acpi_memory_get_device_resources(mem_device); if (result) { kfree(mem_device); - return result; + return_VALUE(result); } /* Set the device state */ @@ -415,21 +430,22 @@ static int acpi_memory_device_add(struct acpi_device *device) printk(KERN_INFO "%s \n", acpi_device_name(device)); - return result; + return_VALUE(result); } static int acpi_memory_device_remove(struct acpi_device *device, int type) { struct acpi_memory_device *mem_device = NULL; + ACPI_FUNCTION_TRACE("acpi_memory_device_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); mem_device = (struct acpi_memory_device *)acpi_driver_data(device); kfree(mem_device); - return 0; + return_VALUE(0); } static int acpi_memory_device_start (struct acpi_device *device) @@ -437,6 +453,8 @@ static int acpi_memory_device_start (struct acpi_device *device) struct acpi_memory_device *mem_device; int result = 0; + ACPI_FUNCTION_TRACE("acpi_memory_device_start"); + mem_device = acpi_driver_data(device); if (!acpi_memory_check_device(mem_device)) { @@ -446,7 +464,7 @@ static int acpi_memory_device_start (struct acpi_device *device) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_memory_enable_device\n")); } - return result; + return_VALUE(result); } /* @@ -459,15 +477,16 @@ static acpi_status is_memory_device(acpi_handle handle) struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_device_info *info; + ACPI_FUNCTION_TRACE("is_memory_device"); status = acpi_get_object_info(handle, &buffer); if (ACPI_FAILURE(status)) - return status; + return_ACPI_STATUS(AE_ERROR); info = buffer.pointer; if (!(info->valid & ACPI_VALID_HID)) { acpi_os_free(buffer.pointer); - return AE_ERROR; + return_ACPI_STATUS(AE_ERROR); } hardware_id = info->hardware_id.value; @@ -476,7 +495,7 @@ static acpi_status is_memory_device(acpi_handle handle) status = AE_ERROR; acpi_os_free(buffer.pointer); - return status; + return_ACPI_STATUS(status); } static acpi_status @@ -485,17 +504,21 @@ acpi_memory_register_notify_handler(acpi_handle handle, { acpi_status status; + ACPI_FUNCTION_TRACE("acpi_memory_register_notify_handler"); status = is_memory_device(handle); - if (ACPI_FAILURE(status)){ - ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device")); - return AE_OK; /* continue */ - } + if (ACPI_FAILURE(status)) + return_ACPI_STATUS(AE_OK); /* continue */ status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_memory_device_notify, NULL); - /* continue */ - return AE_OK; + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing notify handler\n")); + return_ACPI_STATUS(AE_OK); /* continue */ + } + + return_ACPI_STATUS(status); } static acpi_status @@ -504,18 +527,22 @@ acpi_memory_deregister_notify_handler(acpi_handle handle, { acpi_status status; + ACPI_FUNCTION_TRACE("acpi_memory_deregister_notify_handler"); status = is_memory_device(handle); - if (ACPI_FAILURE(status)){ - ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device")); - return AE_OK; /* continue */ - } + if (ACPI_FAILURE(status)) + return_ACPI_STATUS(AE_OK); /* continue */ status = acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_memory_device_notify); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); + return_ACPI_STATUS(AE_OK); /* continue */ + } - return AE_OK; /* continue */ + return_ACPI_STATUS(status); } static int __init acpi_memory_device_init(void) @@ -523,11 +550,12 @@ static int __init acpi_memory_device_init(void) int result; acpi_status status; + ACPI_FUNCTION_TRACE("acpi_memory_device_init"); result = acpi_bus_register_driver(&acpi_memory_device_driver); if (result < 0) - return -ENODEV; + return_VALUE(-ENODEV); status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, @@ -535,18 +563,19 @@ static int __init acpi_memory_device_init(void) NULL, NULL); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); acpi_bus_unregister_driver(&acpi_memory_device_driver); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } static void __exit acpi_memory_device_exit(void) { acpi_status status; + ACPI_FUNCTION_TRACE("acpi_memory_device_exit"); /* * Adding this to un-install notification handlers for all the device @@ -558,11 +587,11 @@ static void __exit acpi_memory_device_exit(void) NULL, NULL); if (ACPI_FAILURE(status)) - ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); acpi_bus_unregister_driver(&acpi_memory_device_driver); - return; + return_VOID; } module_init(acpi_memory_device_init); diff --git a/trunk/drivers/acpi/asus_acpi.c b/trunk/drivers/acpi/asus_acpi.c index 055cfd5c8766..839f423d738d 100644 --- a/trunk/drivers/acpi/asus_acpi.c +++ b/trunk/drivers/acpi/asus_acpi.c @@ -1232,7 +1232,7 @@ static int __init asus_acpi_init(void) result = acpi_bus_register_driver(&asus_hotk_driver); if (result < 0) { remove_proc_entry(PROC_ASUS, acpi_root_dir); - return result; + return -ENODEV; } /* diff --git a/trunk/drivers/acpi/battery.c b/trunk/drivers/acpi/battery.c index 00b0728efe82..702e857e98c5 100644 --- a/trunk/drivers/acpi/battery.c +++ b/trunk/drivers/acpi/battery.c @@ -132,16 +132,17 @@ acpi_battery_get_info(struct acpi_battery *battery, struct acpi_buffer data = { 0, NULL }; union acpi_object *package = NULL; + ACPI_FUNCTION_TRACE("acpi_battery_get_info"); if (!battery || !bif) - return -EINVAL; + return_VALUE(-EINVAL); /* Evalute _BIF */ status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BIF\n")); + return_VALUE(-ENODEV); } package = (union acpi_object *)buffer.pointer; @@ -150,7 +151,7 @@ acpi_battery_get_info(struct acpi_battery *battery, status = acpi_extract_package(package, &format, &data); if (status != AE_BUFFER_OVERFLOW) { - ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); result = -ENODEV; goto end; } @@ -164,7 +165,7 @@ acpi_battery_get_info(struct acpi_battery *battery, status = acpi_extract_package(package, &format, &data); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); kfree(data.pointer); result = -ENODEV; goto end; @@ -176,7 +177,7 @@ acpi_battery_get_info(struct acpi_battery *battery, if (!result) (*bif) = (struct acpi_battery_info *)data.pointer; - return result; + return_VALUE(result); } static int @@ -192,16 +193,17 @@ acpi_battery_get_status(struct acpi_battery *battery, struct acpi_buffer data = { 0, NULL }; union acpi_object *package = NULL; + ACPI_FUNCTION_TRACE("acpi_battery_get_status"); if (!battery || !bst) - return -EINVAL; + return_VALUE(-EINVAL); /* Evalute _BST */ status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BST\n")); + return_VALUE(-ENODEV); } package = (union acpi_object *)buffer.pointer; @@ -210,7 +212,7 @@ acpi_battery_get_status(struct acpi_battery *battery, status = acpi_extract_package(package, &format, &data); if (status != AE_BUFFER_OVERFLOW) { - ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); result = -ENODEV; goto end; } @@ -224,7 +226,7 @@ acpi_battery_get_status(struct acpi_battery *battery, status = acpi_extract_package(package, &format, &data); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); kfree(data.pointer); result = -ENODEV; goto end; @@ -236,7 +238,7 @@ acpi_battery_get_status(struct acpi_battery *battery, if (!result) (*bst) = (struct acpi_battery_status *)data.pointer; - return result; + return_VALUE(result); } static int @@ -246,24 +248,25 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm) union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list arg_list = { 1, &arg0 }; + ACPI_FUNCTION_TRACE("acpi_battery_set_alarm"); if (!battery) - return -EINVAL; + return_VALUE(-EINVAL); if (!battery->flags.alarm) - return -ENODEV; + return_VALUE(-ENODEV); arg0.integer.value = alarm; status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm)); battery->alarm = alarm; - return 0; + return_VALUE(0); } static int acpi_battery_check(struct acpi_battery *battery) @@ -274,17 +277,18 @@ static int acpi_battery_check(struct acpi_battery *battery) struct acpi_device *device = NULL; struct acpi_battery_info *bif = NULL; + ACPI_FUNCTION_TRACE("acpi_battery_check"); if (!battery) - return -EINVAL; + return_VALUE(-EINVAL); result = acpi_bus_get_device(battery->handle, &device); if (result) - return result; + return_VALUE(result); result = acpi_bus_get_status(device); if (result) - return result; + return_VALUE(result); /* Insertion? */ @@ -296,7 +300,7 @@ static int acpi_battery_check(struct acpi_battery *battery) result = acpi_battery_get_info(battery, &bif); if (result) - return result; + return_VALUE(result); battery->flags.power_unit = bif->power_unit; battery->trips.warning = bif->design_capacity_warning; @@ -320,7 +324,7 @@ static int acpi_battery_check(struct acpi_battery *battery) battery->flags.present = device->status.battery_present; - return result; + return_VALUE(result); } /* -------------------------------------------------------------------------- @@ -335,6 +339,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) struct acpi_battery_info *bif = NULL; char *units = "?"; + ACPI_FUNCTION_TRACE("acpi_battery_read_info"); if (!battery) goto end; @@ -404,7 +409,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) end: kfree(bif); - return 0; + return_VALUE(0); } static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) @@ -419,6 +424,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) struct acpi_battery_status *bst = NULL; char *units = "?"; + ACPI_FUNCTION_TRACE("acpi_battery_read_state"); if (!battery) goto end; @@ -452,6 +458,8 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) if ((bst->state & 0x01) && (bst->state & 0x02)) { seq_printf(seq, "charging state: charging/discharging\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Battery Charging and Discharging?\n")); } else if (bst->state & 0x01) seq_printf(seq, "charging state: discharging\n"); else if (bst->state & 0x02) @@ -481,7 +489,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) end: kfree(bst); - return 0; + return_VALUE(0); } static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) @@ -494,6 +502,7 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) struct acpi_battery *battery = (struct acpi_battery *)seq->private; char *units = "?"; + ACPI_FUNCTION_TRACE("acpi_battery_read_alarm"); if (!battery) goto end; @@ -518,7 +527,7 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); end: - return 0; + return_VALUE(0); } static ssize_t @@ -531,24 +540,25 @@ acpi_battery_write_alarm(struct file *file, struct seq_file *m = (struct seq_file *)file->private_data; struct acpi_battery *battery = (struct acpi_battery *)m->private; + ACPI_FUNCTION_TRACE("acpi_battery_write_alarm"); if (!battery || (count > sizeof(alarm_string) - 1)) - return -EINVAL; + return_VALUE(-EINVAL); if (!battery->flags.present) - return -ENODEV; + return_VALUE(-ENODEV); if (copy_from_user(alarm_string, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); alarm_string[count] = '\0'; result = acpi_battery_set_alarm(battery, simple_strtoul(alarm_string, NULL, 0)); if (result) - return result; + return_VALUE(result); - return count; + return_VALUE(count); } static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) @@ -585,12 +595,13 @@ static int acpi_battery_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; + ACPI_FUNCTION_TRACE("acpi_battery_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_battery_dir); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; } @@ -598,7 +609,9 @@ static int acpi_battery_add_fs(struct acpi_device *device) entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_BATTERY_FILE_INFO)); else { entry->proc_fops = &acpi_battery_info_ops; entry->data = acpi_driver_data(device); @@ -609,7 +622,9 @@ static int acpi_battery_add_fs(struct acpi_device *device) entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_BATTERY_FILE_STATUS)); else { entry->proc_fops = &acpi_battery_state_ops; entry->data = acpi_driver_data(device); @@ -621,18 +636,21 @@ static int acpi_battery_add_fs(struct acpi_device *device) S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_BATTERY_FILE_ALARM)); else { entry->proc_fops = &acpi_battery_alarm_ops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return 0; + return_VALUE(0); } static int acpi_battery_remove_fs(struct acpi_device *device) { + ACPI_FUNCTION_TRACE("acpi_battery_remove_fs"); if (acpi_device_dir(device)) { remove_proc_entry(ACPI_BATTERY_FILE_ALARM, @@ -646,7 +664,7 @@ static int acpi_battery_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -658,12 +676,13 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) struct acpi_battery *battery = (struct acpi_battery *)data; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_battery_notify"); if (!battery) - return; + return_VOID; if (acpi_bus_get_device(handle, &device)) - return; + return_VOID; switch (event) { case ACPI_BATTERY_NOTIFY_STATUS: @@ -677,7 +696,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) break; } - return; + return_VOID; } static int acpi_battery_add(struct acpi_device *device) @@ -686,13 +705,14 @@ static int acpi_battery_add(struct acpi_device *device) acpi_status status = 0; struct acpi_battery *battery = NULL; + ACPI_FUNCTION_TRACE("acpi_battery_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL); if (!battery) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(battery, 0, sizeof(struct acpi_battery)); battery->handle = device->handle; @@ -712,6 +732,8 @@ static int acpi_battery_add(struct acpi_device *device) ACPI_DEVICE_NOTIFY, acpi_battery_notify, battery); if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -726,7 +748,7 @@ static int acpi_battery_add(struct acpi_device *device) kfree(battery); } - return result; + return_VALUE(result); } static int acpi_battery_remove(struct acpi_device *device, int type) @@ -734,50 +756,56 @@ static int acpi_battery_remove(struct acpi_device *device, int type) acpi_status status = 0; struct acpi_battery *battery = NULL; + ACPI_FUNCTION_TRACE("acpi_battery_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); battery = (struct acpi_battery *)acpi_driver_data(device); status = acpi_remove_notify_handler(battery->handle, ACPI_DEVICE_NOTIFY, acpi_battery_notify); + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); acpi_battery_remove_fs(device); kfree(battery); - return 0; + return_VALUE(0); } static int __init acpi_battery_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_battery_init"); acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); if (!acpi_battery_dir) - return -ENODEV; + return_VALUE(-ENODEV); acpi_battery_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_battery_driver); if (result < 0) { remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } static void __exit acpi_battery_exit(void) { + ACPI_FUNCTION_TRACE("acpi_battery_exit"); acpi_bus_unregister_driver(&acpi_battery_driver); remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); - return; + return_VOID; } module_init(acpi_battery_init); diff --git a/trunk/drivers/acpi/bus.c b/trunk/drivers/acpi/bus.c index dec044c04273..dd3983cece92 100644 --- a/trunk/drivers/acpi/bus.c +++ b/trunk/drivers/acpi/bus.c @@ -60,19 +60,21 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) { acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_bus_get_device"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); /* TBD: Support fixed-feature devices */ status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); if (ACPI_FAILURE(status) || !*device) { - ACPI_EXCEPTION((AE_INFO, status, "No context for object [%p]", handle)); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No context for object [%p]\n", + handle)); + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } EXPORT_SYMBOL(acpi_bus_get_device); @@ -82,9 +84,10 @@ int acpi_bus_get_status(struct acpi_device *device) acpi_status status = AE_OK; unsigned long sta = 0; + ACPI_FUNCTION_TRACE("acpi_bus_get_status"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); /* * Evaluate _STA if present. @@ -93,7 +96,7 @@ int acpi_bus_get_status(struct acpi_device *device) status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); STRUCT_TO_INT(device->status) = (int)sta; } @@ -117,7 +120,7 @@ int acpi_bus_get_status(struct acpi_device *device) device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status))); - return 0; + return_VALUE(0); } EXPORT_SYMBOL(acpi_bus_get_status); @@ -133,10 +136,11 @@ int acpi_bus_get_power(acpi_handle handle, int *state) struct acpi_device *device = NULL; unsigned long psc = 0; + ACPI_FUNCTION_TRACE("acpi_bus_get_power"); result = acpi_bus_get_device(handle, &device); if (result) - return result; + return_VALUE(result); *state = ACPI_STATE_UNKNOWN; @@ -155,12 +159,12 @@ int acpi_bus_get_power(acpi_handle handle, int *state) status = acpi_evaluate_integer(device->handle, "_PSC", NULL, &psc); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); device->power.state = (int)psc; } else if (device->power.flags.power_resources) { result = acpi_power_get_inferred_state(device); if (result) - return result; + return_VALUE(result); } *state = device->power.state; @@ -169,7 +173,7 @@ int acpi_bus_get_power(acpi_handle handle, int *state) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n", device->pnp.bus_id, device->power.state)); - return 0; + return_VALUE(0); } EXPORT_SYMBOL(acpi_bus_get_power); @@ -181,20 +185,21 @@ int acpi_bus_set_power(acpi_handle handle, int state) struct acpi_device *device = NULL; char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' }; + ACPI_FUNCTION_TRACE("acpi_bus_set_power"); result = acpi_bus_get_device(handle, &device); if (result) - return result; + return_VALUE(result); if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) - return -EINVAL; + return_VALUE(-EINVAL); /* Make sure this is a valid target state */ if (!device->flags.power_manageable) { - printk(KERN_DEBUG "Device `[%s]is not power manageable", - device->kobj.name); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Device is not power manageable\n")); + return_VALUE(-ENODEV); } /* * Get device's current power state if it's unknown @@ -206,18 +211,18 @@ int acpi_bus_set_power(acpi_handle handle, int state) if (state == device->power.state) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state)); - return 0; + return_VALUE(0); } } if (!device->power.states[state].flags.valid) { - printk(KERN_WARNING PREFIX "Device does not support D%d\n", state); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", + state)); + return_VALUE(-ENODEV); } if (device->parent && (state < device->parent->power.state)) { - printk(KERN_WARNING PREFIX - "Cannot set device to a higher-powered" - " state than parent\n"); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Cannot set device to a higher-powered state than parent\n")); + return_VALUE(-ENODEV); } /* @@ -259,15 +264,15 @@ int acpi_bus_set_power(acpi_handle handle, int state) end: if (result) - printk(KERN_WARNING PREFIX - "Transitioning device [%s] to D%d\n", - device->pnp.bus_id, state); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Error transitioning device [%s] to D%d\n", + device->pnp.bus_id, state)); else ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] transitioned to D%d\n", device->pnp.bus_id, state)); - return result; + return_VALUE(result); } EXPORT_SYMBOL(acpi_bus_set_power); @@ -288,17 +293,18 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data) struct acpi_bus_event *event = NULL; unsigned long flags = 0; + ACPI_FUNCTION_TRACE("acpi_bus_generate_event"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); /* drop event on the floor if no one's listening */ if (!event_is_open) - return 0; + return_VALUE(0); event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC); if (!event) - return -ENOMEM; + return_VALUE(-ENOMEM); strcpy(event->device_class, device->pnp.device_class); strcpy(event->bus_id, device->pnp.bus_id); @@ -311,7 +317,7 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data) wake_up_interruptible(&acpi_bus_event_queue); - return 0; + return_VALUE(0); } EXPORT_SYMBOL(acpi_bus_generate_event); @@ -323,9 +329,10 @@ int acpi_bus_receive_event(struct acpi_bus_event *event) DECLARE_WAITQUEUE(wait, current); + ACPI_FUNCTION_TRACE("acpi_bus_receive_event"); if (!event) - return -EINVAL; + return_VALUE(-EINVAL); if (list_empty(&acpi_bus_event_list)) { @@ -339,7 +346,7 @@ int acpi_bus_receive_event(struct acpi_bus_event *event) set_current_state(TASK_RUNNING); if (signal_pending(current)) - return -ERESTARTSYS; + return_VALUE(-ERESTARTSYS); } spin_lock_irqsave(&acpi_bus_event_lock, flags); @@ -350,13 +357,13 @@ int acpi_bus_receive_event(struct acpi_bus_event *event) spin_unlock_irqrestore(&acpi_bus_event_lock, flags); if (!entry) - return -ENODEV; + return_VALUE(-ENODEV); memcpy(event, entry, sizeof(struct acpi_bus_event)); kfree(entry); - return 0; + return_VALUE(0); } EXPORT_SYMBOL(acpi_bus_receive_event); @@ -371,9 +378,10 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed) acpi_status status = 0; struct acpi_device_status old_status; + ACPI_FUNCTION_TRACE("acpi_bus_check_device"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); if (status_changed) *status_changed = 0; @@ -390,15 +398,15 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed) if (status_changed) *status_changed = 1; } - return 0; + return_VALUE(0); } status = acpi_bus_get_status(device); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) - return 0; + return_VALUE(0); if (status_changed) *status_changed = 1; @@ -414,7 +422,7 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed) /* TBD: Handle device removal */ } - return 0; + return_VALUE(0); } static int acpi_bus_check_scope(struct acpi_device *device) @@ -422,24 +430,25 @@ static int acpi_bus_check_scope(struct acpi_device *device) int result = 0; int status_changed = 0; + ACPI_FUNCTION_TRACE("acpi_bus_check_scope"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); /* Status Change? */ result = acpi_bus_check_device(device, &status_changed); if (result) - return result; + return_VALUE(result); if (!status_changed) - return 0; + return_VALUE(0); /* * TBD: Enumerate child devices within this device's scope and * run acpi_bus_check_device()'s on them. */ - return 0; + return_VALUE(0); } /** @@ -452,9 +461,10 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) int result = 0; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_bus_notify"); if (acpi_bus_get_device(handle, &device)) - return; + return_VOID; switch (type) { @@ -529,7 +539,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) break; } - return; + return_VOID; } /* -------------------------------------------------------------------------- @@ -543,6 +553,7 @@ static int __init acpi_bus_init_irq(void) struct acpi_object_list arg_list = { 1, &arg }; char *message = NULL; + ACPI_FUNCTION_TRACE("acpi_bus_init_irq"); /* * Let the system know what interrupt model we are using by @@ -561,7 +572,7 @@ static int __init acpi_bus_init_irq(void) break; default: printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n"); - return -ENODEV; + return_VALUE(-ENODEV); } printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message); @@ -570,11 +581,11 @@ static int __init acpi_bus_init_irq(void) status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL); if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC")); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n")); + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } void __init acpi_early_init(void) @@ -582,9 +593,10 @@ void __init acpi_early_init(void) acpi_status status = AE_OK; struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt }; + ACPI_FUNCTION_TRACE("acpi_early_init"); if (acpi_disabled) - return; + return_VOID; printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION); @@ -644,11 +656,11 @@ void __init acpi_early_init(void) goto error0; } - return; + return_VOID; error0: disable_acpi(); - return; + return_VOID; } static int __init acpi_bus_init(void) @@ -657,6 +669,7 @@ static int __init acpi_bus_init(void) acpi_status status = AE_OK; extern acpi_status acpi_os_initialize1(void); + ACPI_FUNCTION_TRACE("acpi_bus_init"); status = acpi_os_initialize1(); @@ -718,12 +731,12 @@ static int __init acpi_bus_init(void) */ acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL); - return 0; + return_VALUE(0); /* Mimic structured exception handling */ error1: acpi_terminate(); - return -ENODEV; + return_VALUE(-ENODEV); } decl_subsys(acpi, NULL, NULL); @@ -732,10 +745,11 @@ static int __init acpi_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_init"); if (acpi_disabled) { printk(KERN_INFO PREFIX "Interpreter disabled.\n"); - return -ENODEV; + return_VALUE(-ENODEV); } firmware_register(&acpi_subsys); @@ -756,7 +770,7 @@ static int __init acpi_init(void) } else disable_acpi(); - return result; + return_VALUE(result); } subsys_initcall(acpi_init); diff --git a/trunk/drivers/acpi/button.c b/trunk/drivers/acpi/button.c index 02594639c4d9..4b6d9f0096a1 100644 --- a/trunk/drivers/acpi/button.c +++ b/trunk/drivers/acpi/button.c @@ -112,14 +112,15 @@ static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) { struct acpi_button *button = (struct acpi_button *)seq->private; + ACPI_FUNCTION_TRACE("acpi_button_info_seq_show"); if (!button || !button->device) - return 0; + return_VALUE(0); seq_printf(seq, "type: %s\n", acpi_device_name(button->device)); - return 0; + return_VALUE(0); } static int acpi_button_info_open_fs(struct inode *inode, struct file *file) @@ -133,9 +134,10 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) acpi_status status; unsigned long state; + ACPI_FUNCTION_TRACE("acpi_button_state_seq_show"); if (!button || !button->device) - return 0; + return_VALUE(0); status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state); if (ACPI_FAILURE(status)) { @@ -145,7 +147,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) (state ? "open" : "closed")); } - return 0; + return_VALUE(0); } static int acpi_button_state_open_fs(struct inode *inode, struct file *file) @@ -162,9 +164,10 @@ static int acpi_button_add_fs(struct acpi_device *device) struct proc_dir_entry *entry = NULL; struct acpi_button *button = NULL; + ACPI_FUNCTION_TRACE("acpi_button_add_fs"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); button = acpi_driver_data(device); @@ -192,19 +195,21 @@ static int acpi_button_add_fs(struct acpi_device *device) } if (!entry) - return -ENODEV; + return_VALUE(-ENODEV); entry->owner = THIS_MODULE; acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; /* 'info' [R] */ entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_BUTTON_FILE_INFO)); else { entry->proc_fops = &acpi_button_info_fops; entry->data = acpi_driver_data(device); @@ -216,7 +221,9 @@ static int acpi_button_add_fs(struct acpi_device *device) entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_BUTTON_FILE_INFO)); else { entry->proc_fops = &acpi_button_state_fops; entry->data = acpi_driver_data(device); @@ -224,13 +231,14 @@ static int acpi_button_add_fs(struct acpi_device *device) } } - return 0; + return_VALUE(0); } static int acpi_button_remove_fs(struct acpi_device *device) { struct acpi_button *button = NULL; + ACPI_FUNCTION_TRACE("acpi_button_remove_fs"); button = acpi_driver_data(device); if (acpi_device_dir(device)) { @@ -245,7 +253,7 @@ static int acpi_button_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -256,9 +264,10 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) { struct acpi_button *button = (struct acpi_button *)data; + ACPI_FUNCTION_TRACE("acpi_button_notify"); if (!button || !button->device) - return; + return_VOID; switch (event) { case ACPI_BUTTON_NOTIFY_STATUS: @@ -271,20 +280,21 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) break; } - return; + return_VOID; } static acpi_status acpi_button_notify_fixed(void *data) { struct acpi_button *button = (struct acpi_button *)data; + ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); if (!button) - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); - return AE_OK; + return_ACPI_STATUS(AE_OK); } static int acpi_button_add(struct acpi_device *device) @@ -293,13 +303,14 @@ static int acpi_button_add(struct acpi_device *device) acpi_status status = AE_OK; struct acpi_button *button = NULL; + ACPI_FUNCTION_TRACE("acpi_button_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL); if (!button) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(button, 0, sizeof(struct acpi_button)); button->device = device; @@ -338,8 +349,8 @@ static int acpi_button_add(struct acpi_device *device) sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); } else { - printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", - acpi_device_hid(device)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", + acpi_device_hid(device))); result = -ENODEV; goto end; } @@ -370,6 +381,8 @@ static int acpi_button_add(struct acpi_device *device) } if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -393,7 +406,7 @@ static int acpi_button_add(struct acpi_device *device) kfree(button); } - return result; + return_VALUE(result); } static int acpi_button_remove(struct acpi_device *device, int type) @@ -401,9 +414,10 @@ static int acpi_button_remove(struct acpi_device *device, int type) acpi_status status = 0; struct acpi_button *button = NULL; + ACPI_FUNCTION_TRACE("acpi_button_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); button = acpi_driver_data(device); @@ -426,33 +440,39 @@ static int acpi_button_remove(struct acpi_device *device, int type) break; } + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); + acpi_button_remove_fs(device); kfree(button); - return 0; + return_VALUE(0); } static int __init acpi_button_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_button_init"); acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); if (!acpi_button_dir) - return -ENODEV; + return_VALUE(-ENODEV); acpi_button_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_button_driver); if (result < 0) { remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } static void __exit acpi_button_exit(void) { + ACPI_FUNCTION_TRACE("acpi_button_exit"); acpi_bus_unregister_driver(&acpi_button_driver); @@ -464,7 +484,7 @@ static void __exit acpi_button_exit(void) remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); - return; + return_VOID; } module_init(acpi_button_init); diff --git a/trunk/drivers/acpi/container.c b/trunk/drivers/acpi/container.c index 7f7e41d40a3b..b69a8cad82b7 100644 --- a/trunk/drivers/acpi/container.c +++ b/trunk/drivers/acpi/container.c @@ -73,16 +73,17 @@ static int is_device_present(acpi_handle handle) acpi_status status; unsigned long sta; + ACPI_FUNCTION_TRACE("is_device_present"); status = acpi_get_handle(handle, "_STA", &temp); if (ACPI_FAILURE(status)) - return 1; /* _STA not found, assmue device present */ + return_VALUE(1); /* _STA not found, assmue device present */ status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) - return 0; /* Firmware error */ + return_VALUE(0); /* Firmware error */ - return ((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT); + return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT); } /*******************************************************************/ @@ -90,15 +91,16 @@ static int acpi_container_add(struct acpi_device *device) { struct acpi_container *container; + ACPI_FUNCTION_TRACE("acpi_container_add"); if (!device) { - printk(KERN_ERR PREFIX "device is NULL\n"); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "device is NULL\n")); + return_VALUE(-EINVAL); } container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL); if (!container) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(container, 0, sizeof(struct acpi_container)); container->handle = device->handle; @@ -109,7 +111,7 @@ static int acpi_container_add(struct acpi_device *device) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", acpi_device_name(device), acpi_device_bid(device))); - return 0; + return_VALUE(0); } static int acpi_container_remove(struct acpi_device *device, int type) @@ -128,22 +130,23 @@ static int container_device_add(struct acpi_device **device, acpi_handle handle) struct acpi_device *pdev; int result; + ACPI_FUNCTION_TRACE("container_device_add"); if (acpi_get_parent(handle, &phandle)) { - return -ENODEV; + return_VALUE(-ENODEV); } if (acpi_bus_get_device(phandle, &pdev)) { - return -ENODEV; + return_VALUE(-ENODEV); } if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) { - return -ENODEV; + return_VALUE(-ENODEV); } result = acpi_bus_start(*device); - return result; + return_VALUE(result); } static void container_notify_cb(acpi_handle handle, u32 type, void *context) @@ -153,6 +156,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) int present; acpi_status status; + ACPI_FUNCTION_TRACE("container_notify_cb"); present = is_device_present(handle); @@ -188,7 +192,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) default: break; } - return; + return_VOID; } static acpi_status @@ -201,10 +205,11 @@ container_walk_namespace_cb(acpi_handle handle, acpi_status status; int *action = context; + ACPI_FUNCTION_TRACE("container_walk_namespace_cb"); status = acpi_get_object_info(handle, &buffer); if (ACPI_FAILURE(status) || !buffer.pointer) { - return AE_OK; + return_ACPI_STATUS(AE_OK); } info = buffer.pointer; @@ -238,7 +243,7 @@ container_walk_namespace_cb(acpi_handle handle, end: acpi_os_free(buffer.pointer); - return AE_OK; + return_ACPI_STATUS(AE_OK); } static int __init acpi_container_init(void) @@ -264,6 +269,7 @@ static void __exit acpi_container_exit(void) { int action = UNINSTALL_NOTIFY_HANDLER; + ACPI_FUNCTION_TRACE("acpi_container_exit"); acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, @@ -272,7 +278,7 @@ static void __exit acpi_container_exit(void) acpi_bus_unregister_driver(&acpi_container_driver); - return; + return_VOID; } module_init(acpi_container_init); diff --git a/trunk/drivers/acpi/debug.c b/trunk/drivers/acpi/debug.c index 35c6af8a83cd..263322b7d113 100644 --- a/trunk/drivers/acpi/debug.c +++ b/trunk/drivers/acpi/debug.c @@ -155,12 +155,13 @@ acpi_system_write_debug(struct file *file, { char debug_string[12] = { '\0' }; + ACPI_FUNCTION_TRACE("acpi_system_write_debug"); if (count > sizeof(debug_string) - 1) - return -EINVAL; + return_VALUE(-EINVAL); if (copy_from_user(debug_string, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); debug_string[count] = '\0'; @@ -172,10 +173,10 @@ acpi_system_write_debug(struct file *file, acpi_dbg_level = simple_strtoul(debug_string, NULL, 0); break; default: - return -EINVAL; + return_VALUE(-EINVAL); } - return count; + return_VALUE(count); } static int __init acpi_debug_init(void) @@ -184,9 +185,10 @@ static int __init acpi_debug_init(void) int error = 0; char *name; + ACPI_FUNCTION_TRACE("acpi_debug_init"); if (acpi_disabled) - return 0; + return_VALUE(0); /* 'debug_layer' [R/W] */ name = ACPI_SYSTEM_FILE_DEBUG_LAYER; @@ -211,12 +213,15 @@ static int __init acpi_debug_init(void) goto Error; Done: - return error; + return_VALUE(error); Error: + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' proc fs entry\n", name)); + remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir); remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir); - error = -ENODEV; + error = -EFAULT; goto Done; } diff --git a/trunk/drivers/acpi/dispatcher/dsinit.c b/trunk/drivers/acpi/dispatcher/dsinit.c index daf51b5b5875..bbdf990e9f65 100644 --- a/trunk/drivers/acpi/dispatcher/dsinit.c +++ b/trunk/drivers/acpi/dispatcher/dsinit.c @@ -125,7 +125,37 @@ acpi_ds_init_one_object(acpi_handle obj_handle, if (info->table_desc->pointer->revision == 1) { node->flags |= ANOBJ_DATA_WIDTH_32; } +#ifdef ACPI_INIT_PARSE_METHODS + /* + * Note 11/2005: Removed this code to parse all methods during table + * load because it causes problems if there are any errors during the + * parse. Also, it seems like overkill and we probably don't want to + * abort a table load because of an issue with a single method. + */ + + /* + * Print a dot for each method unless we are going to print + * the entire pathname + */ + if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ".")); + } + /* + * Always parse methods to detect errors, we will delete + * the parse tree below + */ + status = acpi_ds_parse_method(obj_handle); + if (ACPI_FAILURE(status)) { + ACPI_ERROR((AE_INFO, + "Method %p [%4.4s] - parse failure, %s", + obj_handle, + acpi_ut_get_node_name(obj_handle), + acpi_format_exception(status))); + + /* This parse failed, but we will continue parsing more methods */ + } +#endif info->method_count++; break; diff --git a/trunk/drivers/acpi/dispatcher/dsmethod.c b/trunk/drivers/acpi/dispatcher/dsmethod.c index a39a33f4847a..bc9aca4e7401 100644 --- a/trunk/drivers/acpi/dispatcher/dsmethod.c +++ b/trunk/drivers/acpi/dispatcher/dsmethod.c @@ -52,10 +52,6 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME("dsmethod") -/* Local prototypes */ -static acpi_status -acpi_ds_create_method_mutex(union acpi_operand_object *method_desc); - /******************************************************************************* * * FUNCTION: acpi_ds_method_error @@ -71,7 +67,6 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc); * Note: Allows the exception handler to change the status code * ******************************************************************************/ - acpi_status acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state) { @@ -116,53 +111,13 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state) return (status); } -/******************************************************************************* - * - * FUNCTION: acpi_ds_create_method_mutex - * - * PARAMETERS: obj_desc - The method object - * - * RETURN: Status - * - * DESCRIPTION: Create a mutex object for a serialized control method - * - ******************************************************************************/ - -static acpi_status -acpi_ds_create_method_mutex(union acpi_operand_object *method_desc) -{ - union acpi_operand_object *mutex_desc; - acpi_status status; - - ACPI_FUNCTION_NAME(ds_create_method_mutex); - - /* Create the new mutex object */ - - mutex_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX); - if (!mutex_desc) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - /* Create the actual OS Mutex */ - - status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - mutex_desc->mutex.sync_level = method_desc->method.sync_level; - method_desc->method.mutex = mutex_desc; - return_ACPI_STATUS(AE_OK); -} - /******************************************************************************* * * FUNCTION: acpi_ds_begin_method_execution * * PARAMETERS: method_node - Node of the method * obj_desc - The method object - * walk_state - current state, NULL if not yet executing - * a method. + * calling_method_node - Caller of this method (if non-null) * * RETURN: Status * @@ -173,9 +128,9 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc) ******************************************************************************/ acpi_status -acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, - union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state) +acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node, + union acpi_operand_object * obj_desc, + struct acpi_namespace_node * calling_method_node) { acpi_status status = AE_OK; @@ -194,80 +149,35 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, } /* - * If this method is serialized, we need to acquire the method mutex. + * If there is a concurrency limit on this method, we need to + * obtain a unit from the method semaphore. */ - if (obj_desc->method.method_flags & AML_METHOD_SERIALIZED) { - /* - * Create a mutex for the method if it is defined to be Serialized - * and a mutex has not already been created. We defer the mutex creation - * until a method is actually executed, to minimize the object count - */ - if (!obj_desc->method.mutex) { - status = acpi_ds_create_method_mutex(obj_desc); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - } - + if (obj_desc->method.semaphore) { /* - * The current_sync_level (per-thread) must be less than or equal to - * the sync level of the method. This mechanism provides some - * deadlock prevention + * Allow recursive method calls, up to the reentrancy/concurrency + * limit imposed by the SERIALIZED rule and the sync_level method + * parameter. * - * Top-level method invocation has no walk state at this point + * The point of this code is to avoid permanently blocking a + * thread that is making recursive method calls. */ - if (walk_state && - (walk_state->thread->current_sync_level > - obj_desc->method.mutex->mutex.sync_level)) { - ACPI_ERROR((AE_INFO, - "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)", - acpi_ut_get_node_name(method_node), - walk_state->thread->current_sync_level)); - - return_ACPI_STATUS(AE_AML_MUTEX_ORDER); + if (method_node == calling_method_node) { + if (obj_desc->method.thread_count >= + obj_desc->method.concurrency) { + return_ACPI_STATUS(AE_AML_METHOD_LIMIT); + } } /* - * Obtain the method mutex if necessary. Do not acquire mutex for a - * recursive call. + * Get a unit from the method semaphore. This releases the + * interpreter if we block (then reacquires it) */ - if (!walk_state || - !obj_desc->method.mutex->mutex.owner_thread || - (walk_state->thread != - obj_desc->method.mutex->mutex.owner_thread)) { - /* - * Acquire the method mutex. This releases the interpreter if we - * block (and reacquires it before it returns) - */ - status = - acpi_ex_system_wait_mutex(obj_desc->method.mutex-> - mutex.os_mutex, - ACPI_WAIT_FOREVER); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - - /* Update the mutex and walk info and save the original sync_level */ - - if (walk_state) { - obj_desc->method.mutex->mutex. - original_sync_level = - walk_state->thread->current_sync_level; - - obj_desc->method.mutex->mutex.owner_thread = - walk_state->thread; - walk_state->thread->current_sync_level = - obj_desc->method.sync_level; - } else { - obj_desc->method.mutex->mutex. - original_sync_level = - obj_desc->method.mutex->mutex.sync_level; - } + status = + acpi_ex_system_wait_semaphore(obj_desc->method.semaphore, + ACPI_WAIT_FOREVER); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - - /* Always increase acquisition depth */ - - obj_desc->method.mutex->mutex.acquisition_depth++; } /* @@ -290,10 +200,10 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, return_ACPI_STATUS(status); cleanup: - /* On error, must release the method mutex (if present) */ + /* On error, must signal the method semaphore if present */ - if (obj_desc->method.mutex) { - acpi_os_release_mutex(obj_desc->method.mutex->mutex.os_mutex); + if (obj_desc->method.semaphore) { + (void)acpi_os_signal_semaphore(obj_desc->method.semaphore, 1); } return_ACPI_STATUS(status); } @@ -343,10 +253,10 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, return_ACPI_STATUS(AE_NULL_OBJECT); } - /* Init for new method, possibly wait on method mutex */ + /* Init for new method, possibly wait on concurrency semaphore */ status = acpi_ds_begin_method_execution(method_node, obj_desc, - this_walk_state); + this_walk_state->method_node); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -568,8 +478,6 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, * created, delete all locals and arguments, and delete the parse * tree if requested. * - * MUTEX: Interpreter is locked - * ******************************************************************************/ void @@ -595,21 +503,26 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc, } /* - * If method is serialized, release the mutex and restore the - * current sync level for this thread + * Lock the parser while we terminate this method. + * If this is the last thread executing the method, + * we have additional cleanup to perform */ - if (method_desc->method.mutex) { + status = acpi_ut_acquire_mutex(ACPI_MTX_CONTROL_METHOD); + if (ACPI_FAILURE(status)) { + return_VOID; + } - /* Acquisition Depth handles recursive calls */ + /* Signal completion of the execution of this method if necessary */ - method_desc->method.mutex->mutex.acquisition_depth--; - if (!method_desc->method.mutex->mutex.acquisition_depth) { - walk_state->thread->current_sync_level = - method_desc->method.mutex->mutex. - original_sync_level; + if (method_desc->method.semaphore) { + status = + acpi_os_signal_semaphore(method_desc->method.semaphore, 1); + if (ACPI_FAILURE(status)) { + + /* Ignore error and continue */ - acpi_os_release_mutex(method_desc->method.mutex->mutex. - os_mutex); + ACPI_EXCEPTION((AE_INFO, status, + "Could not signal method semaphore")); } } @@ -624,7 +537,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc, status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - return_VOID; + goto exit; } /* @@ -667,16 +580,18 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc, /* * Support to dynamically change a method from not_serialized to * Serialized if it appears that the method is incorrectly written and - * does not support multiple thread execution. The best example of this - * is if such a method creates namespace objects and blocks. A second + * does not support multiple thread execution. The best example of this + * is if such a method creates namespace objects and blocks. A second * thread will fail with an AE_ALREADY_EXISTS exception * * This code is here because we must wait until the last thread exits * before creating the synchronization semaphore. */ - if ((method_desc->method.method_flags & AML_METHOD_SERIALIZED) - && (!method_desc->method.mutex)) { - status = acpi_ds_create_method_mutex(method_desc); + if ((method_desc->method.concurrency == 1) && + (!method_desc->method.semaphore)) { + status = acpi_os_create_semaphore(1, 1, + &method_desc->method. + semaphore); } /* No more threads, we can free the owner_id */ @@ -684,5 +599,144 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc, acpi_ut_release_owner_id(&method_desc->method.owner_id); } + exit: + (void)acpi_ut_release_mutex(ACPI_MTX_CONTROL_METHOD); return_VOID; } + +#ifdef ACPI_INIT_PARSE_METHODS + /* + * Note 11/2005: Removed this code to parse all methods during table + * load because it causes problems if there are any errors during the + * parse. Also, it seems like overkill and we probably don't want to + * abort a table load because of an issue with a single method. + */ + +/******************************************************************************* + * + * FUNCTION: acpi_ds_parse_method + * + * PARAMETERS: Node - Method node + * + * RETURN: Status + * + * DESCRIPTION: Parse the AML that is associated with the method. + * + * MUTEX: Assumes parser is locked + * + ******************************************************************************/ + +acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node) +{ + acpi_status status; + union acpi_operand_object *obj_desc; + union acpi_parse_object *op; + struct acpi_walk_state *walk_state; + + ACPI_FUNCTION_TRACE_PTR(ds_parse_method, node); + + /* Parameter Validation */ + + if (!node) { + return_ACPI_STATUS(AE_NULL_ENTRY); + } + + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "**** Parsing [%4.4s] **** NamedObj=%p\n", + acpi_ut_get_node_name(node), node)); + + /* Extract the method object from the method Node */ + + obj_desc = acpi_ns_get_attached_object(node); + if (!obj_desc) { + return_ACPI_STATUS(AE_NULL_OBJECT); + } + + /* Create a mutex for the method if there is a concurrency limit */ + + if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) && + (!obj_desc->method.semaphore)) { + status = acpi_os_create_semaphore(obj_desc->method.concurrency, + obj_desc->method.concurrency, + &obj_desc->method.semaphore); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + } + + /* + * Allocate a new parser op to be the root of the parsed + * method tree + */ + op = acpi_ps_alloc_op(AML_METHOD_OP); + if (!op) { + return_ACPI_STATUS(AE_NO_MEMORY); + } + + /* Init new op with the method name and pointer back to the Node */ + + acpi_ps_set_name(op, node->name.integer); + op->common.node = node; + + /* + * Get a new owner_id for objects created by this method. Namespace + * objects (such as Operation Regions) can be created during the + * first pass parse. + */ + status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); + if (ACPI_FAILURE(status)) { + goto cleanup; + } + + /* Create and initialize a new walk state */ + + walk_state = + acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL, + NULL); + if (!walk_state) { + status = AE_NO_MEMORY; + goto cleanup2; + } + + status = acpi_ds_init_aml_walk(walk_state, op, node, + obj_desc->method.aml_start, + obj_desc->method.aml_length, NULL, 1); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(walk_state); + goto cleanup2; + } + + /* + * Parse the method, first pass + * + * The first pass load is where newly declared named objects are added into + * the namespace. Actual evaluation of the named objects (what would be + * called a "second pass") happens during the actual execution of the + * method so that operands to the named objects can take on dynamic + * run-time values. + */ + status = acpi_ps_parse_aml(walk_state); + if (ACPI_FAILURE(status)) { + goto cleanup2; + } + + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "**** [%4.4s] Parsed **** NamedObj=%p Op=%p\n", + acpi_ut_get_node_name(node), node, op)); + + /* + * Delete the parse tree. We simply re-parse the method for every + * execution since there isn't much overhead (compared to keeping lots + * of parse trees around) + */ + acpi_ns_delete_namespace_subtree(node); + acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id); + + cleanup2: + acpi_ut_release_owner_id(&obj_desc->method.owner_id); + + cleanup: + acpi_ps_delete_parse_tree(op); + return_ACPI_STATUS(status); +} +#endif diff --git a/trunk/drivers/acpi/dispatcher/dswexec.c b/trunk/drivers/acpi/dispatcher/dswexec.c index b1ded62d0df1..3acbd9145d72 100644 --- a/trunk/drivers/acpi/dispatcher/dswexec.c +++ b/trunk/drivers/acpi/dispatcher/dswexec.c @@ -472,6 +472,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) acpi_ds_result_push(walk_state->result_obj, walk_state); } + break; default: @@ -509,7 +510,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Method Reference in a Package, Op=%p\n", op)); - op->common.node = (struct acpi_namespace_node *)op->asl.value. arg->asl.node->object; @@ -670,6 +670,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) status = acpi_ds_result_stack_pop(walk_state); } + break; case AML_TYPE_UNDEFINED: @@ -707,6 +708,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) * Check if we just completed the evaluation of a * conditional predicate */ + if ((ACPI_SUCCESS(status)) && (walk_state->control_state) && (walk_state->control_state->common.state == diff --git a/trunk/drivers/acpi/dispatcher/dswload.c b/trunk/drivers/acpi/dispatcher/dswload.c index e3ca7f6539c1..35074399c617 100644 --- a/trunk/drivers/acpi/dispatcher/dswload.c +++ b/trunk/drivers/acpi/dispatcher/dswload.c @@ -175,7 +175,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, if (status == AE_NOT_FOUND) { /* * Table disassembly: - * Target of Scope() not found. Generate an External for it, and + * Target of Scope() not found. Generate an External for it, and * insert the name into the namespace. */ acpi_dm_add_to_external_list(path, ACPI_TYPE_DEVICE, 0); @@ -210,15 +210,16 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, case ACPI_TYPE_BUFFER: /* - * These types we will allow, but we will change the type. This + * These types we will allow, but we will change the type. This * enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } * - * Note: silently change the type here. On the second pass, we will report + * Note: silently change the type here. On the second pass, we will report * a warning */ + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", path, @@ -241,6 +242,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, break; default: + /* * For all other named opcodes, we will enter the name into * the namespace. @@ -257,6 +259,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, * buffer_field, or Package), the name of the object is already * in the namespace. */ + if (walk_state->deferred_node) { /* This name is already in the namespace, get the node */ @@ -290,8 +293,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, } /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that * involve arguments to the opcode must be created as we go back up the * parse tree later. */ @@ -324,12 +327,12 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, (status); } } - status = AE_OK; } } if (ACPI_FAILURE(status)) { + ACPI_ERROR_NAMESPACE(path, status); return_ACPI_STATUS(status); } @@ -431,13 +434,9 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state) status = acpi_ex_create_region(op->named.data, op->named.length, - (acpi_adr_space_type) ((op-> - common. - value. - arg)-> - common. - value. - integer), + (acpi_adr_space_type) + ((op->common.value.arg)-> + common.value.integer), walk_state); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); @@ -475,7 +474,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state) * method_op pkg_length name_string method_flags term_list * * Note: We must create the method node/object pair as soon as we - * see the method declaration. This allows later pass1 parsing + * see the method declaration. This allows later pass1 parsing * of invocations of the method (need to know the number of * arguments.) */ @@ -500,7 +499,6 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state) length, walk_state); } - walk_state->operands[0] = NULL; walk_state->num_operands = 0; @@ -572,6 +570,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, #ifdef ACPI_ENABLE_MODULE_LEVEL_CODE if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || (walk_state->op_info->class == AML_CLASS_CONTROL)) { + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Begin/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, @@ -603,7 +602,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, } else { /* Get name from the op */ - buffer_ptr = ACPI_CAST_PTR(char, &op->named.name); + buffer_ptr = (char *)&op->named.name; } } else { /* Get the namestring from the raw AML */ @@ -630,6 +629,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, break; case AML_INT_NAMEPATH_OP: + /* * The name_path is an object reference to an existing object. * Don't enter the name into the namespace, but look it up @@ -642,6 +642,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, break; case AML_SCOPE_OP: + /* * The Path is an object reference to an existing object. * Don't enter the name into the namespace, but look it up @@ -663,7 +664,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, #endif return_ACPI_STATUS(status); } - /* * We must check to make sure that the target is * one of the opcodes that actually opens a scope @@ -683,12 +683,13 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, case ACPI_TYPE_BUFFER: /* - * These types we will allow, but we will change the type. This + * These types we will allow, but we will change the type. This * enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } */ + ACPI_WARNING((AE_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)", buffer_ptr, @@ -728,14 +729,14 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } - } + } return_ACPI_STATUS(AE_OK); } /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that * involve arguments to the opcode must be created as we go back up the * parse tree later. * @@ -786,6 +787,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, * can get it again quickly when this scope is closed */ op->common.node = node; + return_ACPI_STATUS(status); } @@ -920,6 +922,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) #ifndef ACPI_NO_METHOD_EXECUTION case AML_TYPE_CREATE_FIELD: + /* * Create the field object, but the field buffer and index must * be evaluated later during the execution phase @@ -928,6 +931,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) break; case AML_TYPE_NAMED_FIELD: + /* * If we are executing a method, initialize the field */ @@ -1047,7 +1051,6 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) * argument is the space_id. (We must save the address of the * AML of the address and length operands) */ - /* * If we have a valid region, initialize it * Namespace is NOT locked at this point. @@ -1077,7 +1080,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) * method_op pkg_length name_string method_flags term_list * * Note: We must create the method node/object pair as soon as we - * see the method declaration. This allows later pass1 parsing + * see the method declaration. This allows later pass1 parsing * of invocations of the method (need to know the number of * arguments.) */ diff --git a/trunk/drivers/acpi/dock.c b/trunk/drivers/acpi/dock.c deleted file mode 100644 index 510a94524298..000000000000 --- a/trunk/drivers/acpi/dock.c +++ /dev/null @@ -1,739 +0,0 @@ -/* - * dock.c - ACPI dock station driver - * - * Copyright (C) 2006 Kristen Carlson Accardi - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ - -#include -#include -#include -#include -#include -#include -#include - -#define ACPI_DOCK_DRIVER_NAME "ACPI Dock Station Driver" - -ACPI_MODULE_NAME("dock") -MODULE_AUTHOR("Kristen Carlson Accardi"); -MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME); -MODULE_LICENSE("GPL"); - -static struct atomic_notifier_head dock_notifier_list; - -struct dock_station { - acpi_handle handle; - unsigned long last_dock_time; - u32 flags; - spinlock_t dd_lock; - spinlock_t hp_lock; - struct list_head dependent_devices; - struct list_head hotplug_devices; -}; - -struct dock_dependent_device { - struct list_head list; - struct list_head hotplug_list; - acpi_handle handle; - acpi_notify_handler handler; - void *context; -}; - -#define DOCK_DOCKING 0x00000001 -#define DOCK_EVENT KOBJ_DOCK -#define UNDOCK_EVENT KOBJ_UNDOCK - -static struct dock_station *dock_station; - -/***************************************************************************** - * Dock Dependent device functions * - *****************************************************************************/ -/** - * alloc_dock_dependent_device - allocate and init a dependent device - * @handle: the acpi_handle of the dependent device - * - * Allocate memory for a dependent device structure for a device referenced - * by the acpi handle - */ -static struct dock_dependent_device * -alloc_dock_dependent_device(acpi_handle handle) -{ - struct dock_dependent_device *dd; - - dd = kzalloc(sizeof(*dd), GFP_KERNEL); - if (dd) { - dd->handle = handle; - INIT_LIST_HEAD(&dd->list); - INIT_LIST_HEAD(&dd->hotplug_list); - } - return dd; -} - -/** - * add_dock_dependent_device - associate a device with the dock station - * @ds: The dock station - * @dd: The dependent device - * - * Add the dependent device to the dock's dependent device list. - */ -static void -add_dock_dependent_device(struct dock_station *ds, - struct dock_dependent_device *dd) -{ - spin_lock(&ds->dd_lock); - list_add_tail(&dd->list, &ds->dependent_devices); - spin_unlock(&ds->dd_lock); -} - -/** - * dock_add_hotplug_device - associate a hotplug handler with the dock station - * @ds: The dock station - * @dd: The dependent device struct - * - * Add the dependent device to the dock's hotplug device list - */ -static void -dock_add_hotplug_device(struct dock_station *ds, - struct dock_dependent_device *dd) -{ - spin_lock(&ds->hp_lock); - list_add_tail(&dd->hotplug_list, &ds->hotplug_devices); - spin_unlock(&ds->hp_lock); -} - -/** - * dock_del_hotplug_device - remove a hotplug handler from the dock station - * @ds: The dock station - * @dd: the dependent device struct - * - * Delete the dependent device from the dock's hotplug device list - */ -static void -dock_del_hotplug_device(struct dock_station *ds, - struct dock_dependent_device *dd) -{ - spin_lock(&ds->hp_lock); - list_del(&dd->hotplug_list); - spin_unlock(&ds->hp_lock); -} - -/** - * find_dock_dependent_device - get a device dependent on this dock - * @ds: the dock station - * @handle: the acpi_handle of the device we want - * - * iterate over the dependent device list for this dock. If the - * dependent device matches the handle, return. - */ -static struct dock_dependent_device * -find_dock_dependent_device(struct dock_station *ds, acpi_handle handle) -{ - struct dock_dependent_device *dd; - - spin_lock(&ds->dd_lock); - list_for_each_entry(dd, &ds->dependent_devices, list) { - if (handle == dd->handle) { - spin_unlock(&ds->dd_lock); - return dd; - } - } - spin_unlock(&ds->dd_lock); - return NULL; -} - -/***************************************************************************** - * Dock functions * - *****************************************************************************/ -/** - * is_dock - see if a device is a dock station - * @handle: acpi handle of the device - * - * If an acpi object has a _DCK method, then it is by definition a dock - * station, so return true. - */ -static int is_dock(acpi_handle handle) -{ - acpi_status status; - acpi_handle tmp; - - status = acpi_get_handle(handle, "_DCK", &tmp); - if (ACPI_FAILURE(status)) - return 0; - return 1; -} - -/** - * is_dock_device - see if a device is on a dock station - * @handle: acpi handle of the device - * - * If this device is either the dock station itself, - * or is a device dependent on the dock station, then it - * is a dock device - */ -int is_dock_device(acpi_handle handle) -{ - if (!dock_station) - return 0; - - if (is_dock(handle) || find_dock_dependent_device(dock_station, handle)) - return 1; - - return 0; -} - -EXPORT_SYMBOL_GPL(is_dock_device); - -/** - * dock_present - see if the dock station is present. - * @ds: the dock station - * - * execute the _STA method. note that present does not - * imply that we are docked. - */ -static int dock_present(struct dock_station *ds) -{ - unsigned long sta; - acpi_status status; - - if (ds) { - status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta); - if (ACPI_SUCCESS(status) && sta) - return 1; - } - return 0; -} - - - -/** - * dock_create_acpi_device - add new devices to acpi - * @handle - handle of the device to add - * - * This function will create a new acpi_device for the given - * handle if one does not exist already. This should cause - * acpi to scan for drivers for the given devices, and call - * matching driver's add routine. - * - * Returns a pointer to the acpi_device corresponding to the handle. - */ -static struct acpi_device * dock_create_acpi_device(acpi_handle handle) -{ - struct acpi_device *device = NULL; - struct acpi_device *parent_device; - acpi_handle parent; - int ret; - - if (acpi_bus_get_device(handle, &device)) { - /* - * no device created for this object, - * so we should create one. - */ - acpi_get_parent(handle, &parent); - if (acpi_bus_get_device(parent, &parent_device)) - parent_device = NULL; - - ret = acpi_bus_add(&device, parent_device, handle, - ACPI_BUS_TYPE_DEVICE); - if (ret) { - pr_debug("error adding bus, %x\n", - -ret); - return NULL; - } - } - return device; -} - -/** - * dock_remove_acpi_device - remove the acpi_device struct from acpi - * @handle - the handle of the device to remove - * - * Tell acpi to remove the acpi_device. This should cause any loaded - * driver to have it's remove routine called. - */ -static void dock_remove_acpi_device(acpi_handle handle) -{ - struct acpi_device *device; - int ret; - - if (!acpi_bus_get_device(handle, &device)) { - ret = acpi_bus_trim(device, 1); - if (ret) - pr_debug("error removing bus, %x\n", -ret); - } -} - - -/** - * hotplug_dock_devices - insert or remove devices on the dock station - * @ds: the dock station - * @event: either bus check or eject request - * - * Some devices on the dock station need to have drivers called - * to perform hotplug operations after a dock event has occurred. - * Traverse the list of dock devices that have registered a - * hotplug handler, and call the handler. - */ -static void hotplug_dock_devices(struct dock_station *ds, u32 event) -{ - struct dock_dependent_device *dd; - - spin_lock(&ds->hp_lock); - - /* - * First call driver specific hotplug functions - */ - list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) { - if (dd->handler) - dd->handler(dd->handle, event, dd->context); - } - - /* - * Now make sure that an acpi_device is created for each - * dependent device, or removed if this is an eject request. - * This will cause acpi_drivers to be stopped/started if they - * exist - */ - list_for_each_entry(dd, &ds->dependent_devices, list) { - if (event == ACPI_NOTIFY_EJECT_REQUEST) - dock_remove_acpi_device(dd->handle); - else - dock_create_acpi_device(dd->handle); - } - spin_unlock(&ds->hp_lock); -} - -static void dock_event(struct dock_station *ds, u32 event, int num) -{ - struct acpi_device *device; - - device = dock_create_acpi_device(ds->handle); - if (device) - kobject_uevent(&device->kobj, num); -} - -/** - * eject_dock - respond to a dock eject request - * @ds: the dock station - * - * This is called after _DCK is called, to execute the dock station's - * _EJ0 method. - */ -static void eject_dock(struct dock_station *ds) -{ - struct acpi_object_list arg_list; - union acpi_object arg; - acpi_status status; - acpi_handle tmp; - - /* all dock devices should have _EJ0, but check anyway */ - status = acpi_get_handle(ds->handle, "_EJ0", &tmp); - if (ACPI_FAILURE(status)) { - pr_debug("No _EJ0 support for dock device\n"); - return; - } - - arg_list.count = 1; - arg_list.pointer = &arg; - arg.type = ACPI_TYPE_INTEGER; - arg.integer.value = 1; - - if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0", - &arg_list, NULL))) - pr_debug("Failed to evaluate _EJ0!\n"); -} - -/** - * handle_dock - handle a dock event - * @ds: the dock station - * @dock: to dock, or undock - that is the question - * - * Execute the _DCK method in response to an acpi event - */ -static void handle_dock(struct dock_station *ds, int dock) -{ - acpi_status status; - struct acpi_object_list arg_list; - union acpi_object arg; - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; - struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *obj; - - acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &name_buffer); - obj = name_buffer.pointer; - - printk(KERN_INFO PREFIX "%s\n", dock ? "docking" : "undocking"); - - /* _DCK method has one argument */ - arg_list.count = 1; - arg_list.pointer = &arg; - arg.type = ACPI_TYPE_INTEGER; - arg.integer.value = dock; - status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer); - if (ACPI_FAILURE(status)) - pr_debug("%s: failed to execute _DCK\n", obj->string.pointer); - kfree(buffer.pointer); - kfree(name_buffer.pointer); -} - -static inline void dock(struct dock_station *ds) -{ - handle_dock(ds, 1); -} - -static inline void undock(struct dock_station *ds) -{ - handle_dock(ds, 0); -} - -static inline void begin_dock(struct dock_station *ds) -{ - ds->flags |= DOCK_DOCKING; -} - -static inline void complete_dock(struct dock_station *ds) -{ - ds->flags &= ~(DOCK_DOCKING); - ds->last_dock_time = jiffies; -} - -/** - * dock_in_progress - see if we are in the middle of handling a dock event - * @ds: the dock station - * - * Sometimes while docking, false dock events can be sent to the driver - * because good connections aren't made or some other reason. Ignore these - * if we are in the middle of doing something. - */ -static int dock_in_progress(struct dock_station *ds) -{ - if ((ds->flags & DOCK_DOCKING) || - time_before(jiffies, (ds->last_dock_time + HZ))) - return 1; - return 0; -} - -/** - * register_dock_notifier - add yourself to the dock notifier list - * @nb: the callers notifier block - * - * If a driver wishes to be notified about dock events, they can - * use this function to put a notifier block on the dock notifier list. - * this notifier call chain will be called after a dock event, but - * before hotplugging any new devices. - */ -int register_dock_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&dock_notifier_list, nb); -} - -EXPORT_SYMBOL_GPL(register_dock_notifier); - -/** - * unregister_dock_notifier - remove yourself from the dock notifier list - * @nb: the callers notifier block - */ -void unregister_dock_notifier(struct notifier_block *nb) -{ - atomic_notifier_chain_unregister(&dock_notifier_list, nb); -} - -EXPORT_SYMBOL_GPL(unregister_dock_notifier); - -/** - * register_hotplug_dock_device - register a hotplug function - * @handle: the handle of the device - * @handler: the acpi_notifier_handler to call after docking - * @context: device specific data - * - * If a driver would like to perform a hotplug operation after a dock - * event, they can register an acpi_notifiy_handler to be called by - * the dock driver after _DCK is executed. - */ -int -register_hotplug_dock_device(acpi_handle handle, acpi_notify_handler handler, - void *context) -{ - struct dock_dependent_device *dd; - - if (!dock_station) - return -ENODEV; - - /* - * make sure this handle is for a device dependent on the dock, - * this would include the dock station itself - */ - dd = find_dock_dependent_device(dock_station, handle); - if (dd) { - dd->handler = handler; - dd->context = context; - dock_add_hotplug_device(dock_station, dd); - return 0; - } - - return -EINVAL; -} - -EXPORT_SYMBOL_GPL(register_hotplug_dock_device); - -/** - * unregister_hotplug_dock_device - remove yourself from the hotplug list - * @handle: the acpi handle of the device - */ -void unregister_hotplug_dock_device(acpi_handle handle) -{ - struct dock_dependent_device *dd; - - if (!dock_station) - return; - - dd = find_dock_dependent_device(dock_station, handle); - if (dd) - dock_del_hotplug_device(dock_station, dd); -} - -EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); - -/** - * dock_notify - act upon an acpi dock notification - * @handle: the dock station handle - * @event: the acpi event - * @data: our driver data struct - * - * If we are notified to dock, then check to see if the dock is - * present and then dock. Notify all drivers of the dock event, - * and then hotplug and devices that may need hotplugging. For undock - * check to make sure the dock device is still present, then undock - * and hotremove all the devices that may need removing. - */ -static void dock_notify(acpi_handle handle, u32 event, void *data) -{ - struct dock_station *ds = (struct dock_station *)data; - - switch (event) { - case ACPI_NOTIFY_BUS_CHECK: - if (!dock_in_progress(ds) && dock_present(ds)) { - begin_dock(ds); - dock(ds); - if (!dock_present(ds)) { - printk(KERN_ERR PREFIX "Unable to dock!\n"); - break; - } - atomic_notifier_call_chain(&dock_notifier_list, - event, NULL); - hotplug_dock_devices(ds, event); - complete_dock(ds); - dock_event(ds, event, DOCK_EVENT); - } - break; - case ACPI_NOTIFY_DEVICE_CHECK: - /* - * According to acpi spec 3.0a, if a DEVICE_CHECK notification - * is sent and _DCK is present, it is assumed to mean an - * undock request. This notify routine will only be called - * for objects defining _DCK, so we will fall through to eject - * request here. However, we will pass an eject request through - * to the driver who wish to hotplug. - */ - case ACPI_NOTIFY_EJECT_REQUEST: - if (!dock_in_progress(ds) && dock_present(ds)) { - /* - * here we need to generate the undock - * event prior to actually doing the undock - * so that the device struct still exists. - */ - dock_event(ds, event, UNDOCK_EVENT); - hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); - undock(ds); - eject_dock(ds); - if (dock_present(ds)) - printk(KERN_ERR PREFIX "Unable to undock!\n"); - } - break; - default: - printk(KERN_ERR PREFIX "Unknown dock event %d\n", event); - } -} - -/** - * find_dock_devices - find devices on the dock station - * @handle: the handle of the device we are examining - * @lvl: unused - * @context: the dock station private data - * @rv: unused - * - * This function is called by acpi_walk_namespace. It will - * check to see if an object has an _EJD method. If it does, then it - * will see if it is dependent on the dock station. - */ -static acpi_status -find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) -{ - acpi_status status; - acpi_handle tmp; - struct dock_station *ds = (struct dock_station *)context; - struct dock_dependent_device *dd; - - status = acpi_bus_get_ejd(handle, &tmp); - if (ACPI_FAILURE(status)) - return AE_OK; - - if (tmp == ds->handle) { - dd = alloc_dock_dependent_device(handle); - if (dd) - add_dock_dependent_device(ds, dd); - } - - return AE_OK; -} - -/** - * dock_add - add a new dock station - * @handle: the dock station handle - * - * allocated and initialize a new dock station device. Find all devices - * that are on the dock station, and register for dock event notifications. - */ -static int dock_add(acpi_handle handle) -{ - int ret; - acpi_status status; - struct dock_dependent_device *dd; - - /* allocate & initialize the dock_station private data */ - dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL); - if (!dock_station) - return -ENOMEM; - dock_station->handle = handle; - dock_station->last_dock_time = jiffies - HZ; - INIT_LIST_HEAD(&dock_station->dependent_devices); - INIT_LIST_HEAD(&dock_station->hotplug_devices); - spin_lock_init(&dock_station->dd_lock); - spin_lock_init(&dock_station->hp_lock); - - /* Find dependent devices */ - acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, find_dock_devices, dock_station, - NULL); - - /* add the dock station as a device dependent on itself */ - dd = alloc_dock_dependent_device(handle); - if (!dd) { - kfree(dock_station); - return -ENOMEM; - } - add_dock_dependent_device(dock_station, dd); - - /* register for dock events */ - status = acpi_install_notify_handler(dock_station->handle, - ACPI_SYSTEM_NOTIFY, - dock_notify, dock_station); - - if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX "Error installing notify handler\n"); - ret = -ENODEV; - goto dock_add_err; - } - - printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_NAME); - - return 0; - -dock_add_err: - kfree(dock_station); - kfree(dd); - return ret; -} - -/** - * dock_remove - free up resources related to the dock station - */ -static int dock_remove(void) -{ - struct dock_dependent_device *dd, *tmp; - acpi_status status; - - if (!dock_station) - return 0; - - /* remove dependent devices */ - list_for_each_entry_safe(dd, tmp, &dock_station->dependent_devices, - list) - kfree(dd); - - /* remove dock notify handler */ - status = acpi_remove_notify_handler(dock_station->handle, - ACPI_SYSTEM_NOTIFY, - dock_notify); - if (ACPI_FAILURE(status)) - printk(KERN_ERR "Error removing notify handler\n"); - - /* free dock station memory */ - kfree(dock_station); - return 0; -} - -/** - * find_dock - look for a dock station - * @handle: acpi handle of a device - * @lvl: unused - * @context: counter of dock stations found - * @rv: unused - * - * This is called by acpi_walk_namespace to look for dock stations. - */ -static acpi_status -find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) -{ - int *count = (int *)context; - acpi_status status = AE_OK; - - if (is_dock(handle)) { - if (dock_add(handle) >= 0) { - (*count)++; - status = AE_CTRL_TERMINATE; - } - } - return status; -} - -static int __init dock_init(void) -{ - int num = 0; - - dock_station = NULL; - - /* look for a dock station */ - acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, find_dock, &num, NULL); - - if (!num) - return -ENODEV; - - return 0; -} - -static void __exit dock_exit(void) -{ - dock_remove(); -} - -postcore_initcall(dock_init); -module_exit(dock_exit); diff --git a/trunk/drivers/acpi/ec.c b/trunk/drivers/acpi/ec.c index 8c5d7df7d343..18b3ea9dace2 100644 --- a/trunk/drivers/acpi/ec.c +++ b/trunk/drivers/acpi/ec.c @@ -207,15 +207,16 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_ec_wait"); ec->intr.expect_event = event; smp_mb(); switch (event) { case ACPI_EC_EVENT_IBE: - if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) { + if (~acpi_ec_read_status(ec) & event) { ec->intr.expect_event = 0; - return 0; + return_VALUE(0); } break; default: @@ -237,16 +238,16 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event) switch (event) { case ACPI_EC_EVENT_OBF: if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF) - return 0; + return_VALUE(0); break; case ACPI_EC_EVENT_IBE: if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) - return 0; + return_VALUE(0); break; } - return -ETIME; + return_VALUE(-ETIME); } #ifdef ACPI_FUTURE_USAGE @@ -259,6 +260,7 @@ int acpi_ec_enter_burst_mode(union acpi_ec *ec) u32 tmp = 0; int status = 0; + ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode"); status = acpi_ec_read_status(ec); if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { @@ -270,21 +272,22 @@ int acpi_ec_enter_burst_mode(union acpi_ec *ec) status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); if (tmp != 0x90) { /* Burst ACK byte */ - return -EINVAL; + return_VALUE(-EINVAL); } } atomic_set(&ec->intr.leaving_burst, 0); - return 0; + return_VALUE(0); end: - ACPI_EXCEPTION ((AE_INFO, status, "EC wait, burst mode"); - return -1; + printk(KERN_WARNING PREFIX "Error in acpi_ec_wait\n"); + return_VALUE(-1); } int acpi_ec_leave_burst_mode(union acpi_ec *ec) { int status = 0; + ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); status = acpi_ec_read_status(ec); if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ @@ -295,10 +298,10 @@ int acpi_ec_leave_burst_mode(union acpi_ec *ec) acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); } atomic_set(&ec->intr.leaving_burst, 1); - return 0; + return_VALUE(0); end: - ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"); - return -1; + printk(KERN_WARNING PREFIX "leave burst_mode:error\n"); + return_VALUE(-1); } #endif /* ACPI_FUTURE_USAGE */ @@ -322,16 +325,17 @@ static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data) int result = 0; u32 glk = 0; + ACPI_FUNCTION_TRACE("acpi_ec_read"); if (!ec || !data) - return -EINVAL; + return_VALUE(-EINVAL); *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); } if (down_interruptible(&ec->poll.sem)) { @@ -361,7 +365,7 @@ static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data) if (ec->common.global_lock) acpi_release_global_lock(glk); - return result; + return_VALUE(result); } static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data) @@ -370,14 +374,15 @@ static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data) acpi_status status = AE_OK; u32 glk = 0; + ACPI_FUNCTION_TRACE("acpi_ec_write"); if (!ec) - return -EINVAL; + return_VALUE(-EINVAL); if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); } if (down_interruptible(&ec->poll.sem)) { @@ -410,7 +415,7 @@ static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data) if (ec->common.global_lock) acpi_release_global_lock(glk); - return result; + return_VALUE(result); } static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data) @@ -418,16 +423,17 @@ static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data) int status = 0; u32 glk; + ACPI_FUNCTION_TRACE("acpi_ec_read"); if (!ec || !data) - return -EINVAL; + return_VALUE(-EINVAL); *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); } WARN_ON(in_interrupt()); @@ -461,7 +467,7 @@ static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data) if (ec->common.global_lock) acpi_release_global_lock(glk); - return status; + return_VALUE(status); } static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data) @@ -469,14 +475,15 @@ static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data) int status = 0; u32 glk; + ACPI_FUNCTION_TRACE("acpi_ec_write"); if (!ec) - return -EINVAL; + return_VALUE(-EINVAL); if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); } WARN_ON(in_interrupt()); @@ -509,7 +516,7 @@ static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data) if (ec->common.global_lock) acpi_release_global_lock(glk); - return status; + return_VALUE(status); } /* @@ -567,16 +574,17 @@ static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data) acpi_status status = AE_OK; u32 glk = 0; + ACPI_FUNCTION_TRACE("acpi_ec_query"); if (!ec || !data) - return -EINVAL; + return_VALUE(-EINVAL); *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); } /* @@ -605,22 +613,23 @@ static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data) if (ec->common.global_lock) acpi_release_global_lock(glk); - return result; + return_VALUE(result); } static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data) { int status = 0; u32 glk; + ACPI_FUNCTION_TRACE("acpi_ec_query"); if (!ec || !data) - return -EINVAL; + return_VALUE(-EINVAL); *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); } down(&ec->intr.sem); @@ -653,7 +662,7 @@ static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data) if (ec->common.global_lock) acpi_release_global_lock(glk); - return status; + return_VALUE(status); } /* -------------------------------------------------------------------------- @@ -682,12 +691,13 @@ static void acpi_ec_gpe_poll_query(void *ec_cxt) '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); if (!ec_cxt) goto end; if (down_interruptible (&ec->poll.sem)) { - return; + return_VOID; } acpi_hw_low_level_read(8, &value, &ec->common.command_addr); up(&ec->poll.sem); @@ -724,6 +734,7 @@ static void acpi_ec_gpe_intr_query(void *ec_cxt) '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) result = acpi_ec_query(ec, &value); @@ -782,15 +793,12 @@ static u32 acpi_ec_gpe_intr_handler(void *data) case ACPI_EC_EVENT_OBF: if (!(value & ACPI_EC_FLAG_OBF)) break; - ec->intr.expect_event = 0; - wake_up(&ec->intr.wait); - break; case ACPI_EC_EVENT_IBE: if ((value & ACPI_EC_FLAG_IBF)) break; ec->intr.expect_event = 0; wake_up(&ec->intr.wait); - break; + return ACPI_INTERRUPT_HANDLED; default: break; } @@ -838,14 +846,15 @@ acpi_ec_space_handler(u32 function, acpi_integer f_v = 0; int i = 0; + ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); if ((address > 0xFF) || !value || !handler_context) - return AE_BAD_PARAMETER; + return_VALUE(AE_BAD_PARAMETER); if (bit_width != 8 && acpi_strict) { printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n"); - return AE_BAD_PARAMETER; + return_VALUE(AE_BAD_PARAMETER); } ec = (union acpi_ec *)handler_context; @@ -884,16 +893,16 @@ acpi_ec_space_handler(u32 function, out: switch (result) { case -EINVAL: - return AE_BAD_PARAMETER; + return_VALUE(AE_BAD_PARAMETER); break; case -ENODEV: - return AE_NOT_FOUND; + return_VALUE(AE_NOT_FOUND); break; case -ETIME: - return AE_TIME; + return_VALUE(AE_TIME); break; default: - return AE_OK; + return_VALUE(AE_OK); } } @@ -907,6 +916,7 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset) { union acpi_ec *ec = (union acpi_ec *)seq->private; + ACPI_FUNCTION_TRACE("acpi_ec_read_info"); if (!ec) goto end; @@ -921,7 +931,7 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset) acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); end: - return 0; + return_VALUE(0); } static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) @@ -941,29 +951,33 @@ static int acpi_ec_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; + ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_ec_dir); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); } entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Unable to create '%s' fs entry\n", + ACPI_EC_FILE_INFO)); else { entry->proc_fops = &acpi_ec_info_ops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return 0; + return_VALUE(0); } static int acpi_ec_remove_fs(struct acpi_device *device) { + ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); if (acpi_device_dir(device)) { remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device)); @@ -971,7 +985,7 @@ static int acpi_ec_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -984,13 +998,14 @@ static int acpi_ec_poll_add(struct acpi_device *device) acpi_status status = AE_OK; union acpi_ec *ec = NULL; + ACPI_FUNCTION_TRACE("acpi_ec_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); if (!ec) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(ec, 0, sizeof(union acpi_ec)); ec->common.handle = device->handle; @@ -1023,7 +1038,8 @@ static int acpi_ec_poll_add(struct acpi_device *device) acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error obtaining GPE bit assignment\n")); result = -ENODEV; goto end; } @@ -1043,7 +1059,7 @@ static int acpi_ec_poll_add(struct acpi_device *device) if (result) kfree(ec); - return result; + return_VALUE(result); } static int acpi_ec_intr_add(struct acpi_device *device) { @@ -1051,13 +1067,14 @@ static int acpi_ec_intr_add(struct acpi_device *device) acpi_status status = AE_OK; union acpi_ec *ec = NULL; + ACPI_FUNCTION_TRACE("acpi_ec_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); if (!ec) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(ec, 0, sizeof(union acpi_ec)); ec->common.handle = device->handle; @@ -1093,7 +1110,8 @@ static int acpi_ec_intr_add(struct acpi_device *device) acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX "Obtaining GPE bit assignment\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error obtaining GPE bit assignment\n")); result = -ENODEV; goto end; } @@ -1113,16 +1131,17 @@ static int acpi_ec_intr_add(struct acpi_device *device) if (result) kfree(ec); - return result; + return_VALUE(result); } static int acpi_ec_remove(struct acpi_device *device, int type) { union acpi_ec *ec = NULL; + ACPI_FUNCTION_TRACE("acpi_ec_remove"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); ec = acpi_driver_data(device); @@ -1130,7 +1149,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type) kfree(ec); - return 0; + return_VALUE(0); } static acpi_status @@ -1169,14 +1188,15 @@ static int acpi_ec_start(struct acpi_device *device) acpi_status status = AE_OK; union acpi_ec *ec = NULL; + ACPI_FUNCTION_TRACE("acpi_ec_start"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); ec = acpi_driver_data(device); if (!ec) - return -EINVAL; + return_VALUE(-EINVAL); /* * Get I/O port addresses. Convert to GAS format. @@ -1185,8 +1205,9 @@ static int acpi_ec_start(struct acpi_device *device) acpi_ec_io_ports, ec); if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) { - printk(KERN_ERR PREFIX "Error getting I/O port addresses\n"); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error getting I/O port addresses")); + return_VALUE(-ENODEV); } ec->common.status_addr = ec->common.command_addr; @@ -1203,7 +1224,7 @@ static int acpi_ec_start(struct acpi_device *device) ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); if (ACPI_FAILURE(status)) { - return -ENODEV; + return_VALUE(-ENODEV); } acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); @@ -1215,10 +1236,10 @@ static int acpi_ec_start(struct acpi_device *device) if (ACPI_FAILURE(status)) { acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); - return -ENODEV; + return_VALUE(-ENODEV); } - return AE_OK; + return_VALUE(AE_OK); } static int acpi_ec_stop(struct acpi_device *device, int type) @@ -1226,9 +1247,10 @@ static int acpi_ec_stop(struct acpi_device *device, int type) acpi_status status = AE_OK; union acpi_ec *ec = NULL; + ACPI_FUNCTION_TRACE("acpi_ec_stop"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); ec = acpi_driver_data(device); @@ -1236,15 +1258,15 @@ static int acpi_ec_stop(struct acpi_device *device, int type) ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); - return 0; + return_VALUE(0); } static acpi_status __init @@ -1514,22 +1536,23 @@ static int __init acpi_ec_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_ec_init"); if (acpi_disabled) - return 0; + return_VALUE(0); acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir); if (!acpi_ec_dir) - return -ENODEV; + return_VALUE(-ENODEV); /* Now register the driver for the EC */ result = acpi_bus_register_driver(&acpi_ec_driver); if (result < 0) { remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return result; + return_VALUE(result); } subsys_initcall(acpi_ec_init); @@ -1538,12 +1561,13 @@ subsys_initcall(acpi_ec_init); #if 0 static void __exit acpi_ec_exit(void) { + ACPI_FUNCTION_TRACE("acpi_ec_exit"); acpi_bus_unregister_driver(&acpi_ec_driver); remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); - return; + return_VOID; } #endif /* 0 */ diff --git a/trunk/drivers/acpi/event.c b/trunk/drivers/acpi/event.c index a901b23e95e7..2dbb1b0f11d5 100644 --- a/trunk/drivers/acpi/event.c +++ b/trunk/drivers/acpi/event.c @@ -48,17 +48,18 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count, static int chars_remaining = 0; static char *ptr; + ACPI_FUNCTION_TRACE("acpi_system_read_event"); if (!chars_remaining) { memset(&event, 0, sizeof(struct acpi_bus_event)); if ((file->f_flags & O_NONBLOCK) && (list_empty(&acpi_bus_event_list))) - return -EAGAIN; + return_VALUE(-EAGAIN); result = acpi_bus_receive_event(&event); if (result) - return result; + return_VALUE(result); chars_remaining = sprintf(str, "%s %s %08x %08x\n", event.device_class ? event. @@ -74,13 +75,13 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count, } if (copy_to_user(buffer, ptr, count)) - return -EFAULT; + return_VALUE(-EFAULT); *ppos += count; chars_remaining -= count; ptr += count; - return count; + return_VALUE(count); } static int acpi_system_close_event(struct inode *inode, struct file *file) @@ -111,18 +112,22 @@ static int __init acpi_event_init(void) struct proc_dir_entry *entry; int error = 0; + ACPI_FUNCTION_TRACE("acpi_event_init"); if (acpi_disabled) - return 0; + return_VALUE(0); /* 'event' [R] */ entry = create_proc_entry("event", S_IRUSR, acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_event_ops; else { - error = -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' proc fs entry\n", + "event")); + error = -EFAULT; } - return error; + return_VALUE(error); } subsys_initcall(acpi_event_init); diff --git a/trunk/drivers/acpi/events/evgpe.c b/trunk/drivers/acpi/events/evgpe.c index c76c0583ca6a..f01d339407f8 100644 --- a/trunk/drivers/acpi/events/evgpe.c +++ b/trunk/drivers/acpi/events/evgpe.c @@ -382,6 +382,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) u32 status_reg; u32 enable_reg; acpi_cpu_flags flags; + acpi_cpu_flags hw_flags; acpi_native_uint i; acpi_native_uint j; @@ -393,11 +394,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) return (int_status); } - /* - * We need to obtain the GPE lock for both the data structs and registers - * Note: Not necessary to obtain the hardware lock, since the GPE registers - * are owned by the gpe_lock. - */ + /* We need to hold the GPE lock now, hardware lock in the loop */ + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); /* Examine all GPE blocks attached to this interrupt level */ @@ -415,6 +413,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) gpe_register_info = &gpe_block->register_info[i]; + hw_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); + /* Read the Status Register */ status = @@ -423,6 +423,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) &gpe_register_info-> status_address); if (ACPI_FAILURE(status)) { + acpi_os_release_lock(acpi_gbl_hardware_lock, + hw_flags); goto unlock_and_exit; } @@ -433,6 +435,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) &enable_reg, &gpe_register_info-> enable_address); + acpi_os_release_lock(acpi_gbl_hardware_lock, hw_flags); + if (ACPI_FAILURE(status)) { goto unlock_and_exit; } diff --git a/trunk/drivers/acpi/events/evxface.c b/trunk/drivers/acpi/events/evxface.c index 4f948df17ab9..76c34a66e0e0 100644 --- a/trunk/drivers/acpi/events/evxface.c +++ b/trunk/drivers/acpi/events/evxface.c @@ -414,13 +414,12 @@ acpi_remove_notify_handler(acpi_handle device, if ((!device) || (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { - status = AE_BAD_PARAMETER; - goto exit; + return_ACPI_STATUS(AE_BAD_PARAMETER); } status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - goto exit; + return_ACPI_STATUS(status); } /* Convert and validate the device handle */ @@ -428,7 +427,7 @@ acpi_remove_notify_handler(acpi_handle device, node = acpi_ns_map_handle_to_node(device); if (!node) { status = AE_BAD_PARAMETER; - goto unlock; + goto unlock_and_exit; } /* Root Object */ @@ -442,7 +441,7 @@ acpi_remove_notify_handler(acpi_handle device, ((handler_type & ACPI_DEVICE_NOTIFY) && !acpi_gbl_device_notify.handler)) { status = AE_NOT_EXIST; - goto unlock; + goto unlock_and_exit; } /* Make sure all deferred tasks are completed */ @@ -451,7 +450,7 @@ acpi_remove_notify_handler(acpi_handle device, acpi_os_wait_events_complete(NULL); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - goto exit; + return_ACPI_STATUS(status); } if (handler_type & ACPI_SYSTEM_NOTIFY) { @@ -474,7 +473,7 @@ acpi_remove_notify_handler(acpi_handle device, if (!acpi_ev_is_notify_object(node)) { status = AE_TYPE; - goto unlock; + goto unlock_and_exit; } /* Check for an existing internal object */ @@ -482,7 +481,7 @@ acpi_remove_notify_handler(acpi_handle device, obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { status = AE_NOT_EXIST; - goto unlock; + goto unlock_and_exit; } /* Object exists - make sure there's an existing handler */ @@ -492,7 +491,7 @@ acpi_remove_notify_handler(acpi_handle device, if ((!notify_obj) || (notify_obj->notify.handler != handler)) { status = AE_BAD_PARAMETER; - goto unlock; + goto unlock_and_exit; } /* Make sure all deferred tasks are completed */ @@ -500,7 +499,7 @@ acpi_remove_notify_handler(acpi_handle device, acpi_os_wait_events_complete(NULL); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - goto exit; + return_ACPI_STATUS(status); } /* Remove the handler */ @@ -513,7 +512,7 @@ acpi_remove_notify_handler(acpi_handle device, if ((!notify_obj) || (notify_obj->notify.handler != handler)) { status = AE_BAD_PARAMETER; - goto unlock; + goto unlock_and_exit; } /* Make sure all deferred tasks are completed */ @@ -521,7 +520,7 @@ acpi_remove_notify_handler(acpi_handle device, acpi_os_wait_events_complete(NULL); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - goto exit; + return_ACPI_STATUS(status); } /* Remove the handler */ @@ -530,11 +529,8 @@ acpi_remove_notify_handler(acpi_handle device, } } -unlock: + unlock_and_exit: (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); -exit: - if (ACPI_FAILURE(status)) - ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler")); return_ACPI_STATUS(status); } @@ -572,13 +568,12 @@ acpi_install_gpe_handler(acpi_handle gpe_device, /* Parameter validation */ if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) { - status = AE_BAD_PARAMETER; - goto exit; + return_ACPI_STATUS(AE_BAD_PARAMETER); } status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); if (ACPI_FAILURE(status)) { - goto exit; + return_ACPI_STATUS(status); } /* Ensure that we have a valid GPE number */ @@ -586,7 +581,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); if (!gpe_event_info) { status = AE_BAD_PARAMETER; - goto unlock; + goto unlock_and_exit; } /* Make sure that there isn't a handler there already */ @@ -594,7 +589,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { status = AE_ALREADY_EXISTS; - goto unlock; + goto unlock_and_exit; } /* Allocate and init handler object */ @@ -602,7 +597,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info)); if (!handler) { status = AE_NO_MEMORY; - goto unlock; + goto unlock_and_exit; } handler->address = address; @@ -613,7 +608,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, status = acpi_ev_disable_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - goto unlock; + goto unlock_and_exit; } /* Install the handler */ @@ -628,12 +623,8 @@ acpi_install_gpe_handler(acpi_handle gpe_device, acpi_os_release_lock(acpi_gbl_gpe_lock, flags); -unlock: + unlock_and_exit: (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); -exit: - if (ACPI_FAILURE(status)) - ACPI_EXCEPTION((AE_INFO, status, - "Installing notify handler failed")); return_ACPI_STATUS(status); } diff --git a/trunk/drivers/acpi/executer/exconfig.c b/trunk/drivers/acpi/executer/exconfig.c index 83fed079a276..823352435e08 100644 --- a/trunk/drivers/acpi/executer/exconfig.c +++ b/trunk/drivers/acpi/executer/exconfig.c @@ -266,10 +266,6 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state, } } - ACPI_INFO((AE_INFO, - "Dynamic OEM Table Load - [%4.4s] OemId [%6.6s] OemTableId [%8.8s]", - table->signature, table->oem_id, table->oem_table_id)); - *return_desc = ddb_handle; return_ACPI_STATUS(status); } @@ -450,10 +446,6 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, return_ACPI_STATUS(status); } - ACPI_INFO((AE_INFO, - "Dynamic SSDT Load - OemId [%6.6s] OemTableId [%8.8s]", - table_ptr->oem_id, table_ptr->oem_table_id)); - cleanup: if (ACPI_FAILURE(status)) { ACPI_FREE(table_ptr); diff --git a/trunk/drivers/acpi/executer/excreate.c b/trunk/drivers/acpi/executer/excreate.c index 34eec82c1b1e..106dc7219df7 100644 --- a/trunk/drivers/acpi/executer/excreate.c +++ b/trunk/drivers/acpi/executer/excreate.c @@ -177,7 +177,7 @@ acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state) * that the event is created in an unsignalled state */ status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, - &obj_desc->event.os_semaphore); + &obj_desc->event.semaphore); if (ACPI_FAILURE(status)) { goto cleanup; } @@ -226,9 +226,12 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state) goto cleanup; } - /* Create the actual OS Mutex */ - - status = acpi_os_create_mutex(&obj_desc->mutex.os_mutex); + /* + * Create the actual OS semaphore. + * One unit max to make it a mutex, with one initial unit to allow + * the mutex to be acquired. + */ + status = acpi_os_create_semaphore(1, 1, &obj_desc->mutex.semaphore); if (ACPI_FAILURE(status)) { goto cleanup; } @@ -562,7 +565,7 @@ acpi_ex_create_method(u8 * aml_start, obj_desc->method.aml_length = aml_length; /* - * Disassemble the method flags. Split off the Arg Count + * Disassemble the method flags. Split off the Arg Count * for efficiency */ method_flags = (u8) operand[1]->integer.value; @@ -573,19 +576,21 @@ acpi_ex_create_method(u8 * aml_start, (u8) (method_flags & AML_METHOD_ARG_COUNT); /* - * Get the sync_level. If method is serialized, a mutex will be + * Get the concurrency count. If required, a semaphore will be * created for this method when it is parsed. */ if (acpi_gbl_all_methods_serialized) { - obj_desc->method.sync_level = 0; + obj_desc->method.concurrency = 1; obj_desc->method.method_flags |= AML_METHOD_SERIALIZED; } else if (method_flags & AML_METHOD_SERIALIZED) { /* - * ACPI 1.0: sync_level = 0 - * ACPI 2.0: sync_level = sync_level in method declaration + * ACPI 1.0: Concurrency = 1 + * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1) */ - obj_desc->method.sync_level = (u8) - ((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4); + obj_desc->method.concurrency = (u8) + (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1); + } else { + obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY; } /* Attach the new object to the method Node */ diff --git a/trunk/drivers/acpi/executer/exdump.c b/trunk/drivers/acpi/executer/exdump.c index 2450943add33..7b9718e976bf 100644 --- a/trunk/drivers/acpi/executer/exdump.c +++ b/trunk/drivers/acpi/executer/exdump.c @@ -118,14 +118,14 @@ static struct acpi_exdump_info acpi_ex_dump_device[4] = { static struct acpi_exdump_info acpi_ex_dump_event[2] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.os_semaphore), "OsSemaphore"} + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"} }; static struct acpi_exdump_info acpi_ex_dump_method[8] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "ParamCount"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.sync_level), "Sync Level"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.mutex), "Mutex"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"}, @@ -138,7 +138,7 @@ static struct acpi_exdump_info acpi_ex_dump_mutex[5] = { {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"}, {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), "Acquire Depth"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"} + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.semaphore), "Semaphore"} }; static struct acpi_exdump_info acpi_ex_dump_region[7] = { diff --git a/trunk/drivers/acpi/executer/exfldio.c b/trunk/drivers/acpi/executer/exfldio.c index 40f0bee6faa5..051053f7cccb 100644 --- a/trunk/drivers/acpi/executer/exfldio.c +++ b/trunk/drivers/acpi/executer/exfldio.c @@ -727,23 +727,11 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc, return_ACPI_STATUS(status); } - /* - * Merge with previous datum if necessary. - * - * Note: Before the shift, check if the shift value will be larger than - * the integer size. If so, there is no need to perform the operation. - * This avoids the differences in behavior between different compilers - * concerning shift values larger than the target data width. - */ - if ((obj_desc->common_field.access_bit_width - - obj_desc->common_field.start_field_bit_offset) < - ACPI_INTEGER_BIT_SIZE) { - merged_datum |= - raw_datum << (obj_desc->common_field. - access_bit_width - - obj_desc->common_field. - start_field_bit_offset); - } + /* Merge with previous datum if necessary */ + + merged_datum |= raw_datum << + (obj_desc->common_field.access_bit_width - + obj_desc->common_field.start_field_bit_offset); if (i == datum_count) { break; @@ -820,24 +808,14 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, return_ACPI_STATUS(AE_BUFFER_OVERFLOW); } - /* - * Create the bitmasks used for bit insertion. - * Note: This if/else is used to bypass compiler differences with the - * shift operator - */ - if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) { - width_mask = ACPI_INTEGER_MAX; - } else { - width_mask = - ACPI_MASK_BITS_ABOVE(obj_desc->common_field. - access_bit_width); - } - - mask = width_mask & - ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset); - /* Compute the number of datums (access width data items) */ + width_mask = + ACPI_MASK_BITS_ABOVE(obj_desc->common_field.access_bit_width); + mask = + width_mask & ACPI_MASK_BITS_BELOW(obj_desc->common_field. + start_field_bit_offset); + datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length, obj_desc->common_field.access_bit_width); @@ -870,29 +848,12 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, return_ACPI_STATUS(status); } - field_offset += obj_desc->common_field.access_byte_width; - - /* - * Start new output datum by merging with previous input datum - * if necessary. - * - * Note: Before the shift, check if the shift value will be larger than - * the integer size. If so, there is no need to perform the operation. - * This avoids the differences in behavior between different compilers - * concerning shift values larger than the target data width. - */ - if ((obj_desc->common_field.access_bit_width - - obj_desc->common_field.start_field_bit_offset) < - ACPI_INTEGER_BIT_SIZE) { - merged_datum = - raw_datum >> (obj_desc->common_field. - access_bit_width - - obj_desc->common_field. - start_field_bit_offset); - } else { - merged_datum = 0; - } + /* Start new output datum by merging with previous input datum */ + field_offset += obj_desc->common_field.access_byte_width; + merged_datum = raw_datum >> + (obj_desc->common_field.access_bit_width - + obj_desc->common_field.start_field_bit_offset); mask = width_mask; if (i == datum_count) { diff --git a/trunk/drivers/acpi/executer/exmutex.c b/trunk/drivers/acpi/executer/exmutex.c index d8ac2877cf05..93098d68cadf 100644 --- a/trunk/drivers/acpi/executer/exmutex.c +++ b/trunk/drivers/acpi/executer/exmutex.c @@ -161,13 +161,12 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, /* * Current Sync must be less than or equal to the sync level of the - * mutex. This mechanism provides some deadlock prevention + * mutex. This mechanism provides some deadlock prevention */ if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { ACPI_ERROR((AE_INFO, - "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)", - acpi_ut_get_node_name(obj_desc->mutex.node), - walk_state->thread->current_sync_level)); + "Cannot acquire Mutex [%4.4s], incorrect SyncLevel", + acpi_ut_get_node_name(obj_desc->mutex.node))); return_ACPI_STATUS(AE_AML_MUTEX_ORDER); } @@ -179,7 +178,8 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, if ((obj_desc->mutex.owner_thread->thread_id == walk_state->thread->thread_id) || - (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK)) { + (obj_desc->mutex.semaphore == + acpi_gbl_global_lock_semaphore)) { /* * The mutex is already owned by this thread, * just increment the acquisition depth @@ -264,7 +264,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, */ if ((obj_desc->mutex.owner_thread->thread_id != walk_state->thread->thread_id) - && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) { + && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { ACPI_ERROR((AE_INFO, "Thread %X cannot release Mutex [%4.4s] acquired by thread %X", walk_state->thread->thread_id, diff --git a/trunk/drivers/acpi/executer/exsystem.c b/trunk/drivers/acpi/executer/exsystem.c index 6b5d1e6ce94b..52beee3674a0 100644 --- a/trunk/drivers/acpi/executer/exsystem.c +++ b/trunk/drivers/acpi/executer/exsystem.c @@ -63,14 +63,14 @@ ACPI_MODULE_NAME("exsystem") * interpreter is released. * ******************************************************************************/ -acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) +acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout) { acpi_status status; acpi_status status2; ACPI_FUNCTION_TRACE(ex_system_wait_semaphore); - status = acpi_os_wait_semaphore(semaphore, 1, ACPI_DO_NOT_WAIT); + status = acpi_os_wait_semaphore(semaphore, 1, 0); if (ACPI_SUCCESS(status)) { return_ACPI_STATUS(status); } @@ -101,59 +101,6 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) return_ACPI_STATUS(status); } -/******************************************************************************* - * - * FUNCTION: acpi_ex_system_wait_mutex - * - * PARAMETERS: Mutex - Mutex to wait on - * Timeout - Max time to wait - * - * RETURN: Status - * - * DESCRIPTION: Implements a semaphore wait with a check to see if the - * semaphore is available immediately. If it is not, the - * interpreter is released. - * - ******************************************************************************/ - -acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout) -{ - acpi_status status; - acpi_status status2; - - ACPI_FUNCTION_TRACE(ex_system_wait_mutex); - - status = acpi_os_acquire_mutex(mutex, ACPI_DO_NOT_WAIT); - if (ACPI_SUCCESS(status)) { - return_ACPI_STATUS(status); - } - - if (status == AE_TIME) { - - /* We must wait, so unlock the interpreter */ - - acpi_ex_exit_interpreter(); - - status = acpi_os_acquire_mutex(mutex, timeout); - - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, - "*** Thread awake after blocking, %s\n", - acpi_format_exception(status))); - - /* Reacquire the interpreter */ - - status2 = acpi_ex_enter_interpreter(); - if (ACPI_FAILURE(status2)) { - - /* Report fatal error, could not acquire interpreter */ - - return_ACPI_STATUS(status2); - } - } - - return_ACPI_STATUS(status); -} - /******************************************************************************* * * FUNCTION: acpi_ex_system_do_stall @@ -229,7 +176,7 @@ acpi_status acpi_ex_system_do_suspend(acpi_integer how_long) * * FUNCTION: acpi_ex_system_acquire_mutex * - * PARAMETERS: time_desc - Maximum time to wait for the mutex + * PARAMETERS: time_desc - The 'time to delay' object descriptor * obj_desc - The object descriptor for this op * * RETURN: Status @@ -254,14 +201,14 @@ acpi_ex_system_acquire_mutex(union acpi_operand_object * time_desc, /* Support for the _GL_ Mutex object -- go get the global lock */ - if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) { + if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { status = acpi_ev_acquire_global_lock((u16) time_desc->integer.value); return_ACPI_STATUS(status); } - status = acpi_ex_system_wait_mutex(obj_desc->mutex.os_mutex, - (u16) time_desc->integer.value); + status = acpi_ex_system_wait_semaphore(obj_desc->mutex.semaphore, + (u16) time_desc->integer.value); return_ACPI_STATUS(status); } @@ -292,13 +239,13 @@ acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc) /* Support for the _GL_ Mutex object -- release the global lock */ - if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) { + if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { status = acpi_ev_release_global_lock(); return_ACPI_STATUS(status); } - acpi_os_release_mutex(obj_desc->mutex.os_mutex); - return_ACPI_STATUS(AE_OK); + status = acpi_os_signal_semaphore(obj_desc->mutex.semaphore, 1); + return_ACPI_STATUS(status); } /******************************************************************************* @@ -321,8 +268,7 @@ acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc) ACPI_FUNCTION_TRACE(ex_system_signal_event); if (obj_desc) { - status = - acpi_os_signal_semaphore(obj_desc->event.os_semaphore, 1); + status = acpi_os_signal_semaphore(obj_desc->event.semaphore, 1); } return_ACPI_STATUS(status); @@ -353,7 +299,7 @@ acpi_ex_system_wait_event(union acpi_operand_object *time_desc, if (obj_desc) { status = - acpi_ex_system_wait_semaphore(obj_desc->event.os_semaphore, + acpi_ex_system_wait_semaphore(obj_desc->event.semaphore, (u16) time_desc->integer. value); } @@ -376,7 +322,7 @@ acpi_ex_system_wait_event(union acpi_operand_object *time_desc, acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc) { acpi_status status = AE_OK; - acpi_semaphore temp_semaphore; + void *temp_semaphore; ACPI_FUNCTION_ENTRY(); @@ -387,8 +333,8 @@ acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc) status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore); if (ACPI_SUCCESS(status)) { - (void)acpi_os_delete_semaphore(obj_desc->event.os_semaphore); - obj_desc->event.os_semaphore = temp_semaphore; + (void)acpi_os_delete_semaphore(obj_desc->event.semaphore); + obj_desc->event.semaphore = temp_semaphore; } return (status); diff --git a/trunk/drivers/acpi/fan.c b/trunk/drivers/acpi/fan.c index 38acc69b21bc..1cd25784b7a4 100644 --- a/trunk/drivers/acpi/fan.c +++ b/trunk/drivers/acpi/fan.c @@ -78,6 +78,7 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset) struct acpi_fan *fan = seq->private; int state = 0; + ACPI_FUNCTION_TRACE("acpi_fan_read_state"); if (fan) { if (acpi_bus_get_power(fan->handle, &state)) @@ -86,7 +87,7 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset) seq_printf(seq, "status: %s\n", !state ? "on" : "off"); } - return 0; + return_VALUE(0); } static int acpi_fan_state_open_fs(struct inode *inode, struct file *file) @@ -103,21 +104,22 @@ acpi_fan_write_state(struct file *file, const char __user * buffer, struct acpi_fan *fan = (struct acpi_fan *)m->private; char state_string[12] = { '\0' }; + ACPI_FUNCTION_TRACE("acpi_fan_write_state"); if (!fan || (count > sizeof(state_string) - 1)) - return -EINVAL; + return_VALUE(-EINVAL); if (copy_from_user(state_string, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); state_string[count] = '\0'; result = acpi_bus_set_power(fan->handle, simple_strtoul(state_string, NULL, 0)); if (result) - return result; + return_VALUE(result); - return count; + return_VALUE(count); } static struct file_operations acpi_fan_state_ops = { @@ -133,15 +135,16 @@ static int acpi_fan_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; + ACPI_FUNCTION_TRACE("acpi_fan_add_fs"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_fan_dir); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; } @@ -150,18 +153,21 @@ static int acpi_fan_add_fs(struct acpi_device *device) S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_FAN_FILE_STATE)); else { entry->proc_fops = &acpi_fan_state_ops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return 0; + return_VALUE(0); } static int acpi_fan_remove_fs(struct acpi_device *device) { + ACPI_FUNCTION_TRACE("acpi_fan_remove_fs"); if (acpi_device_dir(device)) { remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device)); @@ -169,7 +175,7 @@ static int acpi_fan_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -182,13 +188,14 @@ static int acpi_fan_add(struct acpi_device *device) struct acpi_fan *fan = NULL; int state = 0; + ACPI_FUNCTION_TRACE("acpi_fan_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL); if (!fan) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(fan, 0, sizeof(struct acpi_fan)); fan->handle = device->handle; @@ -198,7 +205,8 @@ static int acpi_fan_add(struct acpi_device *device) result = acpi_bus_get_power(fan->handle, &state); if (result) { - printk(KERN_ERR PREFIX "Reading power state\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error reading power state\n")); goto end; } @@ -218,16 +226,17 @@ static int acpi_fan_add(struct acpi_device *device) if (result) kfree(fan); - return result; + return_VALUE(result); } static int acpi_fan_remove(struct acpi_device *device, int type) { struct acpi_fan *fan = NULL; + ACPI_FUNCTION_TRACE("acpi_fan_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); fan = (struct acpi_fan *)acpi_driver_data(device); @@ -235,7 +244,7 @@ static int acpi_fan_remove(struct acpi_device *device, int type) kfree(fan); - return 0; + return_VALUE(0); } static int acpi_fan_suspend(struct acpi_device *device, int state) @@ -274,29 +283,31 @@ static int __init acpi_fan_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_fan_init"); acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir); if (!acpi_fan_dir) - return -ENODEV; + return_VALUE(-ENODEV); acpi_fan_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_fan_driver); if (result < 0) { remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } static void __exit acpi_fan_exit(void) { + ACPI_FUNCTION_TRACE("acpi_fan_exit"); acpi_bus_unregister_driver(&acpi_fan_driver); remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); - return; + return_VOID; } module_init(acpi_fan_init); diff --git a/trunk/drivers/acpi/hardware/hwregs.c b/trunk/drivers/acpi/hardware/hwregs.c index 3143f36fcec9..ae142de19507 100644 --- a/trunk/drivers/acpi/hardware/hwregs.c +++ b/trunk/drivers/acpi/hardware/hwregs.c @@ -172,9 +172,9 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b) } /* - * The package must have at least two elements. NOTE (March 2005): This + * The package must have at least two elements. NOTE (March 2005): This * goes against the current ACPI spec which defines this object as a - * package with one encoded DWORD element. However, existing practice + * package with one encoded DWORD element. However, existing practice * by BIOS vendors seems to be to have 2 or more elements, at least * one per sleep type (A/B). */ @@ -255,7 +255,7 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) * return_value - Value that was read from the register * Flags - Lock the hardware or not * - * RETURN: Status and the value read from specified Register. Value + * RETURN: Status and the value read from specified Register. Value * returned is normalized to bit0 (is shifted all the way right) * * DESCRIPTION: ACPI bit_register read function. @@ -361,8 +361,8 @@ acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags) case ACPI_REGISTER_PM1_STATUS: /* - * Status Registers are different from the rest. Clear by - * writing 1, and writing 0 has no effect. So, the only relevant + * Status Registers are different from the rest. Clear by + * writing 1, and writing 0 has no effect. So, the only relevant * information is the single bit we're interested in, all others should * be written as 0 so they will be left unchanged. */ @@ -467,13 +467,14 @@ ACPI_EXPORT_SYMBOL(acpi_set_register) * * FUNCTION: acpi_hw_register_read * - * PARAMETERS: use_lock - Lock hardware? True/False - * register_id - ACPI Register ID + * PARAMETERS: use_lock - Mutex hw access + * register_id - register_iD + Offset * return_value - Where the register value is returned * * RETURN: Status and the value read. * - * DESCRIPTION: Read from the specified ACPI register + * DESCRIPTION: Acpi register read function. Registers are read at the + * given offset. * ******************************************************************************/ acpi_status @@ -579,26 +580,14 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) * * FUNCTION: acpi_hw_register_write * - * PARAMETERS: use_lock - Lock hardware? True/False - * register_id - ACPI Register ID + * PARAMETERS: use_lock - Mutex hw access + * register_id - register_iD + Offset * Value - The value to write * * RETURN: Status * - * DESCRIPTION: Write to the specified ACPI register - * - * NOTE: In accordance with the ACPI specification, this function automatically - * preserves the value of the following bits, meaning that these bits cannot be - * changed via this interface: - * - * PM1_CONTROL[0] = SCI_EN - * PM1_CONTROL[9] - * PM1_STATUS[11] - * - * ACPI References: - * 1) Hardware Ignored Bits: When software writes to a register with ignored - * bit fields, it preserves the ignored bit fields - * 2) SCI_EN: OSPM always preserves this bit position + * DESCRIPTION: Acpi register Write function. Registers are written at the + * given offset. * ******************************************************************************/ @@ -606,7 +595,6 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) { acpi_status status; acpi_cpu_flags lock_flags = 0; - u32 read_value; ACPI_FUNCTION_TRACE(hw_register_write); @@ -617,22 +605,6 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) switch (register_id) { case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ - /* Perform a read first to preserve certain bits (per ACPI spec) */ - - status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_STATUS, - &read_value); - if (ACPI_FAILURE(status)) { - goto unlock_and_exit; - } - - /* Insert the bits to be preserved */ - - ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS, - read_value); - - /* Now we can write the data */ - status = acpi_hw_low_level_write(16, value, &acpi_gbl_FADT->xpm1a_evt_blk); @@ -663,25 +635,6 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ - /* - * Perform a read first to preserve certain bits (per ACPI spec) - * - * Note: This includes SCI_EN, we never want to change this bit - */ - status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_CONTROL, - &read_value); - if (ACPI_FAILURE(status)) { - goto unlock_and_exit; - } - - /* Insert the bits to be preserved */ - - ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS, - read_value); - - /* Now we can write the data */ - status = acpi_hw_low_level_write(16, value, &acpi_gbl_FADT->xpm1a_cnt_blk); @@ -773,7 +726,7 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg) return (AE_OK); } - /* Get a local copy of the address. Handles possible alignment issues */ + /* Get a local copy of the address. Handles possible alignment issues */ ACPI_MOVE_64_TO_64(&address, ®->address); if (!address) { @@ -845,7 +798,7 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg) return (AE_OK); } - /* Get a local copy of the address. Handles possible alignment issues */ + /* Get a local copy of the address. Handles possible alignment issues */ ACPI_MOVE_64_TO_64(&address, ®->address); if (!address) { diff --git a/trunk/drivers/acpi/hotkey.c b/trunk/drivers/acpi/hotkey.c index fd81a0f5222f..c25b2b92edcf 100644 --- a/trunk/drivers/acpi/hotkey.c +++ b/trunk/drivers/acpi/hotkey.c @@ -231,10 +231,11 @@ struct list_head hotkey_entries; /* head of the list of hotkey_list */ static int hotkey_info_seq_show(struct seq_file *seq, void *offset) { + ACPI_FUNCTION_TRACE("hotkey_info_seq_show"); seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION); - return 0; + return_VALUE(0); } static int hotkey_info_open_fs(struct inode *inode, struct file *file) @@ -265,6 +266,7 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) (struct acpi_polling_hotkey *)seq->private; char *buf; + ACPI_FUNCTION_TRACE("hotkey_polling_seq_show"); if (poll_hotkey->poll_result) { buf = format_result(poll_hotkey->poll_result); @@ -272,7 +274,7 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) seq_printf(seq, "%s", buf); kfree(buf); } - return 0; + return_VALUE(0); } static int hotkey_polling_open_fs(struct inode *inode, struct file *file) @@ -291,6 +293,7 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list) struct list_head *entries; int val = -1; + ACPI_FUNCTION_TRACE("hotkey_get_internal_event"); list_for_each(entries, list->entries) { union acpi_hotkey *key = @@ -302,7 +305,7 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list) } } - return val; + return_VALUE(val); } static void @@ -311,14 +314,15 @@ acpi_hotkey_notify_handler(acpi_handle handle, u32 event, void *data) struct acpi_device *device = NULL; u32 internal_event; + ACPI_FUNCTION_TRACE("acpi_hotkey_notify_handler"); if (acpi_bus_get_device(handle, &device)) - return; + return_VOID; internal_event = hotkey_get_internal_event(event, &global_hotkey_list); acpi_bus_generate_event(device, internal_event, 0); - return; + return_VOID; } /* Need to invent automatically hotkey add method */ @@ -342,6 +346,7 @@ static int create_polling_proc(union acpi_hotkey *device) char proc_name[80]; mode_t mode; + ACPI_FUNCTION_TRACE("create_polling_proc"); mode = S_IFREG | S_IRUGO | S_IWUGO; sprintf(proc_name, "%d", device->link.hotkey_standard_num); @@ -351,7 +356,10 @@ static int create_polling_proc(union acpi_hotkey *device) proc = create_proc_entry(proc_name, mode, hotkey_proc_dir); if (!proc) { - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Hotkey: Unable to create %s entry\n", + device->poll_hotkey.poll_method)); + return_VALUE(-ENODEV); } else { proc->proc_fops = &hotkey_polling_fops; proc->owner = THIS_MODULE; @@ -360,7 +368,7 @@ static int create_polling_proc(union acpi_hotkey *device) proc->gid = 0; device->poll_hotkey.proc = proc; } - return 0; + return_VALUE(0); } static int hotkey_add(union acpi_hotkey *device) @@ -368,6 +376,7 @@ static int hotkey_add(union acpi_hotkey *device) int status = 0; struct acpi_device *dev = NULL; + ACPI_FUNCTION_TRACE("hotkey_add"); if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) { acpi_bus_get_device(device->event_hotkey.bus_handle, &dev); @@ -382,13 +391,14 @@ static int hotkey_add(union acpi_hotkey *device) list_add_tail(&device->link.entries, global_hotkey_list.entries); - return status; + return_VALUE(status); } static int hotkey_remove(union acpi_hotkey *device) { struct list_head *entries, *next; + ACPI_FUNCTION_TRACE("hotkey_remove"); list_for_each_safe(entries, next, global_hotkey_list.entries) { union acpi_hotkey *key = @@ -402,13 +412,14 @@ static int hotkey_remove(union acpi_hotkey *device) } } kfree(device); - return 0; + return_VALUE(0); } static int hotkey_update(union acpi_hotkey *key) { struct list_head *entries; + ACPI_FUNCTION_TRACE("hotkey_update"); list_for_each(entries, global_hotkey_list.entries) { union acpi_hotkey *tmp = @@ -450,18 +461,19 @@ static int hotkey_update(union acpi_hotkey *key) */ kfree(key); } - return 0; + return_VALUE(0); break; } } - return -ENODEV; + return_VALUE(-ENODEV); } static void free_hotkey_device(union acpi_hotkey *key) { struct acpi_device *dev; + ACPI_FUNCTION_TRACE("free_hotkey_device"); if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { acpi_bus_get_device(key->event_hotkey.bus_handle, &dev); @@ -481,7 +493,7 @@ static void free_hotkey_device(union acpi_hotkey *key) free_poll_hotkey_buffer(key); } kfree(key); - return; + return_VOID; } static void free_hotkey_buffer(union acpi_hotkey *key) @@ -502,6 +514,7 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str, acpi_handle tmp_handle; acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("init_hotkey_device"); if (std_num < 0 || IS_POLL(std_num) || !key) goto do_fail; @@ -528,9 +541,9 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str, method, &tmp_handle); if (ACPI_FAILURE(status)) goto do_fail; - return AE_OK; + return_VALUE(AE_OK); do_fail: - return -ENODEV; + return_VALUE(-ENODEV); } static int @@ -542,6 +555,7 @@ init_poll_hotkey_device(union acpi_hotkey *key, acpi_status status = AE_OK; acpi_handle tmp_handle; + ACPI_FUNCTION_TRACE("init_poll_hotkey_device"); if (std_num < 0 || IS_EVENT(std_num) || !key) goto do_fail; @@ -576,20 +590,22 @@ init_poll_hotkey_device(union acpi_hotkey *key, (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); if (!key->poll_hotkey.poll_result) goto do_fail; - return AE_OK; + return_VALUE(AE_OK); do_fail: - return -ENODEV; + return_VALUE(-ENODEV); } static int hotkey_open_config(struct inode *inode, struct file *file) { - return (single_open + ACPI_FUNCTION_TRACE("hotkey_open_config"); + return_VALUE(single_open (file, hotkey_config_seq_show, PDE(inode)->data)); } static int hotkey_poll_open_config(struct inode *inode, struct file *file) { - return (single_open + ACPI_FUNCTION_TRACE("hotkey_poll_open_config"); + return_VALUE(single_open (file, hotkey_poll_config_seq_show, PDE(inode)->data)); } @@ -602,6 +618,7 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset) struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; + ACPI_FUNCTION_TRACE(("hotkey_config_seq_show")); list_for_each(entries, hotkey_list->entries) { union acpi_hotkey *key = @@ -619,7 +636,7 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset) } } seq_puts(seq, "\n"); - return 0; + return_VALUE(0); } static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset) @@ -631,6 +648,7 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset) struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; + ACPI_FUNCTION_TRACE(("hotkey_config_seq_show")); list_for_each(entries, hotkey_list->entries) { union acpi_hotkey *key = @@ -648,7 +666,7 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset) } } seq_puts(seq, "\n"); - return 0; + return_VALUE(0); } static int @@ -660,6 +678,7 @@ get_parms(char *config_record, char **method, int *internal_event_num, int *external_event_num) { char *tmp, *tmp1, count; + ACPI_FUNCTION_TRACE(("get_parms")); sscanf(config_record, "%d", cmd); @@ -725,9 +744,9 @@ get_parms(char *config_record, 0) goto do_fail; - return 6; + return_VALUE(6); do_fail: - return -1; + return_VALUE(-1); } /* count is length for one input record */ @@ -744,15 +763,16 @@ static ssize_t hotkey_write_config(struct file *file, int ret = 0; union acpi_hotkey *key = NULL; + ACPI_FUNCTION_TRACE(("hotkey_write_config")); config_record = (char *)kmalloc(count + 1, GFP_KERNEL); if (!config_record) - return -ENOMEM; + return_VALUE(-ENOMEM); if (copy_from_user(config_record, buffer, count)) { kfree(config_record); - printk(KERN_ERR PREFIX "Invalid data\n"); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n")); + return_VALUE(-EINVAL); } config_record[count] = 0; @@ -772,8 +792,9 @@ static ssize_t hotkey_write_config(struct file *file, kfree(bus_method); kfree(action_handle); kfree(method); - printk(KERN_ERR PREFIX "Invalid data format ret=%d\n", ret); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid data format ret=%d\n", ret)); + return_VALUE(-EINVAL); } key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); @@ -785,7 +806,7 @@ static ssize_t hotkey_write_config(struct file *file, tmp = get_hotkey_by_event(&global_hotkey_list, internal_event_num); if (!tmp) - printk(KERN_ERR PREFIX "Invalid key\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key")); else memcpy(key, tmp, sizeof(union acpi_hotkey)); goto cont_cmd; @@ -807,8 +828,8 @@ static ssize_t hotkey_write_config(struct file *file, else free_poll_hotkey_buffer(key); kfree(key); - printk(KERN_ERR PREFIX "Invalid hotkey\n"); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n")); + return_VALUE(-EINVAL); } cont_cmd: @@ -834,15 +855,15 @@ static ssize_t hotkey_write_config(struct file *file, goto fail_out; break; } - return count; + return_VALUE(count); fail_out: if (IS_EVENT(internal_event_num)) free_hotkey_buffer(key); else free_poll_hotkey_buffer(key); kfree(key); - printk(KERN_ERR PREFIX "invalid key\n"); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "invalid key\n")); + return_VALUE(-EINVAL); } /* @@ -859,6 +880,7 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val, union acpi_object in_obj; /* the only param we use */ acpi_status status; + ACPI_FUNCTION_TRACE("write_acpi_int"); params.count = 1; params.pointer = &in_obj; in_obj.type = ACPI_TYPE_INTEGER; @@ -866,7 +888,7 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val, status = acpi_evaluate_object(handle, (char *)method, ¶ms, output); - return (status == AE_OK); + return_VALUE(status == AE_OK); } static int read_acpi_int(acpi_handle handle, const char *method, @@ -876,6 +898,7 @@ static int read_acpi_int(acpi_handle handle, const char *method, union acpi_object out_obj; acpi_status status; + ACPI_FUNCTION_TRACE("read_acpi_int"); output.length = sizeof(out_obj); output.pointer = &out_obj; @@ -884,8 +907,8 @@ static int read_acpi_int(acpi_handle handle, const char *method, val->integer.value = out_obj.integer.value; val->type = out_obj.type; } else - printk(KERN_ERR PREFIX "null val pointer\n"); - return ((status == AE_OK) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "null val pointer")); + return_VALUE((status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER)); } @@ -922,23 +945,24 @@ static ssize_t hotkey_execute_aml_method(struct file *file, int event, method_type, type, value; union acpi_hotkey *key; + ACPI_FUNCTION_TRACE("hotkey_execte_aml_method"); arg = (char *)kmalloc(count + 1, GFP_KERNEL); if (!arg) - return -ENOMEM; + return_VALUE(-ENOMEM); arg[count] = 0; if (copy_from_user(arg, buffer, count)) { kfree(arg); - printk(KERN_ERR PREFIX "Invalid argument 2\n"); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2")); + return_VALUE(-EINVAL); } if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != 4) { kfree(arg); - printk(KERN_ERR PREFIX "Invalid argument 3\n"); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3")); + return_VALUE(-EINVAL); } kfree(arg); if (type == ACPI_TYPE_INTEGER) { @@ -963,12 +987,12 @@ static ssize_t hotkey_execute_aml_method(struct file *file, } } else { - printk(KERN_WARNING "Not supported\n"); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported")); + return_VALUE(-EINVAL); } - return count; + return_VALUE(count); do_fail: - return -EINVAL; + return_VALUE(-EINVAL); } @@ -977,6 +1001,7 @@ static int __init hotkey_init(void) int result; mode_t mode = S_IFREG | S_IRUGO | S_IWUGO; + ACPI_FUNCTION_TRACE("hotkey_init"); if (acpi_disabled) return -ENODEV; @@ -988,6 +1013,9 @@ static int __init hotkey_init(void) hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir); if (!hotkey_proc_dir) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Hotkey: Unable to create %s entry\n", + HOTKEY_PROC)); return (-ENODEV); } hotkey_proc_dir->owner = THIS_MODULE; @@ -995,6 +1023,9 @@ static int __init hotkey_init(void) hotkey_config = create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir); if (!hotkey_config) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Hotkey: Unable to create %s entry\n", + HOTKEY_EV_CONFIG)); goto do_fail1; } else { hotkey_config->proc_fops = &hotkey_config_fops; @@ -1007,6 +1038,10 @@ static int __init hotkey_init(void) hotkey_poll_config = create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir); if (!hotkey_poll_config) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Hotkey: Unable to create %s entry\n", + HOTKEY_EV_CONFIG)); + goto do_fail2; } else { hotkey_poll_config->proc_fops = &hotkey_poll_config_fops; @@ -1018,6 +1053,9 @@ static int __init hotkey_init(void) hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir); if (!hotkey_action) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Hotkey: Unable to create %s entry\n", + HOTKEY_ACTION)); goto do_fail3; } else { hotkey_action->proc_fops = &hotkey_action_fops; @@ -1028,6 +1066,9 @@ static int __init hotkey_init(void) hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir); if (!hotkey_info) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Hotkey: Unable to create %s entry\n", + HOTKEY_INFO)); goto do_fail4; } else { hotkey_info->proc_fops = &hotkey_info_fops; @@ -1063,6 +1104,7 @@ static void __exit hotkey_exit(void) { struct list_head *entries, *next; + ACPI_FUNCTION_TRACE("hotkey_exit"); list_for_each_safe(entries, next, global_hotkey_list.entries) { union acpi_hotkey *key = diff --git a/trunk/drivers/acpi/motherboard.c b/trunk/drivers/acpi/motherboard.c index ec6b7f9ede34..d51d68f5dd8d 100644 --- a/trunk/drivers/acpi/motherboard.c +++ b/trunk/drivers/acpi/motherboard.c @@ -52,12 +52,13 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data) { struct resource *requested_res = NULL; + ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges"); if (res->type == ACPI_RESOURCE_TYPE_IO) { struct acpi_resource_io *io_res = &res->data.io; if (io_res->minimum != io_res->maximum) - return AE_OK; + return_VALUE(AE_OK); if (IS_RESERVED_ADDR (io_res->minimum, io_res->address_length)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, @@ -91,7 +92,7 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data) if (requested_res) requested_res->flags &= ~IORESOURCE_BUSY; - return AE_OK; + return_VALUE(AE_OK); } static int acpi_motherboard_add(struct acpi_device *device) diff --git a/trunk/drivers/acpi/namespace/nsaccess.c b/trunk/drivers/acpi/namespace/nsaccess.c index c1c6c236df9a..48fadade52e2 100644 --- a/trunk/drivers/acpi/namespace/nsaccess.c +++ b/trunk/drivers/acpi/namespace/nsaccess.c @@ -196,30 +196,33 @@ acpi_status acpi_ns_root_initialize(void) (u8) (ACPI_TO_INTEGER(val) - 1); if (ACPI_STRCMP(init_val->name, "_GL_") == 0) { - - /* Create a counting semaphore for the global lock */ - + /* + * Create a counting semaphore for the + * global lock + */ status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 1, - &acpi_gbl_global_lock_semaphore); + &obj_desc->mutex.semaphore); if (ACPI_FAILURE(status)) { acpi_ut_remove_reference (obj_desc); goto unlock_and_exit; } - /* Mark this mutex as very special */ - - obj_desc->mutex.os_mutex = - ACPI_GLOBAL_LOCK; + /* + * We just created the mutex for the + * global lock, save it + */ + acpi_gbl_global_lock_semaphore = + obj_desc->mutex.semaphore; } else { /* Create a mutex */ - status = - acpi_os_create_mutex(&obj_desc-> - mutex. - os_mutex); + status = acpi_os_create_semaphore(1, 1, + &obj_desc-> + mutex. + semaphore); if (ACPI_FAILURE(status)) { acpi_ut_remove_reference (obj_desc); diff --git a/trunk/drivers/acpi/osl.c b/trunk/drivers/acpi/osl.c index afd937b158b3..1bb558adee66 100644 --- a/trunk/drivers/acpi/osl.c +++ b/trunk/drivers/acpi/osl.c @@ -137,7 +137,6 @@ void acpi_os_vprintf(const char *fmt, va_list args) #endif } - extern int acpi_in_resume; void *acpi_os_allocate(acpi_size size) { @@ -587,18 +586,19 @@ static void acpi_os_execute_deferred(void *context) { struct acpi_os_dpc *dpc = NULL; + ACPI_FUNCTION_TRACE("os_execute_deferred"); dpc = (struct acpi_os_dpc *)context; if (!dpc) { - printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); - return; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); + return_VOID; } dpc->function(dpc->context); kfree(dpc); - return; + return_VOID; } static int acpi_os_execute_thread(void *context) @@ -688,19 +688,35 @@ EXPORT_SYMBOL(acpi_os_wait_events_complete); /* * Allocate the memory for a spinlock and initialize it. */ -acpi_status acpi_os_create_lock(acpi_spinlock * handle) +acpi_status acpi_os_create_lock(acpi_handle * out_handle) { - spin_lock_init(*handle); + spinlock_t *lock_ptr; - return AE_OK; + ACPI_FUNCTION_TRACE("os_create_lock"); + + lock_ptr = acpi_os_allocate(sizeof(spinlock_t)); + + spin_lock_init(lock_ptr); + + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr)); + + *out_handle = lock_ptr; + + return_ACPI_STATUS(AE_OK); } /* * Deallocate the memory for a spinlock. */ -void acpi_os_delete_lock(acpi_spinlock handle) +void acpi_os_delete_lock(acpi_handle handle) { - return; + ACPI_FUNCTION_TRACE("os_create_lock"); + + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle)); + + acpi_os_free(handle); + + return_VOID; } acpi_status @@ -708,10 +724,11 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) { struct semaphore *sem = NULL; + ACPI_FUNCTION_TRACE("os_create_semaphore"); sem = acpi_os_allocate(sizeof(struct semaphore)); if (!sem) - return AE_NO_MEMORY; + return_ACPI_STATUS(AE_NO_MEMORY); memset(sem, 0, sizeof(struct semaphore)); sema_init(sem, initial_units); @@ -721,7 +738,7 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", *handle, initial_units)); - return AE_OK; + return_ACPI_STATUS(AE_OK); } EXPORT_SYMBOL(acpi_os_create_semaphore); @@ -737,16 +754,17 @@ acpi_status acpi_os_delete_semaphore(acpi_handle handle) { struct semaphore *sem = (struct semaphore *)handle; + ACPI_FUNCTION_TRACE("os_delete_semaphore"); if (!sem) - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); acpi_os_free(sem); sem = NULL; - return AE_OK; + return_ACPI_STATUS(AE_OK); } EXPORT_SYMBOL(acpi_os_delete_semaphore); @@ -766,12 +784,13 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) struct semaphore *sem = (struct semaphore *)handle; int ret = 0; + ACPI_FUNCTION_TRACE("os_wait_semaphore"); if (!sem || (units < 1)) - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); if (units > 1) - return AE_SUPPORT; + return_ACPI_STATUS(AE_SUPPORT); ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout)); @@ -820,17 +839,17 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) } if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, - "Failed to acquire semaphore[%p|%d|%d], %s", + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Failed to acquire semaphore[%p|%d|%d], %s\n", handle, units, timeout, acpi_format_exception(status))); } else { ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, - "Acquired semaphore[%p|%d|%d]", handle, + "Acquired semaphore[%p|%d|%d]\n", handle, units, timeout)); } - return status; + return_ACPI_STATUS(status); } EXPORT_SYMBOL(acpi_os_wait_semaphore); @@ -842,19 +861,20 @@ acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) { struct semaphore *sem = (struct semaphore *)handle; + ACPI_FUNCTION_TRACE("os_signal_semaphore"); if (!sem || (units < 1)) - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); if (units > 1) - return AE_SUPPORT; + return_ACPI_STATUS(AE_SUPPORT); ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, units)); up(sem); - return AE_OK; + return_ACPI_STATUS(AE_OK); } EXPORT_SYMBOL(acpi_os_signal_semaphore); @@ -1023,10 +1043,10 @@ EXPORT_SYMBOL(max_cstate); * handle is a pointer to the spinlock_t. */ -acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp) +acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle) { acpi_cpu_flags flags; - spin_lock_irqsave(lockp, flags); + spin_lock_irqsave((spinlock_t *) handle, flags); return flags; } @@ -1034,9 +1054,9 @@ acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp) * Release a spinlock. See above. */ -void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags) +void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags) { - spin_unlock_irqrestore(lockp, flags); + spin_unlock_irqrestore((spinlock_t *) handle, flags); } #ifndef ACPI_USE_LOCAL_CACHE diff --git a/trunk/drivers/acpi/parser/psparse.c b/trunk/drivers/acpi/parser/psparse.c index a02aa62fe1e5..7ee2f2e77525 100644 --- a/trunk/drivers/acpi/parser/psparse.c +++ b/trunk/drivers/acpi/parser/psparse.c @@ -469,16 +469,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) } walk_state->thread = thread; - - /* - * If executing a method, the starting sync_level is this method's - * sync_level - */ - if (walk_state->method_desc) { - walk_state->thread->current_sync_level = - walk_state->method_desc->method.sync_level; - } - acpi_ds_push_walk_state(walk_state, thread); /* @@ -515,10 +505,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) status = acpi_ds_call_control_method(thread, walk_state, NULL); - if (ACPI_FAILURE(status)) { - status = - acpi_ds_method_error(status, walk_state); - } /* * If the transfer to the new method method call worked, a new walk @@ -539,7 +525,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) /* Check for possible multi-thread reentrancy problem */ if ((status == AE_ALREADY_EXISTS) && - (!walk_state->method_desc->method.mutex)) { + (!walk_state->method_desc->method.semaphore)) { /* * Method tried to create an object twice. The probable cause is * that the method cannot handle reentrancy. @@ -551,7 +537,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) */ walk_state->method_desc->method.method_flags |= AML_METHOD_SERIALIZED; - walk_state->method_desc->method.sync_level = 0; + walk_state->method_desc->method.concurrency = 1; } } diff --git a/trunk/drivers/acpi/pci_bind.c b/trunk/drivers/acpi/pci_bind.c index 1e2ae6e7a7e4..2a718df769b5 100644 --- a/trunk/drivers/acpi/pci_bind.c +++ b/trunk/drivers/acpi/pci_bind.c @@ -47,10 +47,11 @@ struct acpi_pci_data { static void acpi_pci_data_handler(acpi_handle handle, u32 function, void *context) { + ACPI_FUNCTION_TRACE("acpi_pci_data_handler"); /* TBD: Anything we need to do here? */ - return; + return_VOID; } /** @@ -67,24 +68,25 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id) struct acpi_device *device = NULL; struct acpi_pci_data *data = NULL; + ACPI_FUNCTION_TRACE("acpi_get_pci_id"); if (!id) - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); result = acpi_bus_get_device(handle, &device); if (result) { - printk(KERN_ERR PREFIX - "Invalid ACPI Bus context for device %s\n", - acpi_device_bid(device)); - return AE_NOT_EXIST; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid ACPI Bus context for device %s\n", + acpi_device_bid(device))); + return_ACPI_STATUS(AE_NOT_EXIST); } status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data); if (ACPI_FAILURE(status) || !data) { - ACPI_EXCEPTION((AE_INFO, status, - "Invalid ACPI-PCI context for device %s", - acpi_device_bid(device))); - return status; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid ACPI-PCI context for device %s\n", + acpi_device_bid(device))); + return_ACPI_STATUS(status); } *id = data->id; @@ -101,7 +103,7 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id) acpi_device_bid(device), id->segment, id->bus, id->device, id->function)); - return AE_OK; + return_ACPI_STATUS(AE_OK); } EXPORT_SYMBOL(acpi_get_pci_id); @@ -118,13 +120,14 @@ int acpi_pci_bind(struct acpi_device *device) struct pci_dev *dev; struct pci_bus *bus; + ACPI_FUNCTION_TRACE("acpi_pci_bind"); if (!device || !device->parent) - return -EINVAL; + return_VALUE(-EINVAL); pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); if (!pathname) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(pathname, 0, ACPI_PATHNAME_MAX); buffer.length = ACPI_PATHNAME_MAX; buffer.pointer = pathname; @@ -132,7 +135,7 @@ int acpi_pci_bind(struct acpi_device *device) data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); if (!data) { kfree(pathname); - return -ENOMEM; + return_VALUE(-ENOMEM); } memset(data, 0, sizeof(struct acpi_pci_data)); @@ -148,9 +151,9 @@ int acpi_pci_bind(struct acpi_device *device) status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, (void **)&pdata); if (ACPI_FAILURE(status) || !pdata || !pdata->bus) { - ACPI_EXCEPTION((AE_INFO, status, - "Invalid ACPI-PCI context for parent device %s", - acpi_device_bid(device->parent))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid ACPI-PCI context for parent device %s\n", + acpi_device_bid(device->parent))); result = -ENODEV; goto end; } @@ -203,10 +206,10 @@ int acpi_pci_bind(struct acpi_device *device) goto end; } if (!data->dev->bus) { - printk(KERN_ERR PREFIX - "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", - data->id.segment, data->id.bus, - data->id.device, data->id.function); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", + data->id.segment, data->id.bus, + data->id.device, data->id.function)); result = -ENODEV; goto end; } @@ -234,9 +237,9 @@ int acpi_pci_bind(struct acpi_device *device) */ status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, - "Unable to attach ACPI-PCI context to device %s", - acpi_device_bid(device))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to attach ACPI-PCI context to device %s\n", + acpi_device_bid(device))); result = -ENODEV; goto end; } @@ -266,7 +269,7 @@ int acpi_pci_bind(struct acpi_device *device) if (result) kfree(data); - return result; + return_VALUE(result); } int acpi_pci_unbind(struct acpi_device *device) @@ -277,13 +280,14 @@ int acpi_pci_unbind(struct acpi_device *device) char *pathname = NULL; struct acpi_buffer buffer = { 0, NULL }; + ACPI_FUNCTION_TRACE("acpi_pci_unbind"); if (!device || !device->parent) - return -EINVAL; + return_VALUE(-EINVAL); pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); if (!pathname) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(pathname, 0, ACPI_PATHNAME_MAX); buffer.length = ACPI_PATHNAME_MAX; @@ -297,18 +301,18 @@ 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))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to get data from device %s\n", + acpi_device_bid(device))); result = -ENODEV; goto end; } status = acpi_detach_data(device->handle, acpi_pci_data_handler); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, - "Unable to detach data from device %s", - acpi_device_bid(device))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to detach data from device %s\n", + acpi_device_bid(device))); result = -ENODEV; goto end; } @@ -318,7 +322,7 @@ int acpi_pci_unbind(struct acpi_device *device) kfree(data); end: - return result; + return_VALUE(result); } int @@ -331,10 +335,11 @@ acpi_pci_bind_root(struct acpi_device *device, char *pathname = NULL; struct acpi_buffer buffer = { 0, NULL }; + ACPI_FUNCTION_TRACE("acpi_pci_bind_root"); pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); if (!pathname) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(pathname, 0, ACPI_PATHNAME_MAX); buffer.length = ACPI_PATHNAME_MAX; @@ -342,13 +347,13 @@ acpi_pci_bind_root(struct acpi_device *device, if (!device || !id || !bus) { kfree(pathname); - return -EINVAL; + return_VALUE(-EINVAL); } data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); if (!data) { kfree(pathname); - return -ENOMEM; + return_VALUE(-ENOMEM); } memset(data, 0, sizeof(struct acpi_pci_data)); @@ -364,9 +369,9 @@ acpi_pci_bind_root(struct acpi_device *device, status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, - "Unable to attach ACPI-PCI context to device %s", - pathname)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to attach ACPI-PCI context to device %s\n", + pathname)); result = -ENODEV; goto end; } @@ -376,5 +381,5 @@ acpi_pci_bind_root(struct acpi_device *device, if (result != 0) kfree(data); - return result; + return_VALUE(result); } diff --git a/trunk/drivers/acpi/pci_irq.c b/trunk/drivers/acpi/pci_irq.c index fb96e3bf969b..65aee79b3971 100644 --- a/trunk/drivers/acpi/pci_irq.c +++ b/trunk/drivers/acpi/pci_irq.c @@ -55,9 +55,10 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, struct list_head *node = NULL; struct acpi_prt_entry *entry = NULL; + ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry"); if (!acpi_prt.count) - return NULL; + return_PTR(NULL); /* * Parse through all PRT entries looking for a match on the specified @@ -72,12 +73,12 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, && (device == entry->id.device) && (pin == entry->pin)) { spin_unlock(&acpi_prt_lock); - return entry; + return_PTR(entry); } } spin_unlock(&acpi_prt_lock); - return NULL; + return_PTR(NULL); } static int @@ -86,13 +87,14 @@ acpi_pci_irq_add_entry(acpi_handle handle, { struct acpi_prt_entry *entry = NULL; + ACPI_FUNCTION_TRACE("acpi_pci_irq_add_entry"); if (!prt) - return -EINVAL; + return_VALUE(-EINVAL); entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); if (!entry) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(entry, 0, sizeof(struct acpi_prt_entry)); entry->id.segment = segment; @@ -139,7 +141,7 @@ acpi_pci_irq_add_entry(acpi_handle handle, acpi_prt.count++; spin_unlock(&acpi_prt_lock); - return 0; + return_VALUE(0); } static void @@ -161,10 +163,11 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) struct acpi_pci_routing_table *entry = NULL; static int first_time = 1; + ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt"); pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); if (!pathname) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(pathname, 0, ACPI_PATHNAME_MAX); if (first_time) { @@ -194,24 +197,24 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) kfree(pathname); status = acpi_get_irq_routing_table(handle, &buffer); if (status != AE_BUFFER_OVERFLOW) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]", - acpi_format_exception(status))); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", + acpi_format_exception(status))); + return_VALUE(-ENODEV); } prt = kmalloc(buffer.length, GFP_KERNEL); if (!prt) { - return -ENOMEM; + return_VALUE(-ENOMEM); } memset(prt, 0, buffer.length); buffer.pointer = prt; status = acpi_get_irq_routing_table(handle, &buffer); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]", - acpi_format_exception(status))); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", + acpi_format_exception(status))); kfree(buffer.pointer); - return -ENODEV; + return_VALUE(-ENODEV); } entry = prt; @@ -224,7 +227,7 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) kfree(prt); - return 0; + return_VALUE(0); } void acpi_pci_irq_del_prt(int segment, int bus) @@ -259,15 +262,16 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry, { int irq; + ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq"); if (entry->link.handle) { irq = acpi_pci_link_allocate_irq(entry->link.handle, entry->link.index, triggering, polarity, link); if (irq < 0) { - printk(KERN_WARNING PREFIX - "Invalid IRQ link routing entry\n"); - return -1; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid IRQ link routing entry\n")); + return_VALUE(-1); } } else { irq = entry->link.index; @@ -276,7 +280,7 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry, } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); - return irq; + return_VALUE(irq); } static int @@ -285,12 +289,13 @@ acpi_pci_free_irq(struct acpi_prt_entry *entry, { int irq; + ACPI_FUNCTION_TRACE("acpi_pci_free_irq"); if (entry->link.handle) { irq = acpi_pci_link_free_irq(entry->link.handle); } else { irq = entry->link.index; } - return irq; + return_VALUE(irq); } /* @@ -310,6 +315,7 @@ acpi_pci_irq_lookup(struct pci_bus *bus, int bus_nr = bus->number; int ret; + ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup"); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Searching for PRT entry for %02x:%02x:%02x[%c]\n", @@ -318,11 +324,11 @@ acpi_pci_irq_lookup(struct pci_bus *bus, entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); if (!entry) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n")); - return -1; + return_VALUE(-1); } ret = func(entry, triggering, polarity, link); - return ret; + return_VALUE(ret); } /* @@ -340,9 +346,10 @@ acpi_pci_irq_derive(struct pci_dev *dev, int irq = -1; u8 bridge_pin = 0; + ACPI_FUNCTION_TRACE("acpi_pci_irq_derive"); if (!dev) - return -EINVAL; + return_VALUE(-EINVAL); /* * Attempt to derive an IRQ for this device from a parent bridge's @@ -359,7 +366,7 @@ acpi_pci_irq_derive(struct pci_dev *dev, ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No interrupt pin configured for device %s\n", pci_name(bridge))); - return -1; + return_VALUE(-1); } /* Pin is from 0 to 3 */ bridge_pin--; @@ -372,15 +379,16 @@ acpi_pci_irq_derive(struct pci_dev *dev, } if (irq < 0) { - printk(KERN_WARNING PREFIX "Unable to derive IRQ for device %s\n", - pci_name(dev)); - return -1; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Unable to derive IRQ for device %s\n", + pci_name(dev))); + return_VALUE(-1); } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", irq, pci_name(dev), pci_name(bridge))); - return irq; + return_VALUE(irq); } /* @@ -398,22 +406,24 @@ int acpi_pci_irq_enable(struct pci_dev *dev) char *link = NULL; int rc; + ACPI_FUNCTION_TRACE("acpi_pci_irq_enable"); if (!dev) - return -EINVAL; + return_VALUE(-EINVAL); pin = dev->pin; if (!pin) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No interrupt pin configured for device %s\n", pci_name(dev))); - return 0; + return_VALUE(0); } pin--; if (!dev->bus) { - printk(KERN_ERR PREFIX "Invalid (NULL) 'bus' field\n"); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid (NULL) 'bus' field\n")); + return_VALUE(-ENODEV); } /* @@ -445,10 +455,10 @@ int acpi_pci_irq_enable(struct pci_dev *dev) printk(" - using IRQ %d\n", dev->irq); acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW); - return 0; + return_VALUE(0); } else { printk("\n"); - return 0; + return_VALUE(0); } } @@ -456,7 +466,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) if (rc < 0) { printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " "to register GSI\n", pci_name(dev), ('A' + pin)); - return rc; + return_VALUE(rc); } dev->irq = rc; @@ -470,7 +480,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); - return 0; + return_VALUE(0); } EXPORT_SYMBOL(acpi_pci_irq_enable); @@ -487,13 +497,14 @@ void acpi_pci_irq_disable(struct pci_dev *dev) int triggering = ACPI_LEVEL_SENSITIVE; int polarity = ACPI_ACTIVE_LOW; + ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); if (!dev || !dev->bus) - return; + return_VOID; pin = dev->pin; if (!pin) - return; + return_VOID; pin--; /* @@ -511,7 +522,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev) &triggering, &polarity, NULL, acpi_pci_free_irq); if (gsi < 0) - return; + return_VOID; /* * TBD: It might be worth clearing dev->irq by magic constant @@ -523,5 +534,5 @@ void acpi_pci_irq_disable(struct pci_dev *dev) acpi_unregister_gsi(gsi); - return; + return_VOID; } diff --git a/trunk/drivers/acpi/pci_link.c b/trunk/drivers/acpi/pci_link.c index 1badce27a83f..228bdb626502 100644 --- a/trunk/drivers/acpi/pci_link.c +++ b/trunk/drivers/acpi/pci_link.c @@ -107,23 +107,26 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) struct acpi_pci_link *link = (struct acpi_pci_link *)context; u32 i = 0; + ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); switch (resource->type) { case ACPI_RESOURCE_TYPE_START_DEPENDENT: - return AE_OK; + return_ACPI_STATUS(AE_OK); case ACPI_RESOURCE_TYPE_IRQ: { struct acpi_resource_irq *p = &resource->data.irq; if (!p || !p->interrupt_count) { - printk(KERN_WARNING PREFIX "Blank IRQ resource\n"); - return AE_OK; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Blank IRQ resource\n")); + return_ACPI_STATUS(AE_OK); } for (i = 0; (i < p->interrupt_count && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { if (!p->interrupts[i]) { - printk(KERN_WARNING PREFIX "Invalid IRQ %d\n", - p->interrupts[i]); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid IRQ %d\n", + p->interrupts[i])); continue; } link->irq.possible[i] = p->interrupts[i]; @@ -139,16 +142,17 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) struct acpi_resource_extended_irq *p = &resource->data.extended_irq; if (!p || !p->interrupt_count) { - printk(KERN_WARNING PREFIX - "Blank EXT IRQ resource\n"); - return AE_OK; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Blank EXT IRQ resource\n")); + return_ACPI_STATUS(AE_OK); } for (i = 0; (i < p->interrupt_count && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { if (!p->interrupts[i]) { - printk(KERN_WARNING PREFIX "Invalid IRQ %d\n", - p->interrupts[i]); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid IRQ %d\n", + p->interrupts[i])); continue; } link->irq.possible[i] = p->interrupts[i]; @@ -160,33 +164,35 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) break; } default: - printk(KERN_ERR PREFIX "Resource is not an IRQ entry\n"); - return AE_OK; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Resource is not an IRQ entry\n")); + return_ACPI_STATUS(AE_OK); } - return AE_CTRL_TERMINATE; + return_ACPI_STATUS(AE_CTRL_TERMINATE); } static int acpi_pci_link_get_possible(struct acpi_pci_link *link) { acpi_status status; + ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible"); if (!link) - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_walk_resources(link->handle, METHOD_NAME__PRS, acpi_pci_link_check_possible, link); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRS")); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n")); + return_VALUE(-ENODEV); } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d possible IRQs\n", link->irq.possible_count)); - return 0; + return_VALUE(0); } static acpi_status @@ -194,6 +200,7 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) { int *irq = (int *)context; + ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); switch (resource->type) { case ACPI_RESOURCE_TYPE_IRQ: @@ -206,7 +213,7 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) */ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Blank IRQ resource\n")); - return AE_OK; + return_ACPI_STATUS(AE_OK); } *irq = p->interrupts[0]; break; @@ -220,20 +227,20 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) * extended IRQ descriptors must * return at least 1 IRQ */ - printk(KERN_WARNING PREFIX - "Blank EXT IRQ resource\n"); - return AE_OK; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Blank EXT IRQ resource\n")); + return_ACPI_STATUS(AE_OK); } *irq = p->interrupts[0]; break; } break; default: - printk(KERN_ERR PREFIX "Resource %d isn't an IRQ\n", resource->type); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource %d isn't an IRQ\n", resource->type)); case ACPI_RESOURCE_TYPE_END_TAG: - return AE_OK; + return_ACPI_STATUS(AE_OK); } - return AE_CTRL_TERMINATE; + return_ACPI_STATUS(AE_CTRL_TERMINATE); } /* @@ -249,9 +256,10 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link) acpi_status status = AE_OK; int irq = 0; + ACPI_FUNCTION_TRACE("acpi_pci_link_get_current"); if (!link || !link->handle) - return -EINVAL; + return_VALUE(-EINVAL); link->irq.active = 0; @@ -260,13 +268,14 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link) /* Query _STA, set link->device->status */ result = acpi_bus_get_status(link->device); if (result) { - printk(KERN_ERR PREFIX "Unable to read status\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to read status\n")); goto end; } if (!link->device->status.enabled) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n")); - return 0; + return_VALUE(0); } } @@ -277,13 +286,13 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link) status = acpi_walk_resources(link->handle, METHOD_NAME__CRS, acpi_pci_link_check_current, &irq); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _CRS")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n")); result = -ENODEV; goto end; } if (acpi_strict && !irq) { - printk(KERN_ERR PREFIX "_CRS returned 0\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_CRS returned 0\n")); result = -ENODEV; } @@ -292,7 +301,7 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active)); end: - return result; + return_VALUE(result); } static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) @@ -305,13 +314,14 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) } *resource; struct acpi_buffer buffer = { 0, NULL }; + ACPI_FUNCTION_TRACE("acpi_pci_link_set"); if (!link || !irq) - return -EINVAL; + return_VALUE(-EINVAL); resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC); if (!resource) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(resource, 0, sizeof(*resource) + 1); buffer.length = sizeof(*resource) + 1; @@ -352,7 +362,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) /* ignore resource_source, it's optional */ break; default: - printk(KERN_ERR PREFIX "Invalid Resource_type %d\n", link->irq.resource_type); + printk("ACPI BUG: resource_type %d\n", link->irq.resource_type); result = -EINVAL; goto end; @@ -364,7 +374,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) /* check for total failure */ if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SRS")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n")); result = -ENODEV; goto end; } @@ -372,14 +382,14 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) /* Query _STA, set device->status */ result = acpi_bus_get_status(link->device); if (result) { - printk(KERN_ERR PREFIX "Unable to read status\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n")); goto end; } if (!link->device->status.enabled) { printk(KERN_WARNING PREFIX - "%s [%s] disabled and referenced, BIOS bug\n", - acpi_device_name(link->device), - acpi_device_bid(link->device)); + "%s [%s] disabled and referenced, BIOS bug.\n", + acpi_device_name(link->device), + acpi_device_bid(link->device)); } /* Query _CRS, set link->irq.active */ @@ -398,9 +408,9 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) * assume _SRS worked and override _CRS value. */ printk(KERN_WARNING PREFIX - "%s [%s] BIOS reported IRQ %d, using IRQ %d\n", - acpi_device_name(link->device), - acpi_device_bid(link->device), link->irq.active, irq); + "%s [%s] BIOS reported IRQ %d, using IRQ %d\n", + acpi_device_name(link->device), + acpi_device_bid(link->device), link->irq.active, irq); link->irq.active = irq; } @@ -408,7 +418,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) end: kfree(resource); - return result; + return_VALUE(result); } /* -------------------------------------------------------------------------- @@ -482,6 +492,7 @@ int __init acpi_irq_penalty_init(void) struct acpi_pci_link *link = NULL; int i = 0; + ACPI_FUNCTION_TRACE("acpi_irq_penalty_init"); /* * Update penalties to facilitate IRQ balancing. @@ -490,7 +501,8 @@ int __init acpi_irq_penalty_init(void) link = list_entry(node, struct acpi_pci_link, node); if (!link) { - printk(KERN_ERR PREFIX "Invalid link context\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid link context\n")); continue; } @@ -518,7 +530,7 @@ int __init acpi_irq_penalty_init(void) /* Add a penalty for the SCI */ acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING; - return 0; + return_VALUE(0); } static int acpi_irq_balance; /* 0: static, 1: balance */ @@ -528,12 +540,13 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) int irq; int i; + ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); if (link->irq.initialized) { if (link->refcnt == 0) /* This means the link is disabled but initialized */ acpi_pci_link_set(link, link->irq.active); - return 0; + return_VALUE(0); } /* @@ -549,7 +562,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) if (i == link->irq.possible_count) { if (acpi_strict) printk(KERN_WARNING PREFIX "_CRS %d not found" - " in _PRS\n", link->irq.active); + " in _PRS\n", link->irq.active); link->irq.active = 0; } @@ -576,11 +589,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) /* Attempt to enable the link device at this IRQ. */ if (acpi_pci_link_set(link, irq)) { - printk(KERN_ERR PREFIX "Unable to set IRQ for %s [%s]. " - "Try pci=noacpi or acpi=off\n", - acpi_device_name(link->device), - acpi_device_bid(link->device)); - return -ENODEV; + printk(PREFIX + "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n" + "Try pci=noacpi or acpi=off\n", + acpi_device_name(link->device), + acpi_device_bid(link->device)); + return_VALUE(-ENODEV); } else { acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; printk(PREFIX "%s [%s] enabled at IRQ %d\n", @@ -590,7 +604,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) link->irq.initialized = 1; - return 0; + return_VALUE(0); } /* @@ -608,35 +622,36 @@ acpi_pci_link_allocate_irq(acpi_handle handle, struct acpi_device *device = NULL; struct acpi_pci_link *link = NULL; + ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq"); result = acpi_bus_get_device(handle, &device); if (result) { - printk(KERN_ERR PREFIX "Invalid link device\n"); - return -1; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); + return_VALUE(-1); } link = (struct acpi_pci_link *)acpi_driver_data(device); if (!link) { - printk(KERN_ERR PREFIX "Invalid link context\n"); - return -1; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); + return_VALUE(-1); } /* TBD: Support multiple index (IRQ) entries per Link Device */ if (index) { - printk(KERN_ERR PREFIX "Invalid index %d\n", index); - return -1; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index)); + return_VALUE(-1); } mutex_lock(&acpi_link_lock); if (acpi_pci_link_allocate(link)) { mutex_unlock(&acpi_link_lock); - return -1; + return_VALUE(-1); } if (!link->irq.active) { mutex_unlock(&acpi_link_lock); - printk(KERN_ERR PREFIX "Link active IRQ is 0!\n"); - return -1; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n")); + return_VALUE(-1); } link->refcnt++; mutex_unlock(&acpi_link_lock); @@ -650,7 +665,7 @@ acpi_pci_link_allocate_irq(acpi_handle handle, ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link %s is referenced\n", acpi_device_bid(link->device))); - return (link->irq.active); + return_VALUE(link->irq.active); } /* @@ -663,24 +678,25 @@ int acpi_pci_link_free_irq(acpi_handle handle) struct acpi_pci_link *link = NULL; acpi_status result; + ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq"); result = acpi_bus_get_device(handle, &device); if (result) { - printk(KERN_ERR PREFIX "Invalid link device\n"); - return -1; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); + return_VALUE(-1); } link = (struct acpi_pci_link *)acpi_driver_data(device); if (!link) { - printk(KERN_ERR PREFIX "Invalid link context\n"); - return -1; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); + return_VALUE(-1); } mutex_lock(&acpi_link_lock); if (!link->irq.initialized) { mutex_unlock(&acpi_link_lock); - printk(KERN_ERR PREFIX "Link isn't initialized\n"); - return -1; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n")); + return_VALUE(-1); } #ifdef FUTURE_USE /* @@ -702,7 +718,7 @@ int acpi_pci_link_free_irq(acpi_handle handle) acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); } mutex_unlock(&acpi_link_lock); - return (link->irq.active); + return_VALUE(link->irq.active); } /* -------------------------------------------------------------------------- @@ -716,13 +732,14 @@ static int acpi_pci_link_add(struct acpi_device *device) int i = 0; int found = 0; + ACPI_FUNCTION_TRACE("acpi_pci_link_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL); if (!link) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(link, 0, sizeof(struct acpi_pci_link)); link->device = device; @@ -771,16 +788,17 @@ static int acpi_pci_link_add(struct acpi_device *device) if (result) kfree(link); - return result; + return_VALUE(result); } static int acpi_pci_link_resume(struct acpi_pci_link *link) { + ACPI_FUNCTION_TRACE("acpi_pci_link_resume"); if (link->refcnt && link->irq.active && link->irq.initialized) - return (acpi_pci_link_set(link, link->irq.active)); + return_VALUE(acpi_pci_link_set(link, link->irq.active)); else - return 0; + return_VALUE(0); } /* @@ -793,6 +811,7 @@ static int irqrouter_resume(struct sys_device *dev) struct list_head *node = NULL; struct acpi_pci_link *link = NULL; + ACPI_FUNCTION_TRACE("irqrouter_resume"); /* Make sure SCI is enabled again (Apple firmware bug?) */ acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK); @@ -801,22 +820,24 @@ static int irqrouter_resume(struct sys_device *dev) list_for_each(node, &acpi_link.entries) { link = list_entry(node, struct acpi_pci_link, node); if (!link) { - printk(KERN_ERR PREFIX "Invalid link context\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid link context\n")); continue; } acpi_pci_link_resume(link); } acpi_in_resume = 0; - return 0; + return_VALUE(0); } static int acpi_pci_link_remove(struct acpi_device *device, int type) { struct acpi_pci_link *link = NULL; + ACPI_FUNCTION_TRACE("acpi_pci_link_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); link = (struct acpi_pci_link *)acpi_driver_data(device); @@ -826,7 +847,7 @@ static int acpi_pci_link_remove(struct acpi_device *device, int type) kfree(link); - return 0; + return_VALUE(0); } /* @@ -932,32 +953,34 @@ static int __init irqrouter_init_sysfs(void) { int error; + ACPI_FUNCTION_TRACE("irqrouter_init_sysfs"); if (acpi_disabled || acpi_noirq) - return 0; + return_VALUE(0); error = sysdev_class_register(&irqrouter_sysdev_class); if (!error) error = sysdev_register(&device_irqrouter); - return error; + return_VALUE(error); } device_initcall(irqrouter_init_sysfs); static int __init acpi_pci_link_init(void) { + ACPI_FUNCTION_TRACE("acpi_pci_link_init"); if (acpi_noirq) - return 0; + return_VALUE(0); acpi_link.count = 0; INIT_LIST_HEAD(&acpi_link.entries); if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0) - return -ENODEV; + return_VALUE(-ENODEV); - return 0; + return_VALUE(0); } subsys_initcall(acpi_pci_link_init); diff --git a/trunk/drivers/acpi/pci_root.c b/trunk/drivers/acpi/pci_root.c index 8f10442119f0..4c313eab6313 100644 --- a/trunk/drivers/acpi/pci_root.c +++ b/trunk/drivers/acpi/pci_root.c @@ -160,13 +160,14 @@ static int acpi_pci_root_add(struct acpi_device *device) unsigned long value = 0; acpi_handle handle = NULL; + ACPI_FUNCTION_TRACE("acpi_pci_root_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); if (!root) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(root, 0, sizeof(struct acpi_pci_root)); INIT_LIST_HEAD(&root->node); @@ -197,7 +198,7 @@ static int acpi_pci_root_add(struct acpi_device *device) root->id.segment = 0; break; default: - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SEG")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SEG\n")); result = -ENODEV; goto end; } @@ -218,7 +219,7 @@ static int acpi_pci_root_add(struct acpi_device *device) root->id.bus = 0; break; default: - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BBN")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BBN\n")); result = -ENODEV; goto end; } @@ -230,9 +231,8 @@ static int acpi_pci_root_add(struct acpi_device *device) int bus = 0; acpi_status status; - printk(KERN_ERR PREFIX - "Wrong _BBN value, reboot" - " and use option 'pci=noacpi'\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n")); status = try_get_root_bridge_busnr(root->handle, &bus); if (ACPI_FAILURE(status)) @@ -273,9 +273,9 @@ static int acpi_pci_root_add(struct acpi_device *device) */ root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus); if (!root->bus) { - printk(KERN_ERR PREFIX - "Bus %04x:%02x not present in PCI namespace\n", - root->id.segment, root->id.bus); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Bus %04x:%02x not present in PCI namespace\n", + root->id.segment, root->id.bus)); result = -ENODEV; goto end; } @@ -306,43 +306,46 @@ static int acpi_pci_root_add(struct acpi_device *device) kfree(root); } - return result; + return_VALUE(result); } static int acpi_pci_root_start(struct acpi_device *device) { struct acpi_pci_root *root; + ACPI_FUNCTION_TRACE("acpi_pci_root_start"); list_for_each_entry(root, &acpi_pci_roots, node) { if (root->handle == device->handle) { pci_bus_add_devices(root->bus); - return 0; + return_VALUE(0); } } - return -ENODEV; + return_VALUE(-ENODEV); } static int acpi_pci_root_remove(struct acpi_device *device, int type) { struct acpi_pci_root *root = NULL; + ACPI_FUNCTION_TRACE("acpi_pci_root_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); root = (struct acpi_pci_root *)acpi_driver_data(device); kfree(root); - return 0; + return_VALUE(0); } static int __init acpi_pci_root_init(void) { + ACPI_FUNCTION_TRACE("acpi_pci_root_init"); if (acpi_pci_disabled) - return 0; + return_VALUE(0); /* DEBUG: acpi_dbg_layer = ACPI_PCI_COMPONENT; @@ -350,9 +353,9 @@ static int __init acpi_pci_root_init(void) */ if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) - return -ENODEV; + return_VALUE(-ENODEV); - return 0; + return_VALUE(0); } subsys_initcall(acpi_pci_root_init); diff --git a/trunk/drivers/acpi/power.c b/trunk/drivers/acpi/power.c index 224f729f700e..62a5595ed8bc 100644 --- a/trunk/drivers/acpi/power.c +++ b/trunk/drivers/acpi/power.c @@ -98,21 +98,23 @@ acpi_power_get_context(acpi_handle handle, int result = 0; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_power_get_context"); if (!resource) - return -ENODEV; + return_VALUE(-ENODEV); result = acpi_bus_get_device(handle, &device); if (result) { - printk(KERN_WARNING PREFIX "Getting context [%p]\n", handle); - return result; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", + handle)); + return_VALUE(result); } *resource = (struct acpi_power_resource *)acpi_driver_data(device); if (!resource) - return -ENODEV; + return_VALUE(-ENODEV); - return 0; + return_VALUE(0); } static int acpi_power_get_state(struct acpi_power_resource *resource) @@ -120,13 +122,14 @@ static int acpi_power_get_state(struct acpi_power_resource *resource) acpi_status status = AE_OK; unsigned long sta = 0; + ACPI_FUNCTION_TRACE("acpi_power_get_state"); if (!resource) - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); if (sta & 0x01) resource->state = ACPI_POWER_RESOURCE_STATE_ON; @@ -136,7 +139,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", resource->name, resource->state ? "on" : "off")); - return 0; + return_VALUE(0); } static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) @@ -145,19 +148,20 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) struct acpi_power_resource *resource = NULL; u32 i = 0; + ACPI_FUNCTION_TRACE("acpi_power_get_list_state"); if (!list || !state) - return -EINVAL; + return_VALUE(-EINVAL); /* The state of the list is 'on' IFF all resources are 'on'. */ for (i = 0; i < list->count; i++) { result = acpi_power_get_context(list->handles[i], &resource); if (result) - return result; + return_VALUE(result); result = acpi_power_get_state(resource); if (result) - return result; + return_VALUE(result); *state = resource->state; @@ -168,7 +172,7 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", *state ? "on" : "off")); - return result; + return_VALUE(result); } static int acpi_power_on(acpi_handle handle) @@ -178,10 +182,11 @@ static int acpi_power_on(acpi_handle handle) struct acpi_device *device = NULL; struct acpi_power_resource *resource = NULL; + ACPI_FUNCTION_TRACE("acpi_power_on"); result = acpi_power_get_context(handle, &resource); if (result) - return result; + return_VALUE(result); resource->references++; @@ -189,29 +194,29 @@ static int acpi_power_on(acpi_handle handle) || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n", resource->name)); - return 0; + return_VALUE(0); } status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); result = acpi_power_get_state(resource); if (result) - return result; + return_VALUE(result); if (resource->state != ACPI_POWER_RESOURCE_STATE_ON) - return -ENOEXEC; + return_VALUE(-ENOEXEC); /* Update the power resource's _device_ power state */ result = acpi_bus_get_device(resource->handle, &device); if (result) - return result; + return_VALUE(result); device->power.state = ACPI_STATE_D0; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", resource->name)); - return 0; + return_VALUE(0); } static int acpi_power_off_device(acpi_handle handle) @@ -221,10 +226,11 @@ static int acpi_power_off_device(acpi_handle handle) struct acpi_device *device = NULL; struct acpi_power_resource *resource = NULL; + ACPI_FUNCTION_TRACE("acpi_power_off_device"); result = acpi_power_get_context(handle, &resource); if (result) - return result; + return_VALUE(result); if (resource->references) resource->references--; @@ -233,35 +239,35 @@ static int acpi_power_off_device(acpi_handle handle) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is still in use, dereferencing\n", device->pnp.bus_id)); - return 0; + return_VALUE(0); } if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", device->pnp.bus_id)); - return 0; + return_VALUE(0); } status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); result = acpi_power_get_state(resource); if (result) - return result; + return_VALUE(result); if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF) - return -ENOEXEC; + return_VALUE(-ENOEXEC); /* Update the power resource's _device_ power state */ result = acpi_bus_get_device(resource->handle, &device); if (result) - return result; + return_VALUE(result); device->power.state = ACPI_STATE_D3; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", resource->name)); - return 0; + return_VALUE(0); } /* @@ -277,29 +283,31 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev) int i; int ret = 0; + ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power"); if (!dev || !dev->wakeup.flags.valid) - return -1; + return_VALUE(-1); arg.integer.value = 1; /* Open power resource */ for (i = 0; i < dev->wakeup.resources.count; i++) { ret = acpi_power_on(dev->wakeup.resources.handles[i]); if (ret) { - printk(KERN_ERR PREFIX "Transition power state\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error transition power state\n")); dev->wakeup.flags.valid = 0; - return -1; + return_VALUE(-1); } } /* Execute PSW */ status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { - printk(KERN_ERR PREFIX "Evaluate _PSW\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); dev->wakeup.flags.valid = 0; ret = -1; } - return ret; + return_VALUE(ret); } /* @@ -315,30 +323,32 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev) int i; int ret = 0; + ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power"); if (!dev || !dev->wakeup.flags.valid) - return -1; + return_VALUE(-1); arg.integer.value = 0; /* Execute PSW */ status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { - printk(KERN_ERR PREFIX "Evaluate _PSW\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); dev->wakeup.flags.valid = 0; - return -1; + return_VALUE(-1); } /* Close power resource */ for (i = 0; i < dev->wakeup.resources.count; i++) { ret = acpi_power_off_device(dev->wakeup.resources.handles[i]); if (ret) { - printk(KERN_ERR PREFIX "Transition power state\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error transition power state\n")); dev->wakeup.flags.valid = 0; - return -1; + return_VALUE(-1); } } - return ret; + return_VALUE(ret); } /* -------------------------------------------------------------------------- @@ -352,9 +362,10 @@ int acpi_power_get_inferred_state(struct acpi_device *device) int list_state = 0; int i = 0; + ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); device->power.state = ACPI_STATE_UNKNOWN; @@ -369,17 +380,17 @@ int acpi_power_get_inferred_state(struct acpi_device *device) result = acpi_power_get_list_state(list, &list_state); if (result) - return result; + return_VALUE(result); if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { device->power.state = i; - return 0; + return_VALUE(0); } } device->power.state = ACPI_STATE_D3; - return 0; + return_VALUE(0); } int acpi_power_transition(struct acpi_device *device, int state) @@ -389,13 +400,14 @@ int acpi_power_transition(struct acpi_device *device, int state) struct acpi_handle_list *tl = NULL; /* Target Resources */ int i = 0; + ACPI_FUNCTION_TRACE("acpi_power_transition"); if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) - return -EINVAL; + return_VALUE(-EINVAL); if ((device->power.state < ACPI_STATE_D0) || (device->power.state > ACPI_STATE_D3)) - return -ENODEV; + return_VALUE(-ENODEV); cl = &device->power.states[device->power.state].resources; tl = &device->power.states[state].resources; @@ -432,10 +444,11 @@ int acpi_power_transition(struct acpi_device *device, int state) device->power.state = state; end: if (result) - printk(KERN_WARNING PREFIX "Transitioning device [%s] to D%d\n", - device->pnp.bus_id, state); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Error transitioning device [%s] to D%d\n", + device->pnp.bus_id, state)); - return result; + return_VALUE(result); } /* -------------------------------------------------------------------------- @@ -448,6 +461,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset) { struct acpi_power_resource *resource = NULL; + ACPI_FUNCTION_TRACE("acpi_power_seq_show"); resource = (struct acpi_power_resource *)seq->private; @@ -474,7 +488,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset) resource->order, resource->references); end: - return 0; + return_VALUE(0); } static int acpi_power_open_fs(struct inode *inode, struct file *file) @@ -486,32 +500,36 @@ static int acpi_power_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; + ACPI_FUNCTION_TRACE("acpi_power_add_fs"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_power_dir); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); } /* 'status' [R] */ entry = create_proc_entry(ACPI_POWER_FILE_STATUS, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -EIO; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_POWER_FILE_STATUS)); else { entry->proc_fops = &acpi_power_fops; entry->data = acpi_driver_data(device); } - return 0; + return_VALUE(0); } static int acpi_power_remove_fs(struct acpi_device *device) { + ACPI_FUNCTION_TRACE("acpi_power_remove_fs"); if (acpi_device_dir(device)) { remove_proc_entry(ACPI_POWER_FILE_STATUS, @@ -520,7 +538,7 @@ static int acpi_power_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -535,13 +553,14 @@ static int acpi_power_add(struct acpi_device *device) union acpi_object acpi_object; struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object }; + ACPI_FUNCTION_TRACE("acpi_power_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL); if (!resource) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(resource, 0, sizeof(struct acpi_power_resource)); resource->handle = device->handle; @@ -586,16 +605,17 @@ static int acpi_power_add(struct acpi_device *device) if (result) kfree(resource); - return result; + return_VALUE(result); } static int acpi_power_remove(struct acpi_device *device, int type) { struct acpi_power_resource *resource = NULL; + ACPI_FUNCTION_TRACE("acpi_power_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); resource = (struct acpi_power_resource *)acpi_driver_data(device); @@ -603,30 +623,31 @@ static int acpi_power_remove(struct acpi_device *device, int type) kfree(resource); - return 0; + return_VALUE(0); } static int __init acpi_power_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_power_init"); if (acpi_disabled) - return 0; + return_VALUE(0); INIT_LIST_HEAD(&acpi_power_resource_list); acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir); if (!acpi_power_dir) - return -ENODEV; + return_VALUE(-ENODEV); result = acpi_bus_register_driver(&acpi_power_driver); if (result < 0) { remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } subsys_initcall(acpi_power_init); diff --git a/trunk/drivers/acpi/processor_core.c b/trunk/drivers/acpi/processor_core.c index 52674323b14d..decaebb4cbe9 100644 --- a/trunk/drivers/acpi/processor_core.c +++ b/trunk/drivers/acpi/processor_core.c @@ -122,9 +122,10 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev) u8 value1 = 0; u8 value2 = 0; + ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4"); if (!dev) - return -EINVAL; + return_VALUE(-EINVAL); /* * Note that 'dev' references the PIIX4 ACPI Controller. @@ -217,7 +218,7 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Type-F DMA livelock erratum (C3 disabled)\n")); - return 0; + return_VALUE(0); } static int acpi_processor_errata(struct acpi_processor *pr) @@ -225,9 +226,10 @@ static int acpi_processor_errata(struct acpi_processor *pr) int result = 0; struct pci_dev *dev = NULL; + ACPI_FUNCTION_TRACE("acpi_processor_errata"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); /* * PIIX4 @@ -240,7 +242,7 @@ static int acpi_processor_errata(struct acpi_processor *pr) pci_dev_put(dev); } - return result; + return_VALUE(result); } /* -------------------------------------------------------------------------- @@ -256,9 +258,10 @@ static int acpi_processor_set_pdc(struct acpi_processor *pr) struct acpi_object_list *pdc_in = pr->pdc; acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_processor_set_pdc"); if (!pdc_in) - return status; + return_VALUE(status); status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL); @@ -266,7 +269,7 @@ static int acpi_processor_set_pdc(struct acpi_processor *pr) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not evaluate _PDC, using legacy perf. control...\n")); - return status; + return_VALUE(status); } /* -------------------------------------------------------------------------- @@ -279,6 +282,7 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) { struct acpi_processor *pr = (struct acpi_processor *)seq->private; + ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show"); if (!pr) goto end; @@ -297,7 +301,7 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) pr->flags.limit ? "yes" : "no"); end: - return 0; + return_VALUE(0); } static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) @@ -310,12 +314,13 @@ static int acpi_processor_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; + ACPI_FUNCTION_TRACE("acpi_processor_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_processor_dir); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); } acpi_device_dir(device)->owner = THIS_MODULE; @@ -323,7 +328,9 @@ static int acpi_processor_add_fs(struct acpi_device *device) entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -EIO; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_INFO)); else { entry->proc_fops = &acpi_processor_info_fops; entry->data = acpi_driver_data(device); @@ -335,7 +342,9 @@ static int acpi_processor_add_fs(struct acpi_device *device) S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - return -EIO; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_THROTTLING)); else { entry->proc_fops = &acpi_processor_throttling_fops; entry->data = acpi_driver_data(device); @@ -347,18 +356,21 @@ static int acpi_processor_add_fs(struct acpi_device *device) S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - return -EIO; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_LIMIT)); else { entry->proc_fops = &acpi_processor_limit_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return 0; + return_VALUE(0); } static int acpi_processor_remove_fs(struct acpi_device *device) { + ACPI_FUNCTION_TRACE("acpi_processor_remove_fs"); if (acpi_device_dir(device)) { remove_proc_entry(ACPI_PROCESSOR_FILE_INFO, @@ -371,7 +383,7 @@ static int acpi_processor_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* Use the acpiid in MADT to map cpus in case of SMP */ @@ -418,9 +430,10 @@ static int acpi_processor_get_info(struct acpi_processor *pr) int cpu_index; static int cpu0_initialized; + ACPI_FUNCTION_TRACE("acpi_processor_get_info"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); if (num_online_cpus() > 1) errata.smp = TRUE; @@ -446,8 +459,9 @@ static int acpi_processor_get_info(struct acpi_processor *pr) */ status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); if (ACPI_FAILURE(status)) { - printk(KERN_ERR PREFIX "Evaluating processor object\n"); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error evaluating processor object\n")); + return_VALUE(-ENODEV); } /* @@ -476,10 +490,10 @@ static int acpi_processor_get_info(struct acpi_processor *pr) if (cpu_index == -1) { if (ACPI_FAILURE (acpi_processor_hotadd_init(pr->handle, &pr->id))) { - printk(KERN_ERR PREFIX - "Getting cpuindex for acpiid 0x%x\n", - pr->acpi_id); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error getting cpuindex for acpiid 0x%x\n", + pr->acpi_id)); + return_VALUE(-ENODEV); } } @@ -489,8 +503,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr) if (!object.processor.pblk_address) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); else if (object.processor.pblk_length != 6) - printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n", - object.processor.pblk_length); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n", + object.processor.pblk_length)); else { pr->throttling.address = object.processor.pblk_address; pr->throttling.duty_offset = acpi_fadt.duty_offset; @@ -514,7 +528,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr) acpi_processor_get_throttling_info(pr); acpi_processor_get_limit_info(pr); - return 0; + return_VALUE(0); } static void *processor_device_array[NR_CPUS]; @@ -525,13 +539,14 @@ static int acpi_processor_start(struct acpi_device *device) acpi_status status = AE_OK; struct acpi_processor *pr; + ACPI_FUNCTION_TRACE("acpi_processor_start"); pr = acpi_driver_data(device); result = acpi_processor_get_info(pr); if (result) { /* Processor is physically not present */ - return 0; + return_VALUE(0); } BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0)); @@ -545,7 +560,7 @@ static int acpi_processor_start(struct acpi_device *device) processor_device_array[pr->id] != (void *)device) { printk(KERN_WARNING "BIOS reported wrong ACPI id" "for the processor\n"); - return -ENODEV; + return_VALUE(-ENODEV); } processor_device_array[pr->id] = (void *)device; @@ -557,6 +572,10 @@ static int acpi_processor_start(struct acpi_device *device) status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify, pr); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing device notify handler\n")); + } /* _PDC call should be done before doing anything else (if reqd.). */ arch_acpi_processor_init_pdc(pr); @@ -573,7 +592,7 @@ static int acpi_processor_start(struct acpi_device *device) end: - return result; + return_VALUE(result); } static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) @@ -581,12 +600,13 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) struct acpi_processor *pr = (struct acpi_processor *)data; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_processor_notify"); if (!pr) - return; + return_VOID; if (acpi_bus_get_device(pr->handle, &device)) - return; + return_VOID; switch (event) { case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: @@ -604,20 +624,21 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) break; } - return; + return_VOID; } static int acpi_processor_add(struct acpi_device *device) { struct acpi_processor *pr = NULL; + ACPI_FUNCTION_TRACE("acpi_processor_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL); if (!pr) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(pr, 0, sizeof(struct acpi_processor)); pr->handle = device->handle; @@ -625,7 +646,7 @@ static int acpi_processor_add(struct acpi_device *device) strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); acpi_driver_data(device) = pr; - return 0; + return_VALUE(0); } static int acpi_processor_remove(struct acpi_device *device, int type) @@ -633,26 +654,31 @@ static int acpi_processor_remove(struct acpi_device *device, int type) acpi_status status = AE_OK; struct acpi_processor *pr = NULL; + ACPI_FUNCTION_TRACE("acpi_processor_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); pr = (struct acpi_processor *)acpi_driver_data(device); if (pr->id >= NR_CPUS) { kfree(pr); - return 0; + return_VALUE(0); } if (type == ACPI_BUS_REMOVAL_EJECT) { if (acpi_processor_handle_eject(pr)) - return -EINVAL; + return_VALUE(-EINVAL); } acpi_processor_power_exit(pr, device); status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); + } acpi_processor_remove_fs(device); @@ -660,7 +686,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type) kfree(pr); - return 0; + return_VALUE(0); } #ifdef CONFIG_ACPI_HOTPLUG_CPU @@ -675,13 +701,15 @@ static int is_processor_present(acpi_handle handle) acpi_status status; unsigned long sta = 0; + ACPI_FUNCTION_TRACE("is_processor_present"); status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) { - ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present")); - return 0; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Processor Device is not present\n")); + return_VALUE(0); } - return 1; + return_VALUE(1); } static @@ -691,29 +719,30 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device) struct acpi_device *pdev; struct acpi_processor *pr; + ACPI_FUNCTION_TRACE("acpi_processor_device_add"); if (acpi_get_parent(handle, &phandle)) { - return -ENODEV; + return_VALUE(-ENODEV); } if (acpi_bus_get_device(phandle, &pdev)) { - return -ENODEV; + return_VALUE(-ENODEV); } if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { - return -ENODEV; + return_VALUE(-ENODEV); } acpi_bus_start(*device); pr = acpi_driver_data(*device); if (!pr) - return -ENODEV; + return_VALUE(-ENODEV); if ((pr->id >= 0) && (pr->id < NR_CPUS)) { kobject_uevent(&(*device)->kobj, KOBJ_ONLINE); } - return 0; + return_VALUE(0); } static void @@ -723,6 +752,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) struct acpi_device *device = NULL; int result; + ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify"); switch (event) { case ACPI_NOTIFY_BUS_CHECK: @@ -737,14 +767,15 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) if (acpi_bus_get_device(handle, &device)) { result = acpi_processor_device_add(handle, &device); if (result) - printk(KERN_ERR PREFIX - "Unable to add the device\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to add the device\n")); break; } pr = acpi_driver_data(device); if (!pr) { - printk(KERN_ERR PREFIX "Driver data is NULL\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Driver data is NULL\n")); break; } @@ -757,8 +788,9 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { kobject_uevent(&device->kobj, KOBJ_ONLINE); } else { - printk(KERN_ERR PREFIX "Device [%s] failed to start\n", - acpi_device_bid(device)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Device [%s] failed to start\n", + acpi_device_bid(device))); } break; case ACPI_NOTIFY_EJECT_REQUEST: @@ -766,15 +798,15 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) "received ACPI_NOTIFY_EJECT_REQUEST\n")); if (acpi_bus_get_device(handle, &device)) { - printk(KERN_ERR PREFIX - "Device don't exist, dropping EJECT\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Device don't exist, dropping EJECT\n")); break; } pr = acpi_driver_data(device); if (!pr) { - printk(KERN_ERR PREFIX - "Driver data is NULL, dropping EJECT\n"); - return; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Driver data is NULL, dropping EJECT\n")); + return_VOID; } if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) @@ -786,7 +818,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) break; } - return; + return_VOID; } static acpi_status @@ -825,20 +857,21 @@ processor_walk_namespace_cb(acpi_handle handle, static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) { + ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init"); if (!is_processor_present(handle)) { - return AE_ERROR; + return_VALUE(AE_ERROR); } if (acpi_map_lsapic(handle, p_cpu)) - return AE_ERROR; + return_VALUE(AE_ERROR); if (arch_register_cpu(*p_cpu)) { acpi_unmap_lsapic(*p_cpu); - return AE_ERROR; + return_VALUE(AE_ERROR); } - return AE_OK; + return_VALUE(AE_OK); } static int acpi_processor_handle_eject(struct acpi_processor *pr) @@ -895,19 +928,20 @@ static int __init acpi_processor_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_processor_init"); memset(&processors, 0, sizeof(processors)); memset(&errata, 0, sizeof(errata)); acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); if (!acpi_processor_dir) - return 0; + return_VALUE(0); acpi_processor_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_processor_driver); if (result < 0) { remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); - return 0; + return_VALUE(0); } acpi_processor_install_hotplug_notify(); @@ -916,11 +950,12 @@ static int __init acpi_processor_init(void) acpi_processor_ppc_init(); - return 0; + return_VALUE(0); } static void __exit acpi_processor_exit(void) { + ACPI_FUNCTION_TRACE("acpi_processor_exit"); acpi_processor_ppc_exit(); @@ -932,7 +967,7 @@ static void __exit acpi_processor_exit(void) remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); - return; + return_VOID; } module_init(acpi_processor_init); diff --git a/trunk/drivers/acpi/processor_idle.c b/trunk/drivers/acpi/processor_idle.c index e439eb77d283..8a74bf3efd8e 100644 --- a/trunk/drivers/acpi/processor_idle.c +++ b/trunk/drivers/acpi/processor_idle.c @@ -3,7 +3,7 @@ * * Copyright (C) 2001, 2002 Andy Grover * Copyright (C) 2001, 2002 Paul Diefenbaugh - * Copyright (C) 2004, 2005 Dominik Brodowski + * Copyright (C) 2004 Dominik Brodowski * Copyright (C) 2004 Anil S Keshavamurthy * - Added processor hotplug support * Copyright (C) 2005 Venkatesh Pallipadi @@ -97,9 +97,6 @@ static int set_max_cstate(struct dmi_system_id *id) /* Actually this shouldn't be __cpuinitdata, would be better to fix the callers to only run once -AK */ static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = { - { set_max_cstate, "IBM ThinkPad R40e", { - DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), - DMI_MATCH(DMI_BIOS_VERSION,"1SET70WW")}, (void *)1}, { set_max_cstate, "IBM ThinkPad R40e", { DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW")}, (void *)1}, @@ -264,15 +261,21 @@ static void acpi_processor_idle(void) u32 bm_status = 0; unsigned long diff = jiffies - pr->power.bm_check_timestamp; - if (diff > 31) - diff = 31; + if (diff > 32) + diff = 32; - pr->power.bm_activity <<= diff; + while (diff) { + /* if we didn't get called, assume there was busmaster activity */ + diff--; + if (diff) + pr->power.bm_activity |= 0x1; + pr->power.bm_activity <<= 1; + } acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status, ACPI_MTX_DO_NOT_LOCK); if (bm_status) { - pr->power.bm_activity |= 0x1; + pr->power.bm_activity++; acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); } @@ -284,16 +287,16 @@ static void acpi_processor_idle(void) else if (errata.piix4.bmisx) { if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01) || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) - pr->power.bm_activity |= 0x1; + pr->power.bm_activity++; } pr->power.bm_check_timestamp = jiffies; /* - * If bus mastering is or was active this jiffy, demote + * Apply bus mastering demotion policy. Automatically demote * to avoid a faulty transition. Note that the processor * won't enter a low-power state during this call (to this - * function) but should upon the next. + * funciton) but should upon the next. * * TBD: A better policy might be to fallback to the demotion * state (use it for this quantum only) istead of @@ -301,8 +304,7 @@ static void acpi_processor_idle(void) * qualification. This may, however, introduce DMA * issues (e.g. floppy DMA transfer overrun/underrun). */ - if ((pr->power.bm_activity & 0x1) && - cx->demotion.threshold.bm) { + if (pr->power.bm_activity & cx->demotion.threshold.bm) { local_irq_enable(); next_state = cx->demotion.state; goto end; @@ -320,6 +322,8 @@ static void acpi_processor_idle(void) cx = &pr->power.states[ACPI_STATE_C1]; #endif + cx->usage++; + /* * Sleep: * ------ @@ -361,9 +365,7 @@ static void acpi_processor_idle(void) t1 = inl(acpi_fadt.xpm_tmr_blk.address); /* Invoke C2 */ inb(cx->address); - /* Dummy wait op - must do something useless after P_LVL2 read - because chipsets cannot guarantee that STPCLK# signal - gets asserted in time to freeze execution properly. */ + /* Dummy op - must do something useless after P_LVL2 read */ t2 = inl(acpi_fadt.xpm_tmr_blk.address); /* Get end time (ticks) */ t2 = inl(acpi_fadt.xpm_tmr_blk.address); @@ -401,7 +403,7 @@ static void acpi_processor_idle(void) t1 = inl(acpi_fadt.xpm_tmr_blk.address); /* Invoke C3 */ inb(cx->address); - /* Dummy wait op (see above) */ + /* Dummy op - must do something useless after P_LVL3 read */ t2 = inl(acpi_fadt.xpm_tmr_blk.address); /* Get end time (ticks) */ t2 = inl(acpi_fadt.xpm_tmr_blk.address); @@ -428,9 +430,6 @@ static void acpi_processor_idle(void) local_irq_enable(); return; } - cx->usage++; - if ((cx->type != ACPI_STATE_C1) && (sleep_ticks > 0)) - cx->time += sleep_ticks; next_state = pr->power.state; @@ -518,9 +517,10 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr) struct acpi_processor_cx *higher = NULL; struct acpi_processor_cx *cx; + ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); /* * This function sets the default Cx state policy (OS idle handler). @@ -544,7 +544,7 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr) } if (!state_is_set) - return -ENODEV; + return_VALUE(-ENODEV); /* demotion */ for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { @@ -583,17 +583,18 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr) higher = cx; } - return 0; + return_VALUE(0); } static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) { + ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_fadt"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); if (!pr->pblk) - return -ENODEV; + return_VALUE(-ENODEV); /* if info is obtained from pblk/fadt, type equals state */ pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2; @@ -605,7 +606,7 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) * an SMP system. */ if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up) - return -ENODEV; + return_VALUE(-ENODEV); #endif /* determine C2 and C3 address from pblk */ @@ -621,11 +622,12 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) pr->power.states[ACPI_STATE_C2].address, pr->power.states[ACPI_STATE_C3].address)); - return 0; + return_VALUE(0); } static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) { + ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); /* Zero initialize all the C-states info. */ memset(pr->power.states, 0, sizeof(pr->power.states)); @@ -638,7 +640,7 @@ static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) pr->power.states[ACPI_STATE_C0].valid = 1; pr->power.states[ACPI_STATE_C1].valid = 1; - return 0; + return_VALUE(0); } static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) @@ -650,9 +652,10 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *cst; + ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst"); if (nocst) - return -ENODEV; + return_VALUE(-ENODEV); current_count = 1; @@ -664,14 +667,15 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n")); - return -ENODEV; + return_VALUE(-ENODEV); } cst = (union acpi_object *)buffer.pointer; /* There must be at least 2 elements */ if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { - printk(KERN_ERR PREFIX "not enough elements in _CST\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "not enough elements in _CST\n")); status = -EFAULT; goto end; } @@ -680,7 +684,8 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) /* Validate number of power states. */ if (count < 1 || count != cst->package.count - 1) { - printk(KERN_ERR PREFIX "count given by _CST is not valid\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "count given by _CST is not valid\n")); status = -EFAULT; goto end; } @@ -770,14 +775,15 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) end: acpi_os_free(buffer.pointer); - return status; + return_VALUE(status); } static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) { + ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c2"); if (!cx->address) - return; + return_VOID; /* * C2 latency must be less than or equal to 100 @@ -786,7 +792,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "latency too large [%d]\n", cx->latency)); - return; + return_VOID; } /* @@ -796,7 +802,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) cx->valid = 1; cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); - return; + return_VOID; } static void acpi_processor_power_verify_c3(struct acpi_processor *pr, @@ -804,9 +810,10 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr, { static int bm_check_flag; + ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3"); if (!cx->address) - return; + return_VOID; /* * C3 latency must be less than or equal to 1000 @@ -815,7 +822,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr, else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "latency too large [%d]\n", cx->latency)); - return; + return_VOID; } /* @@ -828,7 +835,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr, else if (errata.piix4.fdma) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "C3 not supported on PIIX4 with Type-F DMA\n")); - return; + return_VOID; } /* All the logic here assumes flags.bm_check is same across all CPUs */ @@ -845,7 +852,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr, if (!pr->flags.bm_control) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "C3 support requires bus mastering control\n")); - return; + return_VOID; } } else { /* @@ -856,7 +863,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr, ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cache invalidation should work properly" " for C3 to be enabled on SMP systems\n")); - return; + return_VOID; } acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK); @@ -871,7 +878,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr, cx->valid = 1; cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); - return; + return_VOID; } static int acpi_processor_power_verify(struct acpi_processor *pr) @@ -930,6 +937,7 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr) unsigned int i; int result; + ACPI_FUNCTION_TRACE("acpi_processor_get_power_info"); /* NOTE: the idle thread may not be running while calling * this function */ @@ -952,7 +960,7 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr) */ result = acpi_processor_set_power_policy(pr); if (result) - return result; + return_VALUE(result); /* * if one state of type C2 or C3 is available, mark this @@ -966,23 +974,24 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr) } } - return 0; + return_VALUE(0); } int acpi_processor_cst_has_changed(struct acpi_processor *pr) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_processor_cst_has_changed"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); if (nocst) { - return -ENODEV; + return_VALUE(-ENODEV); } if (!pr->flags.power_setup_done) - return -ENODEV; + return_VALUE(-ENODEV); /* Fall back to the default idle loop */ pm_idle = pm_idle_save; @@ -993,7 +1002,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) if ((pr->flags.power == 1) && (pr->flags.power_setup_done)) pm_idle = acpi_processor_idle; - return result; + return_VALUE(result); } /* proc interface */ @@ -1003,6 +1012,7 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) struct acpi_processor *pr = (struct acpi_processor *)seq->private; unsigned int i; + ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show"); if (!pr) goto end; @@ -1054,14 +1064,13 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) else seq_puts(seq, "demotion[--] "); - seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n", + seq_printf(seq, "latency[%03d] usage[%08d]\n", pr->power.states[i].latency, - pr->power.states[i].usage, - pr->power.states[i].time); + pr->power.states[i].usage); } end: - return 0; + return_VALUE(0); } static int acpi_processor_power_open_fs(struct inode *inode, struct file *file) @@ -1085,6 +1094,7 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct proc_dir_entry *entry = NULL; unsigned int i; + ACPI_FUNCTION_TRACE("acpi_processor_power_init"); if (!first_run) { dmi_check_system(processor_power_dmi_table); @@ -1096,14 +1106,14 @@ int acpi_processor_power_init(struct acpi_processor *pr, } if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); if (acpi_fadt.cst_cnt && !nocst) { status = acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, - "Notifying BIOS of _CST ability failed")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Notifying BIOS of _CST ability failed\n")); } } @@ -1132,7 +1142,9 @@ int acpi_processor_power_init(struct acpi_processor *pr, entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -EIO; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_POWER)); else { entry->proc_fops = &acpi_processor_power_fops; entry->data = acpi_driver_data(device); @@ -1141,12 +1153,13 @@ int acpi_processor_power_init(struct acpi_processor *pr, pr->flags.power_setup_done = 1; - return 0; + return_VALUE(0); } int acpi_processor_power_exit(struct acpi_processor *pr, struct acpi_device *device) { + ACPI_FUNCTION_TRACE("acpi_processor_power_exit"); pr->flags.power_setup_done = 0; @@ -1166,5 +1179,5 @@ int acpi_processor_power_exit(struct acpi_processor *pr, cpu_idle_wait(); } - return 0; + return_VALUE(0); } diff --git a/trunk/drivers/acpi/processor_perflib.c b/trunk/drivers/acpi/processor_perflib.c index 14a00e5a8f6a..41aaaba74b19 100644 --- a/trunk/drivers/acpi/processor_perflib.c +++ b/trunk/drivers/acpi/processor_perflib.c @@ -108,9 +108,10 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr) acpi_status status = 0; unsigned long ppc = 0; + ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); /* * _PPC indicates the maximum state currently supported by the platform @@ -122,13 +123,13 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr) acpi_processor_ppc_status |= PPC_IN_USE; if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC")); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n")); + return_VALUE(-ENODEV); } pr->performance_platform_limit = (int)ppc; - return 0; + return_VALUE(0); } int acpi_processor_ppc_has_changed(struct acpi_processor *pr) @@ -167,17 +168,18 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr) union acpi_object *pct = NULL; union acpi_object obj = { 0 }; + ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control"); status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT")); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n")); + return_VALUE(-ENODEV); } pct = (union acpi_object *)buffer.pointer; if (!pct || (pct->type != ACPI_TYPE_PACKAGE) || (pct->package.count != 2)) { - printk(KERN_ERR PREFIX "Invalid _PCT data\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n")); result = -EFAULT; goto end; } @@ -191,7 +193,8 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr) if ((obj.type != ACPI_TYPE_BUFFER) || (obj.buffer.length < sizeof(struct acpi_pct_register)) || (obj.buffer.pointer == NULL)) { - printk(KERN_ERR PREFIX "Invalid _PCT data (control_register)\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid _PCT data (control_register)\n")); result = -EFAULT; goto end; } @@ -207,7 +210,8 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr) if ((obj.type != ACPI_TYPE_BUFFER) || (obj.buffer.length < sizeof(struct acpi_pct_register)) || (obj.buffer.pointer == NULL)) { - printk(KERN_ERR PREFIX "Invalid _PCT data (status_register)\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid _PCT data (status_register)\n")); result = -EFAULT; goto end; } @@ -218,7 +222,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr) end: acpi_os_free(buffer.pointer); - return result; + return_VALUE(result); } static int acpi_processor_get_performance_states(struct acpi_processor *pr) @@ -231,16 +235,17 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr) union acpi_object *pss = NULL; int i; + ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states"); status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS")); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n")); + return_VALUE(-ENODEV); } pss = (union acpi_object *)buffer.pointer; if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) { - printk(KERN_ERR PREFIX "Invalid _PSS data\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n")); result = -EFAULT; goto end; } @@ -269,7 +274,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr) status = acpi_extract_package(&(pss->package.elements[i]), &format, &state); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Invalid _PSS data")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid _PSS data\n")); result = -EFAULT; kfree(pr->performance->states); goto end; @@ -285,8 +291,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr) (u32) px->control, (u32) px->status)); if (!px->core_frequency) { - printk(KERN_ERR PREFIX - "Invalid _PSS data: freq is zero\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid _PSS data: freq is zero\n")); result = -EFAULT; kfree(pr->performance->states); goto end; @@ -296,7 +302,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr) end: acpi_os_free(buffer.pointer); - return result; + return_VALUE(result); } static int acpi_processor_get_performance_info(struct acpi_processor *pr) @@ -305,30 +311,31 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr) acpi_status status = AE_OK; acpi_handle handle = NULL; + ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info"); if (!pr || !pr->performance || !pr->handle) - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_get_handle(pr->handle, "_PCT", &handle); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI-based processor performance control unavailable\n")); - return -ENODEV; + return_VALUE(-ENODEV); } result = acpi_processor_get_performance_control(pr); if (result) - return result; + return_VALUE(result); result = acpi_processor_get_performance_states(pr); if (result) - return result; + return_VALUE(result); result = acpi_processor_get_platform_limit(pr); if (result) - return result; + return_VALUE(result); - return 0; + return_VALUE(0); } int acpi_processor_notify_smm(struct module *calling_module) @@ -336,12 +343,13 @@ int acpi_processor_notify_smm(struct module *calling_module) acpi_status status; static int is_done = 0; + ACPI_FUNCTION_TRACE("acpi_processor_notify_smm"); if (!(acpi_processor_ppc_status & PPC_REGISTERED)) - return -EBUSY; + return_VALUE(-EBUSY); if (!try_module_get(calling_module)) - return -EINVAL; + return_VALUE(-EINVAL); /* is_done is set to negative if an error occured, * and to postitive if _no_ error occured, but SMM @@ -350,10 +358,10 @@ int acpi_processor_notify_smm(struct module *calling_module) */ if (is_done > 0) { module_put(calling_module); - return 0; + return_VALUE(0); } else if (is_done < 0) { module_put(calling_module); - return is_done; + return_VALUE(is_done); } is_done = -EIO; @@ -362,7 +370,7 @@ int acpi_processor_notify_smm(struct module *calling_module) if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n")); module_put(calling_module); - return 0; + return_VALUE(0); } ACPI_DEBUG_PRINT((ACPI_DB_INFO, @@ -379,12 +387,12 @@ int acpi_processor_notify_smm(struct module *calling_module) status = acpi_os_write_port(acpi_fadt.smi_cmd, (u32) acpi_fadt.pstate_cnt, 8); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, - "Failed to write pstate_cnt [0x%x] to " - "smi_cmd [0x%x]", acpi_fadt.pstate_cnt, - acpi_fadt.smi_cmd)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Failed to write pstate_cnt [0x%x] to " + "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, + acpi_fadt.smi_cmd)); module_put(calling_module); - return status; + return_VALUE(status); } /* Success. If there's no _PPC, we need to fear nothing, so @@ -394,7 +402,7 @@ int acpi_processor_notify_smm(struct module *calling_module) if (!(acpi_processor_ppc_status & PPC_IN_USE)) module_put(calling_module); - return 0; + return_VALUE(0); } EXPORT_SYMBOL(acpi_processor_notify_smm); @@ -415,6 +423,7 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset) struct acpi_processor *pr = (struct acpi_processor *)seq->private; int i; + ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show"); if (!pr) goto end; @@ -438,7 +447,7 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset) (u32) pr->performance->states[i].transition_latency); end: - return 0; + return_VALUE(0); } static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) @@ -460,22 +469,23 @@ acpi_processor_write_performance(struct file *file, unsigned int new_state = 0; struct cpufreq_policy policy; + ACPI_FUNCTION_TRACE("acpi_processor_write_performance"); if (!pr || (count > sizeof(state_string) - 1)) - return -EINVAL; + return_VALUE(-EINVAL); perf = pr->performance; if (!perf) - return -EINVAL; + return_VALUE(-EINVAL); if (copy_from_user(state_string, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); state_string[count] = '\0'; new_state = simple_strtoul(state_string, NULL, 0); if (new_state >= perf->state_count) - return -EINVAL; + return_VALUE(-EINVAL); cpufreq_get_policy(&policy, pr->id); @@ -485,9 +495,9 @@ acpi_processor_write_performance(struct file *file, result = cpufreq_set_policy(&policy); if (result) - return result; + return_VALUE(result); - return count; + return_VALUE(count); } static void acpi_cpufreq_add_file(struct acpi_processor *pr) @@ -495,36 +505,42 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr) struct proc_dir_entry *entry = NULL; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile"); if (acpi_bus_get_device(pr->handle, &device)) - return; + return_VOID; /* add file 'performance' [R/W] */ entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); - if (entry){ + if (!entry) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_PROCESSOR_FILE_PERFORMANCE)); + else { acpi_processor_perf_fops.write = acpi_processor_write_performance; entry->proc_fops = &acpi_processor_perf_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return; + return_VOID; } static void acpi_cpufreq_remove_file(struct acpi_processor *pr) { struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile"); if (acpi_bus_get_device(pr->handle, &device)) - return; + return_VOID; /* remove file 'performance' */ remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, acpi_device_dir(device)); - return; + return_VOID; } #else @@ -682,12 +698,12 @@ int acpi_processor_preregister_performance( /* Validate the Domain info */ count_target = pdomain->num_processors; count = 1; - if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL) + if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL || + pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) { pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; - else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) - pr->performance->shared_type = CPUFREQ_SHARED_TYPE_HW; - else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY) + } else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY) { pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY; + } for_each_possible_cpu(j) { if (i == j) @@ -768,21 +784,22 @@ acpi_processor_register_performance(struct acpi_processor_performance { struct acpi_processor *pr; + ACPI_FUNCTION_TRACE("acpi_processor_register_performance"); if (!(acpi_processor_ppc_status & PPC_REGISTERED)) - return -EINVAL; + return_VALUE(-EINVAL); mutex_lock(&performance_mutex); pr = processors[cpu]; if (!pr) { mutex_unlock(&performance_mutex); - return -ENODEV; + return_VALUE(-ENODEV); } if (pr->performance) { mutex_unlock(&performance_mutex); - return -EBUSY; + return_VALUE(-EBUSY); } WARN_ON(!performance); @@ -792,13 +809,13 @@ acpi_processor_register_performance(struct acpi_processor_performance if (acpi_processor_get_performance_info(pr)) { pr->performance = NULL; mutex_unlock(&performance_mutex); - return -EIO; + return_VALUE(-EIO); } acpi_cpufreq_add_file(pr); mutex_unlock(&performance_mutex); - return 0; + return_VALUE(0); } EXPORT_SYMBOL(acpi_processor_register_performance); @@ -809,13 +826,14 @@ acpi_processor_unregister_performance(struct acpi_processor_performance { struct acpi_processor *pr; + ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance"); mutex_lock(&performance_mutex); pr = processors[cpu]; if (!pr) { mutex_unlock(&performance_mutex); - return; + return_VOID; } if (pr->performance) @@ -826,7 +844,7 @@ acpi_processor_unregister_performance(struct acpi_processor_performance mutex_unlock(&performance_mutex); - return; + return_VOID; } EXPORT_SYMBOL(acpi_processor_unregister_performance); diff --git a/trunk/drivers/acpi/processor_thermal.c b/trunk/drivers/acpi/processor_thermal.c index ef5e0f6efdba..f99ad05cd6a2 100644 --- a/trunk/drivers/acpi/processor_thermal.c +++ b/trunk/drivers/acpi/processor_thermal.c @@ -54,12 +54,13 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr) u16 px = 0; u16 tx = 0; + ACPI_FUNCTION_TRACE("acpi_processor_apply_limit"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); if (!pr->flags.limit) - return -ENODEV; + return_VALUE(-ENODEV); if (pr->flags.throttling) { if (pr->limit.user.tx > tx) @@ -81,9 +82,9 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr) end: if (result) - printk(KERN_ERR PREFIX "Unable to set limit\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n")); - return result; + return_VALUE(result); } #ifdef CONFIG_CPU_FREQ @@ -199,18 +200,19 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type) struct acpi_device *device = NULL; int tx = 0, max_tx_px = 0; + ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit"); if ((type < ACPI_PROCESSOR_LIMIT_NONE) || (type > ACPI_PROCESSOR_LIMIT_DECREMENT)) - return -EINVAL; + return_VALUE(-EINVAL); result = acpi_bus_get_device(handle, &device); if (result) - return result; + return_VALUE(result); pr = (struct acpi_processor *)acpi_driver_data(device); if (!pr) - return -ENODEV; + return_VALUE(-ENODEV); /* Thermal limits are always relative to the current Px/Tx state. */ if (pr->flags.throttling) @@ -287,28 +289,30 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type) result = acpi_processor_apply_limit(pr); if (result) - printk(KERN_ERR PREFIX "Unable to set thermal limit\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to set thermal limit\n")); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n", pr->limit.thermal.px, pr->limit.thermal.tx)); } else result = 0; if (max_tx_px) - return 1; + return_VALUE(1); else - return result; + return_VALUE(result); } int acpi_processor_get_limit_info(struct acpi_processor *pr) { + ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); if (pr->flags.throttling) pr->flags.limit = 1; - return 0; + return_VALUE(0); } /* /proc interface */ @@ -317,6 +321,7 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset) { struct acpi_processor *pr = (struct acpi_processor *)seq->private; + ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show"); if (!pr) goto end; @@ -334,7 +339,7 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset) pr->limit.thermal.px, pr->limit.thermal.tx); end: - return 0; + return_VALUE(0); } static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file) @@ -354,33 +359,36 @@ static ssize_t acpi_processor_write_limit(struct file * file, int px = 0; int tx = 0; + ACPI_FUNCTION_TRACE("acpi_processor_write_limit"); if (!pr || (count > sizeof(limit_string) - 1)) { - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n")); + return_VALUE(-EINVAL); } if (copy_from_user(limit_string, buffer, count)) { - return -EFAULT; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); + return_VALUE(-EFAULT); } limit_string[count] = '\0'; if (sscanf(limit_string, "%d:%d", &px, &tx) != 2) { - printk(KERN_ERR PREFIX "Invalid data format\n"); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); + return_VALUE(-EINVAL); } if (pr->flags.throttling) { if ((tx < 0) || (tx > (pr->throttling.state_count - 1))) { - printk(KERN_ERR PREFIX "Invalid tx\n"); - return -EINVAL; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid tx\n")); + return_VALUE(-EINVAL); } pr->limit.user.tx = tx; } result = acpi_processor_apply_limit(pr); - return count; + return_VALUE(count); } struct file_operations acpi_processor_limit_fops = { diff --git a/trunk/drivers/acpi/processor_throttling.c b/trunk/drivers/acpi/processor_throttling.c index d044ec519db0..b966549ec000 100644 --- a/trunk/drivers/acpi/processor_throttling.c +++ b/trunk/drivers/acpi/processor_throttling.c @@ -55,12 +55,13 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr) u32 duty_mask = 0; u32 duty_value = 0; + ACPI_FUNCTION_TRACE("acpi_processor_get_throttling"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); if (!pr->flags.throttling) - return -ENODEV; + return_VALUE(-ENODEV); pr->throttling.state = 0; @@ -92,7 +93,7 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr) "Throttling state is T%d (%d%% throttling applied)\n", state, pr->throttling.states[state].performance)); - return 0; + return_VALUE(0); } int acpi_processor_set_throttling(struct acpi_processor *pr, int state) @@ -101,18 +102,19 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) u32 duty_mask = 0; u32 duty_value = 0; + ACPI_FUNCTION_TRACE("acpi_processor_set_throttling"); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); if ((state < 0) || (state > (pr->throttling.state_count - 1))) - return -EINVAL; + return_VALUE(-EINVAL); if (!pr->flags.throttling) - return -ENODEV; + return_VALUE(-ENODEV); if (state == pr->throttling.state) - return 0; + return_VALUE(0); /* * Calculate the duty_value and duty_mask. @@ -163,7 +165,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) (pr->throttling.states[state].performance ? pr-> throttling.states[state].performance / 10 : 0))); - return 0; + return_VALUE(0); } int acpi_processor_get_throttling_info(struct acpi_processor *pr) @@ -172,6 +174,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) int step = 0; int i = 0; + ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info"); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", @@ -180,21 +183,21 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) pr->throttling.duty_width)); if (!pr) - return -EINVAL; + return_VALUE(-EINVAL); /* TBD: Support ACPI 2.0 objects */ if (!pr->throttling.address) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); - return 0; + return_VALUE(0); } else if (!pr->throttling.duty_width) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); - return 0; + return_VALUE(0); } /* TBD: Support duty_cycle values that span bit 4. */ else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { - printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n"); - return 0; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n")); + return_VALUE(0); } /* @@ -205,7 +208,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) if (errata.piix4.throttle) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Throttling not supported on PIIX4 A- or B-step\n")); - return 0; + return_VALUE(0); } pr->throttling.state_count = 1 << acpi_fadt.duty_width; @@ -251,7 +254,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) if (result) pr->flags.throttling = 0; - return result; + return_VALUE(result); } /* proc interface */ @@ -263,6 +266,7 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq, int i = 0; int result = 0; + ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show"); if (!pr) goto end; @@ -292,7 +296,7 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq, throttling.states[i].performance / 10 : 0)); end: - return 0; + return_VALUE(0); } static int acpi_processor_throttling_open_fs(struct inode *inode, @@ -311,12 +315,13 @@ static ssize_t acpi_processor_write_throttling(struct file * file, struct acpi_processor *pr = (struct acpi_processor *)m->private; char state_string[12] = { '\0' }; + ACPI_FUNCTION_TRACE("acpi_processor_write_throttling"); if (!pr || (count > sizeof(state_string) - 1)) - return -EINVAL; + return_VALUE(-EINVAL); if (copy_from_user(state_string, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); state_string[count] = '\0'; @@ -324,9 +329,9 @@ static ssize_t acpi_processor_write_throttling(struct file * file, simple_strtoul(state_string, NULL, 0)); if (result) - return result; + return_VALUE(result); - return count; + return_VALUE(count); } struct file_operations acpi_processor_throttling_fops = { diff --git a/trunk/drivers/acpi/scan.c b/trunk/drivers/acpi/scan.c index 861ac378ce42..f8316a05ede7 100644 --- a/trunk/drivers/acpi/scan.c +++ b/trunk/drivers/acpi/scan.c @@ -162,10 +162,11 @@ 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; + return_VOID; } static int acpi_bus_get_power_flags(struct acpi_device *device) @@ -174,6 +175,7 @@ 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 @@ -226,7 +228,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device) device->power.state = ACPI_STATE_UNKNOWN; - return 0; + return_VALUE(0); } int acpi_match_ids(struct acpi_device *device, char *ids) @@ -304,18 +306,20 @@ 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_EXCEPTION((AE_INFO, status, "Evaluating _PRW")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRW\n")); goto end; } package = (union acpi_object *)buffer.pointer; status = acpi_bus_extract_wakeup_device_power_package(device, package); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error extracting _PRW package\n")); goto end; } @@ -329,7 +333,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device) end: if (ACPI_FAILURE(status)) device->flags.wake_capable = 0; - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -485,18 +489,19 @@ 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 -EINVAL; + return_VALUE(-EINVAL); if (!driver->ops.add) - return -ENOSYS; + return_VALUE(-ENOSYS); result = driver->ops.add(device); if (result) { device->driver = NULL; acpi_driver_data(device) = NULL; - return result; + return_VALUE(result); } device->driver = driver; @@ -508,7 +513,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 0; + return_VALUE(0); } static int acpi_start_single_object(struct acpi_device *device) @@ -516,9 +521,10 @@ 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 0; + return_VALUE(0); if (driver->ops.start) { result = driver->ops.start(device); @@ -526,13 +532,14 @@ static int acpi_start_single_object(struct acpi_device *device) driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); } - return result; + return_VALUE(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) { @@ -561,6 +568,7 @@ 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) { @@ -590,16 +598,17 @@ 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 -ENODEV; + return_VALUE(-ENODEV); spin_lock(&acpi_device_lock); list_add_tail(&driver->node, &acpi_bus_drivers); spin_unlock(&acpi_device_lock); acpi_driver_attach(driver); - return 0; + return_VALUE(0); } EXPORT_SYMBOL(acpi_bus_register_driver); @@ -637,6 +646,7 @@ 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) { @@ -656,41 +666,19 @@ static int acpi_bus_find_driver(struct acpi_device *device) spin_unlock(&acpi_device_lock); Done: - return result; + return_VALUE(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); @@ -736,7 +724,7 @@ static int acpi_bus_get_flags(struct acpi_device *device) /* TBD: Peformance management */ - return 0; + return_VALUE(0); } static void acpi_device_get_busid(struct acpi_device *device, @@ -930,9 +918,10 @@ 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 -EINVAL; + return_VALUE(-EINVAL); driver = dev->driver; @@ -941,12 +930,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 result; + return_VALUE(result); } result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT); if (result) { - return result; + return_VALUE(result); } atomic_dec(&dev->driver->references); @@ -955,7 +944,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) } if (!rmdevice) - return 0; + return_VALUE(0); if (dev->flags.bus_address) { if ((dev->parent) && (dev->parent->ops.unbind)) @@ -964,7 +953,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); - return 0; + return_VALUE(0); } static int @@ -974,14 +963,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 -EINVAL; + return_VALUE(-EINVAL); device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL); if (!device) { - printk(KERN_ERR PREFIX "Memory allocation error\n"); - return -ENOMEM; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); + return_VALUE(-ENOMEM); } memset(device, 0, sizeof(struct acpi_device)); @@ -1106,7 +1096,7 @@ acpi_add_single_object(struct acpi_device **child, kfree(device); } - return result; + return_VALUE(result); } static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) @@ -1119,9 +1109,10 @@ 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 -EINVAL; + return_VALUE(-EINVAL); parent = start; phandle = start->handle; @@ -1218,7 +1209,7 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) } } - return 0; + return_VALUE(0); } int @@ -1228,6 +1219,7 @@ 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) { @@ -1235,7 +1227,7 @@ acpi_bus_add(struct acpi_device **child, ops.acpi_op_add = 1; result = acpi_bus_scan(*child, &ops); } - return result; + return_VALUE(result); } EXPORT_SYMBOL(acpi_bus_add); @@ -1245,9 +1237,10 @@ int acpi_bus_start(struct acpi_device *device) int result; struct acpi_bus_ops ops; + ACPI_FUNCTION_TRACE("acpi_bus_start"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); result = acpi_start_single_object(device); if (!result) { @@ -1255,7 +1248,7 @@ int acpi_bus_start(struct acpi_device *device) ops.acpi_op_start = 1; result = acpi_bus_scan(device, &ops); } - return result; + return_VALUE(result); } EXPORT_SYMBOL(acpi_bus_start); @@ -1321,9 +1314,10 @@ 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 -ENODEV; + return_VALUE(-ENODEV); /* * Enumerate all fixed-feature devices. @@ -1344,7 +1338,7 @@ static int acpi_bus_scan_fixed(struct acpi_device *root) result = acpi_start_single_object(device); } - return result; + return_VALUE(result); } @@ -1433,7 +1427,7 @@ static int acpi_device_resume(struct device * dev) } -static struct bus_type acpi_bus_type = { +struct bus_type acpi_bus_type = { .name = "acpi", .suspend = acpi_device_suspend, .resume = acpi_device_resume, @@ -1446,9 +1440,10 @@ static int __init acpi_scan_init(void) int result; struct acpi_bus_ops ops; + ACPI_FUNCTION_TRACE("acpi_scan_init"); if (acpi_disabled) - return 0; + return_VALUE(0); kset_register(&acpi_namespace_kset); @@ -1493,7 +1488,7 @@ static int __init acpi_scan_init(void) acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); Done: - return result; + return_VALUE(result); } subsys_initcall(acpi_scan_init); diff --git a/trunk/drivers/acpi/system.c b/trunk/drivers/acpi/system.c index c90bd2f70b3f..a934ac42178d 100644 --- a/trunk/drivers/acpi/system.c +++ b/trunk/drivers/acpi/system.c @@ -47,9 +47,10 @@ extern struct fadt_descriptor acpi_fadt; static int acpi_system_read_info(struct seq_file *seq, void *offset) { + ACPI_FUNCTION_TRACE("acpi_system_read_info"); seq_printf(seq, "version: %x\n", ACPI_CA_VERSION); - return 0; + return_VALUE(0); } static int acpi_system_info_open_fs(struct inode *inode, struct file *file) @@ -79,16 +80,17 @@ acpi_system_read_dsdt(struct file *file, struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL }; ssize_t res; + ACPI_FUNCTION_TRACE("acpi_system_read_dsdt"); status = acpi_get_table(ACPI_TABLE_ID_DSDT, 1, &dsdt); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); res = simple_read_from_buffer(buffer, count, ppos, dsdt.pointer, dsdt.length); acpi_os_free(dsdt.pointer); - return res; + return_VALUE(res); } static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, @@ -106,16 +108,17 @@ acpi_system_read_fadt(struct file *file, struct acpi_buffer fadt = { ACPI_ALLOCATE_BUFFER, NULL }; ssize_t res; + ACPI_FUNCTION_TRACE("acpi_system_read_fadt"); status = acpi_get_table(ACPI_TABLE_ID_FADT, 1, &fadt); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); res = simple_read_from_buffer(buffer, count, ppos, fadt.pointer, fadt.length); acpi_os_free(fadt.pointer); - return res; + return_VALUE(res); } static int __init acpi_system_init(void) @@ -124,9 +127,10 @@ static int __init acpi_system_init(void) int error = 0; char *name; + ACPI_FUNCTION_TRACE("acpi_system_init"); if (acpi_disabled) - return 0; + return_VALUE(0); /* 'info' [R] */ name = ACPI_SYSTEM_FILE_INFO; @@ -154,9 +158,12 @@ static int __init acpi_system_init(void) goto Error; Done: - return error; + return_VALUE(error); Error: + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' proc fs entry\n", name)); + remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir); diff --git a/trunk/drivers/acpi/thermal.c b/trunk/drivers/acpi/thermal.c index c855f4446b5f..e7fe3a14fdaf 100644 --- a/trunk/drivers/acpi/thermal.c +++ b/trunk/drivers/acpi/thermal.c @@ -222,48 +222,51 @@ static int acpi_thermal_get_temperature(struct acpi_thermal *tz) { acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature"); if (!tz) - return -EINVAL; + return_VALUE(-EINVAL); tz->last_temperature = tz->temperature; status = acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", tz->temperature)); - return 0; + return_VALUE(0); } static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) { acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency"); if (!tz) - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_evaluate_integer(tz->handle, "_TZP", NULL, &tz->polling_frequency); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", tz->polling_frequency)); - return 0; + return_VALUE(0); } static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) { + ACPI_FUNCTION_TRACE("acpi_thermal_set_polling"); if (!tz) - return -EINVAL; + return_VALUE(-EINVAL); tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */ @@ -271,7 +274,7 @@ static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) "Polling frequency set to %lu seconds\n", tz->polling_frequency)); - return 0; + return_VALUE(0); } static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) @@ -281,28 +284,29 @@ static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) struct acpi_object_list arg_list = { 1, &arg0 }; acpi_handle handle = NULL; + ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode"); if (!tz) - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_get_handle(tz->handle, "_SCP", &handle); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); - return -ENODEV; + return_VALUE(-ENODEV); } arg0.integer.value = mode; status = acpi_evaluate_object(handle, NULL, &arg_list, NULL); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); tz->cooling_mode = mode; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", mode ? "passive" : "active")); - return 0; + return_VALUE(0); } static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) @@ -310,9 +314,10 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) acpi_status status = AE_OK; int i = 0; + ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points"); if (!tz) - return -EINVAL; + return_VALUE(-EINVAL); /* Critical Shutdown (required) */ @@ -320,8 +325,8 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) &tz->trips.critical.temperature); if (ACPI_FAILURE(status)) { tz->trips.critical.flags.valid = 0; - ACPI_EXCEPTION((AE_INFO, status, "No critical threshold")); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n")); + return_VALUE(-ENODEV); } else { tz->trips.critical.flags.valid = 1; ACPI_DEBUG_PRINT((ACPI_DB_INFO, @@ -379,7 +384,8 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) tz->trips.passive.flags.valid = 0; if (!tz->trips.passive.flags.valid) - printk(KERN_WARNING PREFIX "Invalid passive threshold\n"); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid passive threshold\n")); else ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found passive threshold [%lu]\n", @@ -408,27 +414,29 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) "Found active threshold [%d]:[%lu]\n", i, tz->trips.active[i].temperature)); } else - ACPI_EXCEPTION((AE_INFO, status, - "Invalid active threshold [%d]", i)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid active threshold [%d]\n", + i)); } - return 0; + return_VALUE(0); } static int acpi_thermal_get_devices(struct acpi_thermal *tz) { acpi_status status = AE_OK; + ACPI_FUNCTION_TRACE("acpi_thermal_get_devices"); if (!tz) - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); - return 0; + return_VALUE(0); } static int acpi_thermal_call_usermode(char *path) @@ -436,9 +444,10 @@ static int acpi_thermal_call_usermode(char *path) char *argv[2] = { NULL, NULL }; char *envp[3] = { NULL, NULL, NULL }; + ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode"); if (!path) - return -EINVAL; + return_VALUE(-EINVAL); argv[0] = path; @@ -448,7 +457,7 @@ static int acpi_thermal_call_usermode(char *path) call_usermodehelper(argv[0], argv, envp, 0); - return 0; + return_VALUE(0); } static int acpi_thermal_critical(struct acpi_thermal *tz) @@ -456,19 +465,20 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) int result = 0; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_thermal_critical"); if (!tz || !tz->trips.critical.flags.valid) - return -EINVAL; + return_VALUE(-EINVAL); if (tz->temperature >= tz->trips.critical.temperature) { - printk(KERN_WARNING PREFIX "Critical trip point\n"); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n")); tz->trips.critical.flags.enabled = 1; } else if (tz->trips.critical.flags.enabled) tz->trips.critical.flags.enabled = 0; result = acpi_bus_get_device(tz->handle, &device); if (result) - return result; + return_VALUE(result); printk(KERN_EMERG "Critical temperature reached (%ld C), shutting down.\n", @@ -478,7 +488,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); - return 0; + return_VALUE(0); } static int acpi_thermal_hot(struct acpi_thermal *tz) @@ -486,26 +496,27 @@ static int acpi_thermal_hot(struct acpi_thermal *tz) int result = 0; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_thermal_hot"); if (!tz || !tz->trips.hot.flags.valid) - return -EINVAL; + return_VALUE(-EINVAL); if (tz->temperature >= tz->trips.hot.temperature) { - printk(KERN_WARNING PREFIX "Hot trip point\n"); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n")); tz->trips.hot.flags.enabled = 1; } else if (tz->trips.hot.flags.enabled) tz->trips.hot.flags.enabled = 0; result = acpi_bus_get_device(tz->handle, &device); if (result) - return result; + return_VALUE(result); acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); /* TBD: Call user-mode "sleep(S4)" function */ - return 0; + return_VALUE(0); } static void acpi_thermal_passive(struct acpi_thermal *tz) @@ -515,6 +526,7 @@ static void acpi_thermal_passive(struct acpi_thermal *tz) int trend = 0; int i = 0; + ACPI_FUNCTION_TRACE("acpi_thermal_passive"); if (!tz || !tz->trips.passive.flags.valid) return; @@ -603,6 +615,7 @@ static void acpi_thermal_active(struct acpi_thermal *tz) int j = 0; unsigned long maxtemp = 0; + ACPI_FUNCTION_TRACE("acpi_thermal_active"); if (!tz) return; @@ -629,10 +642,10 @@ static void acpi_thermal_active(struct acpi_thermal *tz) handles[j], ACPI_STATE_D0); if (result) { - printk(KERN_WARNING PREFIX - "Unable to turn cooling device [%p] 'on'\n", - active->devices. - handles[j]); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Unable to turn cooling device [%p] 'on'\n", + active->devices. + handles[j])); continue; } active->flags.enabled = 1; @@ -654,9 +667,9 @@ static void acpi_thermal_active(struct acpi_thermal *tz) result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3); if (result) { - printk(KERN_WARNING PREFIX - "Unable to turn cooling device [%p] 'off'\n", - active->devices.handles[j]); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Unable to turn cooling device [%p] 'off'\n", + active->devices.handles[j])); continue; } active->flags.enabled = 0; @@ -684,17 +697,18 @@ static void acpi_thermal_check(void *data) int i = 0; struct acpi_thermal_state state; + ACPI_FUNCTION_TRACE("acpi_thermal_check"); if (!tz) { - printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); - return; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); + return_VOID; } state = tz->state; result = acpi_thermal_get_temperature(tz); if (result) - return; + return_VOID; memset(&tz->state, 0, sizeof(tz->state)); @@ -783,7 +797,7 @@ static void acpi_thermal_check(void *data) } } - return; + return_VOID; } /* -------------------------------------------------------------------------- @@ -796,6 +810,7 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) { struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; + ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show"); if (!tz) goto end; @@ -818,7 +833,7 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) } end: - return 0; + return_VALUE(0); } static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file) @@ -831,6 +846,7 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) int result = 0; struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; + ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show"); if (!tz) goto end; @@ -843,7 +859,7 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) KELVIN_TO_CELSIUS(tz->temperature)); end: - return 0; + return_VALUE(0); } static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file) @@ -857,6 +873,7 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) int i = 0; int j = 0; + ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show"); if (!tz) goto end; @@ -896,7 +913,7 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) } end: - return 0; + return_VALUE(0); } static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file) @@ -917,25 +934,28 @@ acpi_thermal_write_trip_points(struct file *file, int *active; int i = 0; + ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points"); limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); if (!limit_string) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN); active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); if (!active) { kfree(limit_string); - return -ENOMEM; + return_VALUE(-ENOMEM); } if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n")); count = -EINVAL; goto end; } if (copy_from_user(limit_string, buffer, count)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); count = -EFAULT; goto end; } @@ -948,6 +968,7 @@ acpi_thermal_write_trip_points(struct file *file, &active[5], &active[6], &active[7], &active[8], &active[9]); if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); count = -EINVAL; goto end; } @@ -964,13 +985,14 @@ acpi_thermal_write_trip_points(struct file *file, end: kfree(active); kfree(limit_string); - return count; + return_VALUE(count); } static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) { struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; + ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show"); if (!tz) goto end; @@ -986,7 +1008,7 @@ static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) tz->cooling_mode ? "passive" : "active"); end: - return 0; + return_VALUE(0); } static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file) @@ -1005,15 +1027,16 @@ acpi_thermal_write_cooling_mode(struct file *file, int result = 0; char mode_string[12] = { '\0' }; + ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode"); if (!tz || (count > sizeof(mode_string) - 1)) - return -EINVAL; + return_VALUE(-EINVAL); if (!tz->flags.cooling_mode) - return -ENODEV; + return_VALUE(-ENODEV); if (copy_from_user(mode_string, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); mode_string[count] = '\0'; @@ -1021,17 +1044,18 @@ acpi_thermal_write_cooling_mode(struct file *file, simple_strtoul(mode_string, NULL, 0)); if (result) - return result; + return_VALUE(result); acpi_thermal_check(tz); - return count; + return_VALUE(count); } static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) { struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; + ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show"); if (!tz) goto end; @@ -1045,7 +1069,7 @@ static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) (tz->polling_frequency / 10)); end: - return 0; + return_VALUE(0); } static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file) @@ -1065,12 +1089,13 @@ acpi_thermal_write_polling(struct file *file, char polling_string[12] = { '\0' }; int seconds = 0; + ACPI_FUNCTION_TRACE("acpi_thermal_write_polling"); if (!tz || (count > sizeof(polling_string) - 1)) - return -EINVAL; + return_VALUE(-EINVAL); if (copy_from_user(polling_string, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); polling_string[count] = '\0'; @@ -1078,23 +1103,24 @@ acpi_thermal_write_polling(struct file *file, result = acpi_thermal_set_polling(tz, seconds); if (result) - return result; + return_VALUE(result); acpi_thermal_check(tz); - return count; + return_VALUE(count); } static int acpi_thermal_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; + ACPI_FUNCTION_TRACE("acpi_thermal_add_fs"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_thermal_dir); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; } @@ -1102,7 +1128,9 @@ static int acpi_thermal_add_fs(struct acpi_device *device) entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_STATE)); else { entry->proc_fops = &acpi_thermal_state_fops; entry->data = acpi_driver_data(device); @@ -1113,7 +1141,9 @@ static int acpi_thermal_add_fs(struct acpi_device *device) entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_TEMPERATURE)); else { entry->proc_fops = &acpi_thermal_temp_fops; entry->data = acpi_driver_data(device); @@ -1125,7 +1155,9 @@ static int acpi_thermal_add_fs(struct acpi_device *device) S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_TRIP_POINTS)); else { entry->proc_fops = &acpi_thermal_trip_fops; entry->data = acpi_driver_data(device); @@ -1137,7 +1169,9 @@ static int acpi_thermal_add_fs(struct acpi_device *device) S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_COOLING_MODE)); else { entry->proc_fops = &acpi_thermal_cooling_fops; entry->data = acpi_driver_data(device); @@ -1149,18 +1183,21 @@ static int acpi_thermal_add_fs(struct acpi_device *device) S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_THERMAL_FILE_POLLING_FREQ)); else { entry->proc_fops = &acpi_thermal_polling_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return 0; + return_VALUE(0); } static int acpi_thermal_remove_fs(struct acpi_device *device) { + ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs"); if (acpi_device_dir(device)) { remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, @@ -1177,7 +1214,7 @@ static int acpi_thermal_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -1189,12 +1226,13 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) struct acpi_thermal *tz = (struct acpi_thermal *)data; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_thermal_notify"); if (!tz) - return; + return_VOID; if (acpi_bus_get_device(tz->handle, &device)) - return; + return_VOID; switch (event) { case ACPI_THERMAL_NOTIFY_TEMPERATURE: @@ -1216,26 +1254,27 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) break; } - return; + return_VOID; } static int acpi_thermal_get_info(struct acpi_thermal *tz) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_thermal_get_info"); if (!tz) - return -EINVAL; + return_VALUE(-EINVAL); /* Get temperature [_TMP] (required) */ result = acpi_thermal_get_temperature(tz); if (result) - return result; + return_VALUE(result); /* Get trip points [_CRT, _PSV, etc.] (required) */ result = acpi_thermal_get_trip_points(tz); if (result) - return result; + return_VALUE(result); /* Set the cooling mode [_SCP] to active cooling (default) */ result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); @@ -1275,7 +1314,7 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz) if (!result) tz->flags.devices = 1; - return 0; + return_VALUE(0); } static int acpi_thermal_add(struct acpi_device *device) @@ -1284,13 +1323,14 @@ static int acpi_thermal_add(struct acpi_device *device) acpi_status status = AE_OK; struct acpi_thermal *tz = NULL; + ACPI_FUNCTION_TRACE("acpi_thermal_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL); if (!tz) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(tz, 0, sizeof(struct acpi_thermal)); tz->handle = device->handle; @@ -1315,6 +1355,8 @@ static int acpi_thermal_add(struct acpi_device *device) ACPI_DEVICE_NOTIFY, acpi_thermal_notify, tz); if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -1329,7 +1371,7 @@ static int acpi_thermal_add(struct acpi_device *device) kfree(tz); } - return result; + return_VALUE(result); } static int acpi_thermal_remove(struct acpi_device *device, int type) @@ -1337,9 +1379,10 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) acpi_status status = AE_OK; struct acpi_thermal *tz = NULL; + ACPI_FUNCTION_TRACE("acpi_thermal_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); tz = (struct acpi_thermal *)acpi_driver_data(device); @@ -1355,6 +1398,9 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) status = acpi_remove_notify_handler(tz->handle, ACPI_DEVICE_NOTIFY, acpi_thermal_notify); + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); /* Terminate policy */ if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) { @@ -1370,7 +1416,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) acpi_thermal_remove_fs(device); kfree(tz); - return 0; + return_VALUE(0); } static int acpi_thermal_resume(struct acpi_device *device, int state) @@ -1378,7 +1424,7 @@ static int acpi_thermal_resume(struct acpi_device *device, int state) struct acpi_thermal *tz = NULL; if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); tz = (struct acpi_thermal *)acpi_driver_data(device); @@ -1391,29 +1437,31 @@ static int __init acpi_thermal_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_thermal_init"); acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir); if (!acpi_thermal_dir) - return -ENODEV; + return_VALUE(-ENODEV); acpi_thermal_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_thermal_driver); if (result < 0) { remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } static void __exit acpi_thermal_exit(void) { + ACPI_FUNCTION_TRACE("acpi_thermal_exit"); acpi_bus_unregister_driver(&acpi_thermal_driver); remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); - return; + return_VOID; } module_init(acpi_thermal_init); diff --git a/trunk/drivers/acpi/utilities/utdelete.c b/trunk/drivers/acpi/utilities/utdelete.c index 38ebe1c54330..67b9f325c6fa 100644 --- a/trunk/drivers/acpi/utilities/utdelete.c +++ b/trunk/drivers/acpi/utilities/utdelete.c @@ -155,30 +155,21 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) case ACPI_TYPE_MUTEX: ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, - "***** Mutex %p, OS Mutex %p\n", - object, object->mutex.os_mutex)); + "***** Mutex %p, Semaphore %p\n", + object, object->mutex.semaphore)); - if (object->mutex.os_mutex != ACPI_GLOBAL_LOCK) { - acpi_ex_unlink_mutex(object); - acpi_os_delete_mutex(object->mutex.os_mutex); - } else { - /* Global Lock "mutex" is actually a counting semaphore */ - - (void) - acpi_os_delete_semaphore - (acpi_gbl_global_lock_semaphore); - acpi_gbl_global_lock_semaphore = NULL; - } + acpi_ex_unlink_mutex(object); + (void)acpi_os_delete_semaphore(object->mutex.semaphore); break; case ACPI_TYPE_EVENT: ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, - "***** Event %p, OS Semaphore %p\n", - object, object->event.os_semaphore)); + "***** Event %p, Semaphore %p\n", + object, object->event.semaphore)); - (void)acpi_os_delete_semaphore(object->event.os_semaphore); - object->event.os_semaphore = NULL; + (void)acpi_os_delete_semaphore(object->event.semaphore); + object->event.semaphore = NULL; break; case ACPI_TYPE_METHOD: @@ -186,13 +177,12 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "***** Method %p\n", object)); - /* Delete the method mutex if it exists */ + /* Delete the method semaphore if it exists */ - if (object->method.mutex) { - acpi_os_delete_mutex(object->method.mutex->mutex. - os_mutex); - acpi_ut_delete_object_desc(object->method.mutex); - object->method.mutex = NULL; + if (object->method.semaphore) { + (void)acpi_os_delete_semaphore(object->method. + semaphore); + object->method.semaphore = NULL; } break; diff --git a/trunk/drivers/acpi/utilities/utglobal.c b/trunk/drivers/acpi/utilities/utglobal.c index 014030af8b50..e5999c65c0b8 100644 --- a/trunk/drivers/acpi/utilities/utglobal.c +++ b/trunk/drivers/acpi/utilities/utglobal.c @@ -794,7 +794,6 @@ void acpi_ut_init_globals(void) /* Global Lock support */ - acpi_gbl_global_lock_semaphore = NULL; acpi_gbl_global_lock_acquired = FALSE; acpi_gbl_global_lock_thread_count = 0; acpi_gbl_global_lock_handle = 0; diff --git a/trunk/drivers/acpi/utilities/utmisc.c b/trunk/drivers/acpi/utilities/utmisc.c index 33268310c738..5c75d35ad1cd 100644 --- a/trunk/drivers/acpi/utilities/utmisc.c +++ b/trunk/drivers/acpi/utilities/utmisc.c @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include @@ -964,7 +962,6 @@ acpi_ut_exception(char *module_name, acpi_os_vprintf(format, args); acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); } -EXPORT_SYMBOL(acpi_ut_exception); void ACPI_INTERNAL_VAR_XFACE acpi_ut_warning(char *module_name, u32 line_number, char *format, ...) diff --git a/trunk/drivers/acpi/utilities/utmutex.c b/trunk/drivers/acpi/utilities/utmutex.c index dfc8f30ca892..25eb34369afa 100644 --- a/trunk/drivers/acpi/utilities/utmutex.c +++ b/trunk/drivers/acpi/utilities/utmutex.c @@ -82,9 +82,12 @@ acpi_status acpi_ut_mutex_initialize(void) /* Create the spinlocks for use at interrupt level */ - spin_lock_init(acpi_gbl_gpe_lock); - spin_lock_init(acpi_gbl_hardware_lock); + status = acpi_os_create_lock(&acpi_gbl_gpe_lock); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + status = acpi_os_create_lock(&acpi_gbl_hardware_lock); return_ACPI_STATUS(status); } @@ -143,8 +146,9 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id) } if (!acpi_gbl_mutex_info[mutex_id].mutex) { - status = - acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex); + status = acpi_os_create_semaphore(1, 1, + &acpi_gbl_mutex_info + [mutex_id].mutex); acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; acpi_gbl_mutex_info[mutex_id].use_count = 0; @@ -167,6 +171,7 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id) static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id) { + acpi_status status; ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id); @@ -174,12 +179,12 @@ static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id) return_ACPI_STATUS(AE_BAD_PARAMETER); } - acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex); + status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex); acpi_gbl_mutex_info[mutex_id].mutex = NULL; acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; - return_ACPI_STATUS(AE_OK); + return_ACPI_STATUS(status); } /******************************************************************************* @@ -246,8 +251,8 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) "Thread %X attempting to acquire Mutex [%s]\n", this_thread_id, acpi_ut_get_mutex_name(mutex_id))); - status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex, - ACPI_WAIT_FOREVER); + status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, + 1, ACPI_WAIT_FOREVER); if (ACPI_SUCCESS(status)) { ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", @@ -279,6 +284,7 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) { + acpi_status status; acpi_thread_id this_thread_id; ACPI_FUNCTION_NAME(ut_release_mutex); @@ -334,6 +340,19 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; - acpi_os_release_mutex(acpi_gbl_mutex_info[mutex_id].mutex); - return (AE_OK); + status = + acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1); + + if (ACPI_FAILURE(status)) { + ACPI_EXCEPTION((AE_INFO, status, + "Thread %X could not release Mutex [%X]", + this_thread_id, mutex_id)); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, + "Thread %X released Mutex [%s]\n", + this_thread_id, + acpi_ut_get_mutex_name(mutex_id))); + } + + return (status); } diff --git a/trunk/drivers/acpi/utils.c b/trunk/drivers/acpi/utils.c index 1930e1a75b22..6b516852ac12 100644 --- a/trunk/drivers/acpi/utils.c +++ b/trunk/drivers/acpi/utils.c @@ -58,29 +58,31 @@ acpi_extract_package(union acpi_object *package, u8 *head = NULL; u8 *tail = NULL; + ACPI_FUNCTION_TRACE("acpi_extract_package"); if (!package || (package->type != ACPI_TYPE_PACKAGE) || (package->package.count < 1)) { - printk(KERN_WARNING PREFIX "Invalid package argument\n"); - return AE_BAD_PARAMETER; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid 'package' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); } if (!format || !format->pointer || (format->length < 1)) { - printk(KERN_WARNING PREFIX "Invalid format argument\n"); - return AE_BAD_PARAMETER; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); } if (!buffer) { - printk(KERN_WARNING PREFIX "Invalid buffer argument\n"); - return AE_BAD_PARAMETER; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); } format_count = (format->length / sizeof(char)) - 1; if (format_count > package->package.count) { - printk(KERN_WARNING PREFIX "Format specifies more objects [%d]" - " than exist in package [%d].\n", - format_count, package->package.count); - return AE_BAD_DATA; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Format specifies more objects [%d] than exist in package [%d].", + format_count, package->package.count)); + return_ACPI_STATUS(AE_BAD_DATA); } format_string = (char *)format->pointer; @@ -93,7 +95,7 @@ acpi_extract_package(union acpi_object *package, union acpi_object *element = &(package->package.elements[i]); if (!element) { - return AE_BAD_DATA; + return_ACPI_STATUS(AE_BAD_DATA); } switch (element->type) { @@ -111,11 +113,10 @@ acpi_extract_package(union acpi_object *package, tail_offset += sizeof(char *); break; default: - printk(KERN_WARNING PREFIX "Invalid package element" - " [%d]: got number, expecing" - " [%c]\n", - i, format_string[i]); - return AE_BAD_DATA; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid package element [%d]: got number, expecing [%c].\n", + i, format_string[i])); + return_ACPI_STATUS(AE_BAD_DATA); break; } break; @@ -137,11 +138,10 @@ acpi_extract_package(union acpi_object *package, tail_offset += sizeof(u8 *); break; default: - printk(KERN_WARNING PREFIX "Invalid package element" - " [%d] got string/buffer," - " expecing [%c]\n", - i, format_string[i]); - return AE_BAD_DATA; + ACPI_DEBUG_PRINT((ACPI_DB_WARN, + "Invalid package element [%d] got string/buffer, expecing [%c].\n", + i, format_string[i])); + return_ACPI_STATUS(AE_BAD_DATA); break; } break; @@ -152,7 +152,7 @@ acpi_extract_package(union acpi_object *package, "Found unsupported element at index=%d\n", i)); /* TBD: handle nested packages... */ - return AE_SUPPORT; + return_ACPI_STATUS(AE_SUPPORT); break; } } @@ -162,9 +162,9 @@ acpi_extract_package(union acpi_object *package, */ if (buffer->length < size_required) { buffer->length = size_required; - return AE_BUFFER_OVERFLOW; + return_ACPI_STATUS(AE_BUFFER_OVERFLOW); } else if (buffer->length != size_required || !buffer->pointer) { - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); } head = buffer->pointer; @@ -179,7 +179,7 @@ acpi_extract_package(union acpi_object *package, union acpi_object *element = &(package->package.elements[i]); if (!element) { - return AE_BAD_DATA; + return_ACPI_STATUS(AE_BAD_DATA); } switch (element->type) { @@ -244,7 +244,7 @@ acpi_extract_package(union acpi_object *package, } } - return AE_OK; + return_ACPI_STATUS(AE_OK); } EXPORT_SYMBOL(acpi_extract_package); @@ -258,13 +258,14 @@ acpi_evaluate_integer(acpi_handle handle, union acpi_object *element; struct acpi_buffer buffer = { 0, NULL }; + ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); if (!data) - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); if (!element) - return AE_NO_MEMORY; + return_ACPI_STATUS(AE_NO_MEMORY); memset(element, 0, sizeof(union acpi_object)); buffer.length = sizeof(union acpi_object); @@ -273,13 +274,13 @@ acpi_evaluate_integer(acpi_handle handle, if (ACPI_FAILURE(status)) { acpi_util_eval_error(handle, pathname, status); kfree(element); - return status; + return_ACPI_STATUS(status); } if (element->type != ACPI_TYPE_INTEGER) { acpi_util_eval_error(handle, pathname, AE_BAD_DATA); kfree(element); - return AE_BAD_DATA; + return_ACPI_STATUS(AE_BAD_DATA); } *data = element->integer.value; @@ -287,7 +288,7 @@ acpi_evaluate_integer(acpi_handle handle, ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); - return AE_OK; + return_ACPI_STATUS(AE_OK); } EXPORT_SYMBOL(acpi_evaluate_integer); @@ -302,14 +303,15 @@ acpi_evaluate_string(acpi_handle handle, acpi_object *element = NULL; acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + ACPI_FUNCTION_TRACE("acpi_evaluate_string"); if (!data) - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); status = acpi_evaluate_object(handle, pathname, arguments, &buffer); if (ACPI_FAILURE(status)) { acpi_util_eval_error(handle, pathname, status); - return status; + return_ACPI_STATUS(status); } element = (acpi_object *) buffer.pointer; @@ -318,13 +320,13 @@ acpi_evaluate_string(acpi_handle handle, || (element->type != ACPI_TYPE_BUFFER) || !element->string.length) { acpi_util_eval_error(handle, pathname, AE_BAD_DATA); - return AE_BAD_DATA; + return_ACPI_STATUS(AE_BAD_DATA); } *data = kmalloc(element->string.length + 1, GFP_KERNEL); if (!data) { - printk(KERN_ERR PREFIX "Memory allocation\n"); - return -ENOMEM; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); + return_VALUE(-ENOMEM); } memset(*data, 0, element->string.length + 1); @@ -334,7 +336,7 @@ acpi_evaluate_string(acpi_handle handle, acpi_os_free(buffer.pointer); - return AE_OK; + return_ACPI_STATUS(AE_OK); } #endif @@ -350,9 +352,10 @@ acpi_evaluate_reference(acpi_handle handle, struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; u32 i = 0; + ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); if (!list) { - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Evaluate object. */ @@ -364,29 +367,32 @@ acpi_evaluate_reference(acpi_handle handle, package = (union acpi_object *)buffer.pointer; if ((buffer.length == 0) || !package) { - printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n", - (unsigned)buffer.length, package); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No return object (len %X ptr %p)\n", + (unsigned)buffer.length, package)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (package->type != ACPI_TYPE_PACKAGE) { - printk(KERN_ERR PREFIX "Expecting a [Package], found type %X\n", - package->type); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Package], found type %X\n", + package->type)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (!package->package.count) { - printk(KERN_ERR PREFIX "[Package] has zero elements (%p)\n", - package); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "[Package] has zero elements (%p)\n", + package)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (package->package.count > ACPI_MAX_HANDLES) { - return AE_NO_MEMORY; + return_ACPI_STATUS(AE_NO_MEMORY); } list->count = package->package.count; @@ -398,9 +404,9 @@ acpi_evaluate_reference(acpi_handle handle, if (element->type != ACPI_TYPE_ANY) { status = AE_BAD_DATA; - printk(KERN_ERR PREFIX - "Expecting a [Reference] package element, found type %X\n", - element->type); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Reference] package element, found type %X\n", + element->type)); acpi_util_eval_error(handle, pathname, status); break; } @@ -420,7 +426,7 @@ acpi_evaluate_reference(acpi_handle handle, acpi_os_free(buffer.pointer); - return status; + return_ACPI_STATUS(status); } EXPORT_SYMBOL(acpi_evaluate_reference); diff --git a/trunk/drivers/acpi/video.c b/trunk/drivers/acpi/video.c index 9feb633087a9..e7e9a693953a 100644 --- a/trunk/drivers/acpi/video.c +++ b/trunk/drivers/acpi/video.c @@ -272,9 +272,10 @@ static int acpi_video_device_query(struct acpi_video_device *device, unsigned long *state) { int status; + ACPI_FUNCTION_TRACE("acpi_video_device_query"); status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state); - return status; + return_VALUE(status); } static int @@ -283,10 +284,11 @@ acpi_video_device_get_state(struct acpi_video_device *device, { int status; + ACPI_FUNCTION_TRACE("acpi_video_device_get_state"); status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state); - return status; + return_VALUE(status); } static int @@ -297,11 +299,12 @@ acpi_video_device_set_state(struct acpi_video_device *device, int state) struct acpi_object_list args = { 1, &arg0 }; unsigned long ret; + ACPI_FUNCTION_TRACE("acpi_video_device_set_state"); arg0.integer.value = state; status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret); - return status; + return_VALUE(status); } static int @@ -312,27 +315,28 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *obj; + ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels"); *levels = NULL; status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer); if (!ACPI_SUCCESS(status)) - return status; + return_VALUE(status); obj = (union acpi_object *)buffer.pointer; if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { - printk(KERN_ERR PREFIX "Invalid _BCL data\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n")); status = -EFAULT; goto err; } *levels = obj; - return 0; + return_VALUE(0); err: kfree(buffer.pointer); - return status; + return_VALUE(status); } static int @@ -342,12 +346,13 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; + ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level"); arg0.integer.value = level; status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL); printk(KERN_DEBUG "set_level status: %x\n", status); - return status; + return_VALUE(status); } static int @@ -355,10 +360,11 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, unsigned long *level) { int status; + ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current"); status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level); - return status; + return_VALUE(status); } static int @@ -371,33 +377,34 @@ acpi_video_device_EDID(struct acpi_video_device *device, union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; + ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID"); *edid = NULL; if (!device) - return -ENODEV; + return_VALUE(-ENODEV); if (length == 128) arg0.integer.value = 1; else if (length == 256) arg0.integer.value = 2; else - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer); if (ACPI_FAILURE(status)) - return -ENODEV; + return_VALUE(-ENODEV); obj = (union acpi_object *)buffer.pointer; if (obj && obj->type == ACPI_TYPE_BUFFER) *edid = obj; else { - printk(KERN_ERR PREFIX "Invalid _DDC data\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DDC data\n")); status = -EFAULT; kfree(obj); } - return status; + return_VALUE(status); } /* bus */ @@ -410,6 +417,7 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option) union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; + ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST"); arg0.integer.value = option; @@ -417,7 +425,7 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option) if (ACPI_SUCCESS(status)) status = tmp ? (-EINVAL) : (AE_OK); - return status; + return_VALUE(status); } static int @@ -425,10 +433,11 @@ acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id) { int status; + ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST"); status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id); - return status; + return_VALUE(status); } static int @@ -436,11 +445,12 @@ acpi_video_bus_POST_options(struct acpi_video_bus *video, unsigned long *options) { int status; + ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options"); status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options); *options &= 3; - return status; + return_VALUE(status); } /* @@ -471,6 +481,7 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; + ACPI_FUNCTION_TRACE("acpi_video_bus_DOS"); if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) { status = -1; @@ -481,7 +492,7 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) acpi_evaluate_object(video->handle, "_DOS", &args, NULL); Failed: - return status; + return_VALUE(status); } /* @@ -503,6 +514,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) union acpi_object *obj = NULL; struct acpi_video_device_brightness *br = NULL; + ACPI_FUNCTION_TRACE("acpi_video_device_find_cap"); memset(&device->cap, 0, 4); @@ -548,7 +560,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) o = (union acpi_object *)&obj->package. elements[i]; if (o->type != ACPI_TYPE_INTEGER) { - printk(KERN_ERR PREFIX "Invalid data\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid data\n")); continue; } br->levels[count] = (u32) o->integer.value; @@ -570,7 +583,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) kfree(obj); - return; + return_VOID; } /* @@ -617,9 +630,10 @@ static int acpi_video_bus_check(struct acpi_video_bus *video) { acpi_status status = -ENOENT; + ACPI_FUNCTION_TRACE("acpi_video_bus_check"); if (!video) - return -EINVAL; + return_VALUE(-EINVAL); /* Since there is no HID, CID and so on for VGA driver, we have * to check well known required nodes. @@ -643,7 +657,7 @@ static int acpi_video_bus_check(struct acpi_video_bus *video) status = 0; } - return status; + return_VALUE(status); } /* -------------------------------------------------------------------------- @@ -659,6 +673,7 @@ static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset) struct acpi_video_device *dev = (struct acpi_video_device *)seq->private; + ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show"); if (!dev) goto end; @@ -677,7 +692,7 @@ static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset) seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no"); end: - return 0; + return_VALUE(0); } static int @@ -694,6 +709,7 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) (struct acpi_video_device *)seq->private; unsigned long state; + ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show"); if (!dev) goto end; @@ -713,7 +729,7 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) seq_printf(seq, "\n"); end: - return 0; + return_VALUE(0); } static int @@ -734,12 +750,13 @@ acpi_video_device_write_state(struct file *file, char str[12] = { 0 }; u32 state = 0; + ACPI_FUNCTION_TRACE("acpi_video_device_write_state"); if (!dev || count + 1 > sizeof str) - return -EINVAL; + return_VALUE(-EINVAL); if (copy_from_user(str, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); str[count] = 0; state = simple_strtoul(str, NULL, 0); @@ -748,9 +765,9 @@ acpi_video_device_write_state(struct file *file, status = acpi_video_device_set_state(dev, state); if (status) - return -EFAULT; + return_VALUE(-EFAULT); - return count; + return_VALUE(count); } static int @@ -760,10 +777,11 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset) (struct acpi_video_device *)seq->private; int i; + ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show"); if (!dev || !dev->brightness) { seq_printf(seq, "\n"); - return 0; + return_VALUE(0); } seq_printf(seq, "levels: "); @@ -771,7 +789,7 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset) seq_printf(seq, " %d", dev->brightness->levels[i]); seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr); - return 0; + return_VALUE(0); } static int @@ -792,18 +810,19 @@ acpi_video_device_write_brightness(struct file *file, unsigned int level = 0; int i; + ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness"); if (!dev || !dev->brightness || count + 1 > sizeof str) - return -EINVAL; + return_VALUE(-EINVAL); if (copy_from_user(str, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); str[count] = 0; level = simple_strtoul(str, NULL, 0); if (level > 100) - return -EFAULT; + return_VALUE(-EFAULT); /* validate though the list of available levels */ for (i = 0; i < dev->brightness->count; i++) @@ -814,7 +833,7 @@ acpi_video_device_write_brightness(struct file *file, break; } - return count; + return_VALUE(count); } static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) @@ -825,6 +844,7 @@ static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) int i; union acpi_object *edid = NULL; + ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show"); if (!dev) goto out; @@ -849,7 +869,7 @@ static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) else kfree(edid); - return 0; + return_VALUE(0); } static int @@ -864,26 +884,28 @@ static int acpi_video_device_add_fs(struct acpi_device *device) struct proc_dir_entry *entry = NULL; struct acpi_video_device *vid_dev; + ACPI_FUNCTION_TRACE("acpi_video_device_add_fs"); if (!device) - return -ENODEV; + return_VALUE(-ENODEV); vid_dev = (struct acpi_video_device *)acpi_driver_data(device); if (!vid_dev) - return -ENODEV; + return_VALUE(-ENODEV); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), vid_dev->video->dir); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; } /* 'info' [R] */ entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'info' fs entry\n")); else { entry->proc_fops = &acpi_video_device_info_fops; entry->data = acpi_driver_data(device); @@ -895,7 +917,8 @@ static int acpi_video_device_add_fs(struct acpi_device *device) create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'state' fs entry\n")); else { acpi_video_device_state_fops.write = acpi_video_device_write_state; entry->proc_fops = &acpi_video_device_state_fops; @@ -908,7 +931,8 @@ static int acpi_video_device_add_fs(struct acpi_device *device) create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'brightness' fs entry\n")); else { acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness; entry->proc_fops = &acpi_video_device_brightness_fops; @@ -919,23 +943,25 @@ static int acpi_video_device_add_fs(struct acpi_device *device) /* 'EDID' [R] */ entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'brightness' fs entry\n")); else { entry->proc_fops = &acpi_video_device_EDID_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return 0; + return_VALUE(0); } static int acpi_video_device_remove_fs(struct acpi_device *device) { struct acpi_video_device *vid_dev; + ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs"); vid_dev = (struct acpi_video_device *)acpi_driver_data(device); if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) - return -ENODEV; + return_VALUE(-ENODEV); if (acpi_device_dir(device)) { remove_proc_entry("info", acpi_device_dir(device)); @@ -946,7 +972,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* video bus */ @@ -954,6 +980,7 @@ static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset) { struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; + ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show"); if (!video) goto end; @@ -966,7 +993,7 @@ static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset) video->flags.post ? "yes" : "no"); end: - return 0; + return_VALUE(0); } static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file) @@ -979,6 +1006,7 @@ static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset) { struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; + ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show"); if (!video) goto end; @@ -987,7 +1015,7 @@ static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset) seq_printf(seq, "\n"); end: - return 0; + return_VALUE(0); } static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file) @@ -1001,6 +1029,7 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) unsigned long options; int status; + ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show"); if (!video) goto end; @@ -1023,7 +1052,7 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) } else seq_printf(seq, "\n"); end: - return 0; + return_VALUE(0); } static int @@ -1039,6 +1068,7 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) int status; unsigned long id; + ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show"); if (!video) goto end; @@ -1051,17 +1081,18 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]); end: - return 0; + return_VALUE(0); } static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset) { struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; + ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show"); seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting); - return 0; + return_VALUE(0); } static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file) @@ -1086,21 +1117,22 @@ acpi_video_bus_write_POST(struct file *file, char str[12] = { 0 }; unsigned long opt, options; + ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST"); if (!video || count + 1 > sizeof str) - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_video_bus_POST_options(video, &options); if (!ACPI_SUCCESS(status)) - return -EINVAL; + return_VALUE(-EINVAL); if (copy_from_user(str, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); str[count] = 0; opt = strtoul(str, NULL, 0); if (opt > 3) - return -EFAULT; + return_VALUE(-EFAULT); /* just in case an OEM 'forget' the motherboard... */ options |= 1; @@ -1108,11 +1140,11 @@ acpi_video_bus_write_POST(struct file *file, if (options & (1ul << opt)) { status = acpi_video_bus_set_POST(video, opt); if (!ACPI_SUCCESS(status)) - return -EFAULT; + return_VALUE(-EFAULT); } - return count; + return_VALUE(count); } static ssize_t @@ -1126,24 +1158,25 @@ acpi_video_bus_write_DOS(struct file *file, char str[12] = { 0 }; unsigned long opt; + ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS"); if (!video || count + 1 > sizeof str) - return -EINVAL; + return_VALUE(-EINVAL); if (copy_from_user(str, buffer, count)) - return -EFAULT; + return_VALUE(-EFAULT); str[count] = 0; opt = strtoul(str, NULL, 0); if (opt > 7) - return -EFAULT; + return_VALUE(-EFAULT); status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2); if (!ACPI_SUCCESS(status)) - return -EFAULT; + return_VALUE(-EFAULT); - return count; + return_VALUE(count); } static int acpi_video_bus_add_fs(struct acpi_device *device) @@ -1151,6 +1184,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) struct proc_dir_entry *entry = NULL; struct acpi_video_bus *video; + ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs"); video = (struct acpi_video_bus *)acpi_driver_data(device); @@ -1158,7 +1192,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_video_dir); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); video->dir = acpi_device_dir(device); acpi_device_dir(device)->owner = THIS_MODULE; } @@ -1166,7 +1200,8 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) /* 'info' [R] */ entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'info' fs entry\n")); else { entry->proc_fops = &acpi_video_bus_info_fops; entry->data = acpi_driver_data(device); @@ -1176,7 +1211,8 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) /* 'ROM' [R] */ entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'ROM' fs entry\n")); else { entry->proc_fops = &acpi_video_bus_ROM_fops; entry->data = acpi_driver_data(device); @@ -1187,7 +1223,8 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) entry = create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'POST_info' fs entry\n")); else { entry->proc_fops = &acpi_video_bus_POST_info_fops; entry->data = acpi_driver_data(device); @@ -1199,7 +1236,8 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'POST' fs entry\n")); else { acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST; entry->proc_fops = &acpi_video_bus_POST_fops; @@ -1212,7 +1250,8 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create 'DOS' fs entry\n")); else { acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS; entry->proc_fops = &acpi_video_bus_DOS_fops; @@ -1220,13 +1259,14 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) entry->owner = THIS_MODULE; } - return 0; + return_VALUE(0); } static int acpi_video_bus_remove_fs(struct acpi_device *device) { struct acpi_video_bus *video; + ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs"); video = (struct acpi_video_bus *)acpi_driver_data(device); @@ -1240,7 +1280,7 @@ static int acpi_video_bus_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -1257,9 +1297,10 @@ acpi_video_bus_get_one_device(struct acpi_device *device, int status; struct acpi_video_device *data; + ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device"); if (!device || !video) - return -EINVAL; + return_VALUE(-EINVAL); status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); @@ -1267,7 +1308,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device, data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL); if (!data) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(data, 0, sizeof(struct acpi_video_device)); @@ -1318,10 +1359,10 @@ acpi_video_bus_get_one_device(struct acpi_device *device, acpi_video_device_add_fs(device); - return 0; + return_VALUE(0); } - return -ENOENT; + return_VALUE(-ENOENT); } /* @@ -1364,6 +1405,7 @@ acpi_video_device_bind(struct acpi_video_bus *video, struct acpi_video_device *device) { int i; + ACPI_FUNCTION_TRACE("acpi_video_device_bind"); #define IDS_VAL(i) video->attached_array[i].value.int_val #define IDS_BIND(i) video->attached_array[i].bind_info @@ -1400,16 +1442,17 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) union acpi_object *dod = NULL; union acpi_object *obj; + ACPI_FUNCTION_TRACE("acpi_video_device_enumerate"); status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer); if (!ACPI_SUCCESS(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD")); - return status; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _DOD\n")); + return_VALUE(status); } dod = (union acpi_object *)buffer.pointer; if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { - ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); status = -EFAULT; goto out; } @@ -1433,7 +1476,8 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) obj = (union acpi_object *)&dod->package.elements[i]; if (obj->type != ACPI_TYPE_INTEGER) { - printk(KERN_ERR PREFIX "Invalid _DOD data\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid _DOD data\n")); active_device_list[i].value.int_val = ACPI_VIDEO_HEAD_INVALID; } @@ -1451,7 +1495,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) video->attached_count = count; out: acpi_os_free(buffer.pointer); - return status; + return_VALUE(status); } /* @@ -1476,6 +1520,7 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event) unsigned long state; int status = 0; + ACPI_FUNCTION_TRACE("acpi_video_switch_output"); list_for_each_safe(node, next, &video->video_device_list) { dev = container_of(node, struct acpi_video_device, entry); @@ -1506,7 +1551,7 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event) break; } - return status; + return_VALUE(status); } static int @@ -1533,6 +1578,7 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video, int status = 0; struct list_head *node, *next; + ACPI_FUNCTION_TRACE("acpi_video_get_devices"); acpi_video_device_enumerate(video); @@ -1545,12 +1591,13 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video, status = acpi_video_bus_get_one_device(dev, video); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Cant attach device")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Cant attach device\n")); continue; } } - return status; + return_VALUE(status); } static int acpi_video_bus_put_one_device(struct acpi_video_device *device) @@ -1558,9 +1605,10 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) acpi_status status; struct acpi_video_bus *video; + ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device"); if (!device || !device->video) - return -ENOENT; + return_VALUE(-ENOENT); video = device->video; @@ -1572,8 +1620,11 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) status = acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_video_device_notify); + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); - return 0; + return_VALUE(0); } static int acpi_video_bus_put_devices(struct acpi_video_bus *video) @@ -1581,6 +1632,7 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video) int status; struct list_head *node, *next; + ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices"); list_for_each_safe(node, next, &video->video_device_list) { struct acpi_video_device *data = @@ -1599,7 +1651,7 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video) kfree(data); } - return 0; + return_VALUE(0); } /* acpi_video interface */ @@ -1619,13 +1671,14 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) struct acpi_video_bus *video = (struct acpi_video_bus *)data; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_video_bus_notify"); printk("video bus notify\n"); if (!video) - return; + return_VOID; if (acpi_bus_get_device(handle, &device)) - return; + return_VOID; switch (event) { case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur, @@ -1654,7 +1707,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) break; } - return; + return_VOID; } static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) @@ -1663,13 +1716,14 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) (struct acpi_video_device *)data; struct acpi_device *device = NULL; + ACPI_FUNCTION_TRACE("acpi_video_device_notify"); printk("video device notify\n"); if (!video_device) - return; + return_VOID; if (acpi_bus_get_device(handle, &device)) - return; + return_VOID; switch (event) { case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ @@ -1689,7 +1743,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) "Unsupported event [0x%x]\n", event)); break; } - return; + return_VOID; } static int acpi_video_bus_add(struct acpi_device *device) @@ -1698,13 +1752,14 @@ static int acpi_video_bus_add(struct acpi_device *device) acpi_status status = 0; struct acpi_video_bus *video = NULL; + ACPI_FUNCTION_TRACE("acpi_video_bus_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); if (!video) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(video, 0, sizeof(struct acpi_video_bus)); video->handle = device->handle; @@ -1751,7 +1806,7 @@ static int acpi_video_bus_add(struct acpi_device *device) if (result) kfree(video); - return result; + return_VALUE(result); } static int acpi_video_bus_remove(struct acpi_device *device, int type) @@ -1759,9 +1814,10 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type) acpi_status status = 0; struct acpi_video_bus *video = NULL; + ACPI_FUNCTION_TRACE("acpi_video_bus_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); video = (struct acpi_video_bus *)acpi_driver_data(device); @@ -1770,6 +1826,9 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type) status = acpi_remove_notify_handler(video->handle, ACPI_DEVICE_NOTIFY, acpi_video_bus_notify); + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); acpi_video_bus_put_devices(video); acpi_video_bus_remove_fs(device); @@ -1777,7 +1836,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type) kfree(video->attached_array); kfree(video); - return 0; + return_VALUE(0); } static int @@ -1787,9 +1846,10 @@ acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver) acpi_handle h_dummy2; acpi_handle h_dummy3; + ACPI_FUNCTION_TRACE("acpi_video_bus_match"); if (!device || !driver) - return -EINVAL; + return_VALUE(-EINVAL); /* Since there is no HID, CID for ACPI Video drivers, we have * to check well known required nodes for each feature we support. @@ -1798,25 +1858,26 @@ acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver) /* Does this device able to support video switching ? */ if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) && ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2))) - return 0; + return_VALUE(0); /* Does this device able to retrieve a video ROM ? */ if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1))) - return 0; + return_VALUE(0); /* Does this device able to configure which video head to be POSTed ? */ if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) && ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) && ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3))) - return 0; + return_VALUE(0); - return -ENODEV; + return_VALUE(-ENODEV); } static int __init acpi_video_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_video_init"); /* acpi_dbg_level = 0xFFFFFFFF; @@ -1825,26 +1886,27 @@ static int __init acpi_video_init(void) acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); if (!acpi_video_dir) - return -ENODEV; + return_VALUE(-ENODEV); acpi_video_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_video_bus); if (result < 0) { remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } static void __exit acpi_video_exit(void) { + ACPI_FUNCTION_TRACE("acpi_video_exit"); acpi_bus_unregister_driver(&acpi_video_bus); remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); - return; + return_VOID; } module_init(acpi_video_init); diff --git a/trunk/drivers/media/video/cx88/cx88-blackbird.c b/trunk/drivers/media/video/cx88/cx88-blackbird.c index 4ff81582ec56..349632b48e93 100644 --- a/trunk/drivers/media/video/cx88/cx88-blackbird.c +++ b/trunk/drivers/media/video/cx88/cx88-blackbird.c @@ -686,6 +686,39 @@ static struct videobuf_queue_ops blackbird_qops = { /* ------------------------------------------------------------------ */ +static const u32 *ctrl_classes[] = { + cx88_user_ctrls, + cx2341x_mpeg_ctrls, + NULL +}; + +static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qctrl) +{ + qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); + if (qctrl->id == 0) + return -EINVAL; + + /* Standard V4L2 controls */ + if (cx8800_ctrl_query(qctrl) == 0) + return 0; + + /* MPEG V4L2 controls */ + if (cx2341x_ctrl_query(&dev->params, qctrl)) + qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; + return 0; +} + +static int blackbird_querymenu(struct cx8802_dev *dev, struct v4l2_querymenu *qmenu) +{ + struct v4l2_queryctrl qctrl; + + qctrl.id = qmenu->id; + blackbird_queryctrl(dev, &qctrl); + return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id)); +} + +/* ------------------------------------------------------------------ */ + static int mpeg_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg) { @@ -866,6 +899,16 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, core->name); return 0; } + case VIDIOC_QUERYMENU: + return blackbird_querymenu(dev, arg); + case VIDIOC_QUERYCTRL: + { + struct v4l2_queryctrl *c = arg; + + if (blackbird_queryctrl(dev, c) == 0) + return 0; + return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl); + } default: return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl); diff --git a/trunk/drivers/media/video/cx88/cx88-video.c b/trunk/drivers/media/video/cx88/cx88-video.c index 8d5cf474b68e..fe147e3aaa70 100644 --- a/trunk/drivers/media/video/cx88/cx88-video.c +++ b/trunk/drivers/media/video/cx88/cx88-video.c @@ -327,6 +327,51 @@ static struct cx88_ctrl cx8800_ctls[] = { }; static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls); +const u32 cx88_user_ctrls[] = { + V4L2_CID_USER_CLASS, + V4L2_CID_BRIGHTNESS, + V4L2_CID_CONTRAST, + V4L2_CID_SATURATION, + V4L2_CID_HUE, + V4L2_CID_AUDIO_VOLUME, + V4L2_CID_AUDIO_BALANCE, + V4L2_CID_AUDIO_MUTE, + 0 +}; +EXPORT_SYMBOL(cx88_user_ctrls); + +static const u32 *ctrl_classes[] = { + cx88_user_ctrls, + NULL +}; + +int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl) +{ + int i; + + if (qctrl->id < V4L2_CID_BASE || + qctrl->id >= V4L2_CID_LASTP1) + return -EINVAL; + for (i = 0; i < CX8800_CTLS; i++) + if (cx8800_ctls[i].v.id == qctrl->id) + break; + if (i == CX8800_CTLS) { + *qctrl = no_ctl; + return 0; + } + *qctrl = cx8800_ctls[i].v; + return 0; +} +EXPORT_SYMBOL(cx8800_ctrl_query); + +static int cx88_queryctrl(struct v4l2_queryctrl *qctrl) +{ + qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); + if (qctrl->id == 0) + return -EINVAL; + return cx8800_ctrl_query(qctrl); +} + /* ------------------------------------------------------------------- */ /* resource management */ @@ -1362,20 +1407,8 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, case VIDIOC_QUERYCTRL: { struct v4l2_queryctrl *c = arg; - int i; - if (c->id < V4L2_CID_BASE || - c->id >= V4L2_CID_LASTP1) - return -EINVAL; - for (i = 0; i < CX8800_CTLS; i++) - if (cx8800_ctls[i].v.id == c->id) - break; - if (i == CX8800_CTLS) { - *c = no_ctl; - return 0; - } - *c = cx8800_ctls[i].v; - return 0; + return cx88_queryctrl(c); } case VIDIOC_G_CTRL: return get_control(core,arg); diff --git a/trunk/drivers/media/video/cx88/cx88.h b/trunk/drivers/media/video/cx88/cx88.h index 9a9a0fc7a41a..336e823c7588 100644 --- a/trunk/drivers/media/video/cx88/cx88.h +++ b/trunk/drivers/media/video/cx88/cx88.h @@ -590,6 +590,8 @@ int cx8802_resume_common(struct pci_dev *pci_dev); extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, struct cx88_core *core, unsigned int cmd, void *arg, v4l2_kioctl driver_ioctl); +extern const u32 cx88_user_ctrls[]; +extern int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl); /* * Local variables: diff --git a/trunk/drivers/pci/hotplug/Makefile b/trunk/drivers/pci/hotplug/Makefile index 34a1891191fd..421cfffb1756 100644 --- a/trunk/drivers/pci/hotplug/Makefile +++ b/trunk/drivers/pci/hotplug/Makefile @@ -40,7 +40,8 @@ ibmphp-objs := ibmphp_core.o \ ibmphp_hpc.o acpiphp-objs := acpiphp_core.o \ - acpiphp_glue.o + acpiphp_glue.o \ + acpiphp_dock.o rpaphp-objs := rpaphp_core.o \ rpaphp_pci.o \ diff --git a/trunk/drivers/pci/hotplug/acpiphp.h b/trunk/drivers/pci/hotplug/acpiphp.h index be104eced34c..17a93f890dba 100644 --- a/trunk/drivers/pci/hotplug/acpiphp.h +++ b/trunk/drivers/pci/hotplug/acpiphp.h @@ -130,7 +130,7 @@ struct acpiphp_func { struct list_head sibling; struct pci_dev *pci_dev; - struct notifier_block nb; + acpi_handle handle; u8 function; /* pci function# */ @@ -151,6 +151,24 @@ struct acpiphp_attention_info }; +struct dependent_device { + struct list_head device_list; + struct list_head pci_list; + acpi_handle handle; + struct acpiphp_func *func; +}; + + +struct acpiphp_dock_station { + acpi_handle handle; + u32 last_dock_time; + u32 flags; + struct acpiphp_func *dock_bridge; + struct list_head dependent_devices; + struct list_head pci_dependent_devices; +}; + + /* PCI bus bridge HID */ #define ACPI_PCI_HOST_HID "PNP0A03" @@ -189,6 +207,11 @@ struct acpiphp_attention_info #define FUNC_HAS_PS2 (0x00000040) #define FUNC_HAS_PS3 (0x00000080) #define FUNC_HAS_DCK (0x00000100) +#define FUNC_IS_DD (0x00000200) + +/* dock station flags */ +#define DOCK_DOCKING (0x00000001) +#define DOCK_HAS_BRIDGE (0x00000002) /* function prototypes */ @@ -203,6 +226,7 @@ extern int acpiphp_glue_init (void); extern void acpiphp_glue_exit (void); extern int acpiphp_get_num_slots (void); typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); +void handle_hotplug_event_func(acpi_handle, u32, void*); extern int acpiphp_enable_slot (struct acpiphp_slot *slot); extern int acpiphp_disable_slot (struct acpiphp_slot *slot); @@ -212,6 +236,16 @@ extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot); extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); extern u32 acpiphp_get_address (struct acpiphp_slot *slot); +/* acpiphp_dock.c */ +extern int find_dock_station(void); +extern void remove_dock_station(void); +extern void add_dependent_device(struct dependent_device *new_dd); +extern void add_pci_dependent_device(struct dependent_device *new_dd); +extern struct dependent_device *get_dependent_device(acpi_handle handle); +extern int is_dependent_device(acpi_handle handle); +extern int detect_dependent_devices(acpi_handle *bridge_handle); +extern struct dependent_device *alloc_dependent_device(acpi_handle handle); + /* variables */ extern int acpiphp_debug; diff --git a/trunk/drivers/pci/hotplug/acpiphp_core.c b/trunk/drivers/pci/hotplug/acpiphp_core.c index 34de5697983d..4f1b0da8e47e 100644 --- a/trunk/drivers/pci/hotplug/acpiphp_core.c +++ b/trunk/drivers/pci/hotplug/acpiphp_core.c @@ -416,12 +416,27 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot) static int __init acpiphp_init(void) { + int retval; + int docking_station; + info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); acpiphp_debug = debug; + docking_station = find_dock_station(); + /* read all the ACPI info from the system */ - return init_acpi(); + retval = init_acpi(); + + /* if we have found a docking station, we should + * go ahead and load even if init_acpi has found + * no slots. This handles the case when the _DCK + * method not defined under the actual dock bridge + */ + if (docking_station) + return 0; + else + return retval; } @@ -429,6 +444,8 @@ static void __exit acpiphp_exit(void) { /* deallocate internal data structures etc. */ acpiphp_glue_exit(); + + remove_dock_station(); } module_init(acpiphp_init); diff --git a/trunk/drivers/pci/hotplug/acpiphp_dock.c b/trunk/drivers/pci/hotplug/acpiphp_dock.c new file mode 100644 index 000000000000..4f1aaf128312 --- /dev/null +++ b/trunk/drivers/pci/hotplug/acpiphp_dock.c @@ -0,0 +1,438 @@ +/* + * ACPI PCI HotPlug dock functions to ACPI CA subsystem + * + * Copyright (C) 2006 Kristen Carlson Accardi (kristen.c.accardi@intel.com) + * Copyright (C) 2006 Intel Corporation + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Send feedback to + * + */ +#include +#include + +#include +#include +#include +#include + +#include "../pci.h" +#include "pci_hotplug.h" +#include "acpiphp.h" + +static struct acpiphp_dock_station *ds; +#define MY_NAME "acpiphp_dock" + + +int is_dependent_device(acpi_handle handle) +{ + return (get_dependent_device(handle) ? 1 : 0); +} + + +static acpi_status +find_dependent_device(acpi_handle handle, u32 lvl, void *context, void **rv) +{ + int *count = (int *)context; + + if (is_dependent_device(handle)) { + (*count)++; + return AE_CTRL_TERMINATE; + } else { + return AE_OK; + } +} + + + + +void add_dependent_device(struct dependent_device *new_dd) +{ + list_add_tail(&new_dd->device_list, &ds->dependent_devices); +} + + +void add_pci_dependent_device(struct dependent_device *new_dd) +{ + list_add_tail(&new_dd->pci_list, &ds->pci_dependent_devices); +} + + + +struct dependent_device * get_dependent_device(acpi_handle handle) +{ + struct dependent_device *dd; + + if (!ds) + return NULL; + + list_for_each_entry(dd, &ds->dependent_devices, device_list) { + if (handle == dd->handle) + return dd; + } + return NULL; +} + + + +struct dependent_device *alloc_dependent_device(acpi_handle handle) +{ + struct dependent_device *dd; + + dd = kzalloc(sizeof(*dd), GFP_KERNEL); + if (dd) { + INIT_LIST_HEAD(&dd->pci_list); + INIT_LIST_HEAD(&dd->device_list); + dd->handle = handle; + } + return dd; +} + + + +static int is_dock(acpi_handle handle) +{ + acpi_status status; + acpi_handle tmp; + + status = acpi_get_handle(handle, "_DCK", &tmp); + if (ACPI_FAILURE(status)) { + return 0; + } + return 1; +} + + + +static int dock_present(void) +{ + unsigned long sta; + acpi_status status; + + if (ds) { + status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta); + if (ACPI_SUCCESS(status) && sta) + return 1; + } + return 0; +} + + + +static void eject_dock(void) +{ + struct acpi_object_list arg_list; + union acpi_object arg; + + arg_list.count = 1; + arg_list.pointer = &arg; + arg.type = ACPI_TYPE_INTEGER; + arg.integer.value = 1; + + if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0", + &arg_list, NULL)) || dock_present()) + warn("%s: failed to eject dock!\n", __FUNCTION__); + + return; +} + + + + +static acpi_status handle_dock(int dock) +{ + acpi_status status; + struct acpi_object_list arg_list; + union acpi_object arg; + struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + + dbg("%s: %s\n", __FUNCTION__, dock ? "docking" : "undocking"); + + /* _DCK method has one argument */ + arg_list.count = 1; + arg_list.pointer = &arg; + arg.type = ACPI_TYPE_INTEGER; + arg.integer.value = dock; + status = acpi_evaluate_object(ds->handle, "_DCK", + &arg_list, &buffer); + if (ACPI_FAILURE(status)) + err("%s: failed to execute _DCK\n", __FUNCTION__); + acpi_os_free(buffer.pointer); + + return status; +} + + + +static inline void dock(void) +{ + handle_dock(1); +} + + + +static inline void undock(void) +{ + handle_dock(0); +} + + + +/* + * the _DCK method can do funny things... and sometimes not + * hah-hah funny. + * + * TBD - figure out a way to only call fixups for + * systems that require them. + */ +static void post_dock_fixups(void) +{ + struct pci_bus *bus; + u32 buses; + struct dependent_device *dd; + + list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) { + bus = dd->func->slot->bridge->pci_bus; + + /* fixup bad _DCK function that rewrites + * secondary bridge on slot + */ + pci_read_config_dword(bus->self, + PCI_PRIMARY_BUS, + &buses); + + if (((buses >> 8) & 0xff) != bus->secondary) { + buses = (buses & 0xff000000) + | ((unsigned int)(bus->primary) << 0) + | ((unsigned int)(bus->secondary) << 8) + | ((unsigned int)(bus->subordinate) << 16); + pci_write_config_dword(bus->self, + PCI_PRIMARY_BUS, + buses); + } + } +} + + + +static void hotplug_pci(u32 type) +{ + struct dependent_device *dd; + + list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) + handle_hotplug_event_func(dd->handle, type, dd->func); +} + + + +static inline void begin_dock(void) +{ + ds->flags |= DOCK_DOCKING; +} + + +static inline void complete_dock(void) +{ + ds->flags &= ~(DOCK_DOCKING); + ds->last_dock_time = jiffies; +} + + +static int dock_in_progress(void) +{ + if (ds->flags & DOCK_DOCKING || + ds->last_dock_time == jiffies) { + dbg("dock in progress\n"); + return 1; + } + return 0; +} + + + +static void +handle_hotplug_event_dock(acpi_handle handle, u32 type, void *context) +{ + dbg("%s: enter\n", __FUNCTION__); + + switch (type) { + case ACPI_NOTIFY_BUS_CHECK: + dbg("BUS Check\n"); + if (!dock_in_progress() && dock_present()) { + begin_dock(); + dock(); + if (!dock_present()) { + err("Unable to dock!\n"); + break; + } + post_dock_fixups(); + hotplug_pci(type); + complete_dock(); + } + break; + case ACPI_NOTIFY_EJECT_REQUEST: + dbg("EJECT request\n"); + if (!dock_in_progress() && dock_present()) { + hotplug_pci(type); + undock(); + eject_dock(); + if (dock_present()) + err("Unable to undock!\n"); + } + break; + } +} + + + + +static acpi_status +find_dock_ejd(acpi_handle handle, u32 lvl, void *context, void **rv) +{ + acpi_status status; + acpi_handle tmp; + acpi_handle dck_handle = (acpi_handle) context; + char objname[64]; + struct acpi_buffer buffer = { .length = sizeof(objname), + .pointer = objname }; + struct acpi_buffer ejd_buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + union acpi_object *ejd_obj; + + status = acpi_get_handle(handle, "_EJD", &tmp); + if (ACPI_FAILURE(status)) + return AE_OK; + + /* make sure we are dependent on the dock device, + * by executing the _EJD method, then getting a handle + * to the device referenced by that name. If that + * device handle is the same handle as the dock station + * handle, then we are a device dependent on the dock station + */ + acpi_get_name(dck_handle, ACPI_FULL_PATHNAME, &buffer); + status = acpi_evaluate_object(handle, "_EJD", NULL, &ejd_buffer); + if (ACPI_FAILURE(status)) { + err("Unable to execute _EJD!\n"); + goto find_ejd_out; + } + ejd_obj = ejd_buffer.pointer; + status = acpi_get_handle(NULL, ejd_obj->string.pointer, &tmp); + if (ACPI_FAILURE(status)) + goto find_ejd_out; + + if (tmp == dck_handle) { + struct dependent_device *dd; + dbg("%s: found device dependent on dock\n", __FUNCTION__); + dd = alloc_dependent_device(handle); + if (!dd) { + err("Can't allocate memory for dependent device!\n"); + goto find_ejd_out; + } + add_dependent_device(dd); + } + +find_ejd_out: + acpi_os_free(ejd_buffer.pointer); + return AE_OK; +} + + + +int detect_dependent_devices(acpi_handle *bridge_handle) +{ + acpi_status status; + int count; + + count = 0; + + status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, + (u32)1, find_dependent_device, + (void *)&count, NULL); + + return count; +} + + + + + +static acpi_status +find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) +{ + int *count = (int *)context; + + if (is_dock(handle)) { + dbg("%s: found dock\n", __FUNCTION__); + ds = kzalloc(sizeof(*ds), GFP_KERNEL); + ds->handle = handle; + INIT_LIST_HEAD(&ds->dependent_devices); + INIT_LIST_HEAD(&ds->pci_dependent_devices); + + /* look for devices dependent on dock station */ + acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, find_dock_ejd, handle, NULL); + + acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, + handle_hotplug_event_dock, ds); + (*count)++; + } + + return AE_OK; +} + + + + +int find_dock_station(void) +{ + int num = 0; + + ds = NULL; + + /* start from the root object, because some laptops define + * _DCK methods outside the scope of PCI (IBM x-series laptop) + */ + acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, find_dock, &num, NULL); + + return num; +} + + + +void remove_dock_station(void) +{ + struct dependent_device *dd, *tmp; + if (ds) { + if (ACPI_FAILURE(acpi_remove_notify_handler(ds->handle, + ACPI_SYSTEM_NOTIFY, handle_hotplug_event_dock))) + err("failed to remove dock notify handler\n"); + + /* free all dependent devices */ + list_for_each_entry_safe(dd, tmp, &ds->dependent_devices, + device_list) + kfree(dd); + + /* no need to touch the pci_dependent_device list, + * cause all memory was freed above + */ + kfree(ds); + } +} + + diff --git a/trunk/drivers/pci/hotplug/acpiphp_glue.c b/trunk/drivers/pci/hotplug/acpiphp_glue.c index ef95d12fb32c..d370f999782e 100644 --- a/trunk/drivers/pci/hotplug/acpiphp_glue.c +++ b/trunk/drivers/pci/hotplug/acpiphp_glue.c @@ -59,7 +59,6 @@ static LIST_HEAD(bridge_list); static void handle_hotplug_event_bridge (acpi_handle, u32, void *); static void acpiphp_sanitize_bus(struct pci_bus *bus); static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); -static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context); /* @@ -117,59 +116,6 @@ is_ejectable_slot(acpi_handle handle, u32 lvl, void *context, void **rv) } } -/* callback routine to check for the existance of a pci dock device */ -static acpi_status -is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv) -{ - int *count = (int *)context; - - if (is_dock_device(handle)) { - (*count)++; - return AE_CTRL_TERMINATE; - } else { - return AE_OK; - } -} - - - - -/* - * the _DCK method can do funny things... and sometimes not - * hah-hah funny. - * - * TBD - figure out a way to only call fixups for - * systems that require them. - */ -static int post_dock_fixups(struct notifier_block *nb, unsigned long val, - void *v) -{ - struct acpiphp_func *func = container_of(nb, struct acpiphp_func, nb); - struct pci_bus *bus = func->slot->bridge->pci_bus; - u32 buses; - - if (!bus->self) - return NOTIFY_OK; - - /* fixup bad _DCK function that rewrites - * secondary bridge on slot - */ - pci_read_config_dword(bus->self, - PCI_PRIMARY_BUS, - &buses); - - if (((buses >> 8) & 0xff) != bus->secondary) { - buses = (buses & 0xff000000) - | ((unsigned int)(bus->primary) << 0) - | ((unsigned int)(bus->secondary) << 8) - | ((unsigned int)(bus->subordinate) << 16); - pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses); - } - return NOTIFY_OK; -} - - - /* callback routine to register each ACPI PCI slot object */ static acpi_status @@ -178,6 +124,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context; struct acpiphp_slot *slot; struct acpiphp_func *newfunc; + struct dependent_device *dd; acpi_handle tmp; acpi_status status = AE_OK; unsigned long adr, sun; @@ -190,7 +137,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) status = acpi_get_handle(handle, "_EJ0", &tmp); - if (ACPI_FAILURE(status) && !(is_dock_device(handle))) + if (ACPI_FAILURE(status) && !(is_dependent_device(handle))) return AE_OK; device = (adr >> 16) & 0xffff; @@ -215,18 +162,23 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp))) newfunc->flags |= FUNC_HAS_PS3; - if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp))) + if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp))) { newfunc->flags |= FUNC_HAS_DCK; - - status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun); - if (ACPI_FAILURE(status)) { - /* - * use the count of the number of slots we've found - * for the number of the slot + /* add to devices dependent on dock station, + * because this may actually be the dock bridge */ - sun = bridge->nr_slots+1; + dd = alloc_dependent_device(handle); + if (!dd) + err("Can't allocate memory for " + "new dependent device!\n"); + else + add_dependent_device(dd); } + status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun); + if (ACPI_FAILURE(status)) + sun = -1; + /* search for objects that share the same slot */ for (slot = bridge->slots; slot; slot = slot->next) if (slot->device == device) { @@ -273,23 +225,20 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); } - if (is_dock_device(handle)) { - /* we don't want to call this device's _EJ0 - * because we want the dock notify handler - * to call it after it calls _DCK + /* if this is a device dependent on a dock station, + * associate the acpiphp_func to the dependent_device + * struct. + */ + if ((dd = get_dependent_device(handle))) { + newfunc->flags |= FUNC_IS_DD; + /* + * we don't want any devices which is dependent + * on the dock to have it's _EJ0 method executed. + * because we need to run _DCK first. */ newfunc->flags &= ~FUNC_HAS_EJ0; - if (register_hotplug_dock_device(handle, - handle_hotplug_event_func, newfunc)) - dbg("failed to register dock device\n"); - - /* we need to be notified when dock events happen - * outside of the hotplug operation, since we may - * need to do fixups before we can hotplug. - */ - newfunc->nb.notifier_call = post_dock_fixups; - if (register_dock_notifier(&newfunc->nb)) - dbg("failed to register a dock notifier"); + dd->func = newfunc; + add_pci_dependent_device(dd); } /* install notify handler */ @@ -328,15 +277,6 @@ static int detect_ejectable_slots(acpi_handle *bridge_handle) status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1, is_ejectable_slot, (void *)&count, NULL); - /* - * we also need to add this bridge if there is a dock bridge or - * other pci device on a dock station (removable) - */ - if (!count) - status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, - (u32)1, is_pci_dock_device, (void *)&count, - NULL); - return count; } @@ -547,7 +487,8 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) goto out; /* check if this bridge has ejectable slots */ - if ((detect_ejectable_slots(handle) > 0)) { + if ((detect_ejectable_slots(handle) > 0) || + (detect_dependent_devices(handle) > 0)) { dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); add_p2p_bridge(handle, dev); } @@ -664,10 +605,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) list_for_each_safe (list, tmp, &slot->funcs) { struct acpiphp_func *func; func = list_entry(list, struct acpiphp_func, sibling); - if (is_dock_device(func->handle)) { - unregister_hotplug_dock_device(func->handle); - unregister_dock_notifier(&func->nb); - } if (!(func->flags & FUNC_HAS_DCK)) { status = acpi_remove_notify_handler(func->handle, ACPI_SYSTEM_NOTIFY, @@ -1503,7 +1440,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont * handles ACPI event notification on slots * */ -static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) +void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) { struct acpiphp_func *func; char objname[64]; diff --git a/trunk/include/acpi/acconfig.h b/trunk/include/acpi/acconfig.h index b492857fe721..b9beceb33141 100644 --- a/trunk/include/acpi/acconfig.h +++ b/trunk/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20060623 +#define ACPI_CA_VERSION 0x20060608 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/trunk/include/acpi/acdispat.h b/trunk/include/acpi/acdispat.h index a22fe9cf8493..288f84903af7 100644 --- a/trunk/include/acpi/acdispat.h +++ b/trunk/include/acpi/acdispat.h @@ -201,7 +201,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc, acpi_status acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, union acpi_operand_object *obj_desc, - struct acpi_walk_state *walk_state); + struct acpi_namespace_node *calling_method_node); acpi_status acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state); diff --git a/trunk/include/acpi/acglobal.h b/trunk/include/acpi/acglobal.h index 06972e6637de..14531d48f6b6 100644 --- a/trunk/include/acpi/acglobal.h +++ b/trunk/include/acpi/acglobal.h @@ -181,12 +181,6 @@ ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; extern struct acpi_table_list acpi_gbl_table_lists[ACPI_TABLE_ID_MAX + 1]; extern struct acpi_table_support acpi_gbl_table_data[ACPI_TABLE_ID_MAX + 1]; -/***************************************************************************** - * - * Mutual exlusion within ACPICA subsystem - * - ****************************************************************************/ - /* * Predefined mutex objects. This array contains the * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. @@ -194,20 +188,6 @@ extern struct acpi_table_support acpi_gbl_table_data[ACPI_TABLE_ID_MAX + 1]; */ ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX]; -/* - * Global lock semaphore works in conjunction with the actual HW global lock - */ -ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore; - -/* - * Spinlocks are used for interfaces that can be possibly called at - * interrupt level - */ -ACPI_EXTERN spinlock_t _acpi_gbl_gpe_lock; /* For GPE data structs and registers */ -ACPI_EXTERN spinlock_t _acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ -#define acpi_gbl_gpe_lock &_acpi_gbl_gpe_lock -#define acpi_gbl_hardware_lock &_acpi_gbl_hardware_lock - /***************************************************************************** * * Miscellaneous globals @@ -237,6 +217,7 @@ ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify; ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; +ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore; /* Misc */ @@ -334,6 +315,11 @@ ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; ACPI_EXTERN struct acpi_gpe_block_info *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; +/* Spinlocks */ + +ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock; +ACPI_EXTERN acpi_handle acpi_gbl_hardware_lock; + /***************************************************************************** * * Debugger globals diff --git a/trunk/include/acpi/acinterp.h b/trunk/include/acpi/acinterp.h index 216339a8f1f6..9f22cfcb624b 100644 --- a/trunk/include/acpi/acinterp.h +++ b/trunk/include/acpi/acinterp.h @@ -287,10 +287,7 @@ acpi_ex_system_wait_event(union acpi_operand_object *time, acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc); -acpi_status -acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout); - -acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout); +acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout); /* * exoparg1 - ACPI AML execution, 1 operand diff --git a/trunk/include/acpi/aclocal.h b/trunk/include/acpi/aclocal.h index 56b802486161..1eeca7adca95 100644 --- a/trunk/include/acpi/aclocal.h +++ b/trunk/include/acpi/aclocal.h @@ -47,11 +47,10 @@ /* acpisrc:struct_defs -- for acpisrc conversion */ #define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */ -#define ACPI_DO_NOT_WAIT 0 -#define ACPI_SERIALIZED 0xFF +#define ACPI_INFINITE_CONCURRENCY 0xFF +typedef void *acpi_mutex; typedef u32 acpi_mutex_handle; -#define ACPI_GLOBAL_LOCK (acpi_semaphore) (-1) /* Total number of aml opcodes defined */ @@ -80,15 +79,16 @@ union acpi_parse_object; * table below also! */ #define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */ -#define ACPI_MTX_TABLES 1 /* Data for ACPI tables */ -#define ACPI_MTX_NAMESPACE 2 /* ACPI Namespace */ -#define ACPI_MTX_EVENTS 3 /* Data for ACPI events */ -#define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */ -#define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */ -#define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */ -#define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */ - -#define ACPI_MAX_MUTEX 7 +#define ACPI_MTX_CONTROL_METHOD 1 /* Control method termination [TBD: may no longer be necessary] */ +#define ACPI_MTX_TABLES 2 /* Data for ACPI tables */ +#define ACPI_MTX_NAMESPACE 3 /* ACPI Namespace */ +#define ACPI_MTX_EVENTS 4 /* Data for ACPI events */ +#define ACPI_MTX_CACHES 5 /* Internal caches, general purposes */ +#define ACPI_MTX_MEMORY 6 /* Debug memory tracking lists */ +#define ACPI_MTX_DEBUG_CMD_COMPLETE 7 /* AML debugger */ +#define ACPI_MTX_DEBUG_CMD_READY 8 /* AML debugger */ + +#define ACPI_MAX_MUTEX 8 #define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) @@ -98,13 +98,14 @@ union acpi_parse_object; static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = { "ACPI_MTX_Interpreter", + "ACPI_MTX_Method", "ACPI_MTX_Tables", "ACPI_MTX_Namespace", "ACPI_MTX_Events", "ACPI_MTX_Caches", "ACPI_MTX_Memory", - "ACPI_MTX_CommandComplete", - "ACPI_MTX_CommandReady" + "ACPI_MTX_DebugCmdComplete", + "ACPI_MTX_DebugCmdReady" }; #endif @@ -703,13 +704,6 @@ struct acpi_bit_register_info { u16 access_bit_mask; }; -/* - * Some ACPI registers have bits that must be ignored -- meaning that they - * must be preserved. - */ -#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ -#define ACPI_PM1_CONTROL_PRESERVED_BITS 0x0201 /* Bit 9, Bit 0 (SCI_EN) */ - /* * Register IDs * These are the full ACPI registers diff --git a/trunk/include/acpi/acmacros.h b/trunk/include/acpi/acmacros.h index 4bb38068f40d..38f9aa4bef00 100644 --- a/trunk/include/acpi/acmacros.h +++ b/trunk/include/acpi/acmacros.h @@ -394,8 +394,6 @@ #define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) #define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) -#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask)) - /* Generate a UUID */ #define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ diff --git a/trunk/include/acpi/acobject.h b/trunk/include/acpi/acobject.h index 8fdee31119f3..1747d94084d8 100644 --- a/trunk/include/acpi/acobject.h +++ b/trunk/include/acpi/acobject.h @@ -140,14 +140,14 @@ struct acpi_object_package { *****************************************************************************/ struct acpi_object_event { - ACPI_OBJECT_COMMON_HEADER acpi_semaphore os_semaphore; /* Actual OS synchronization object */ + ACPI_OBJECT_COMMON_HEADER void *semaphore; }; struct acpi_object_mutex { ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */ u16 acquisition_depth; /* Allow multiple Acquires, same thread */ struct acpi_thread_state *owner_thread; /* Current owner of the mutex */ - acpi_mutex os_mutex; /* Actual OS synchronization object */ + void *semaphore; /* Actual OS synchronization object */ union acpi_operand_object *prev; /* Link for list of acquired mutexes */ union acpi_operand_object *next; /* Link for list of acquired mutexes */ struct acpi_namespace_node *node; /* Containing namespace node */ @@ -166,8 +166,8 @@ struct acpi_object_region { struct acpi_object_method { ACPI_OBJECT_COMMON_HEADER u8 method_flags; u8 param_count; - u8 sync_level; - union acpi_operand_object *mutex; + u8 concurrency; + void *semaphore; u8 *aml_start; ACPI_INTERNAL_METHOD implementation; u32 aml_length; diff --git a/trunk/include/acpi/acpi_bus.h b/trunk/include/acpi/acpi_bus.h index f338e40bd544..a2b3e390a503 100644 --- a/trunk/include/acpi/acpi_bus.h +++ b/trunk/include/acpi/acpi_bus.h @@ -334,7 +334,7 @@ int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, acpi_handle handle, int type); int acpi_bus_trim(struct acpi_device *start, int rmdevice); int acpi_bus_start(struct acpi_device *device); -acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd); + int acpi_match_ids(struct acpi_device *device, char *ids); int acpi_create_dir(struct acpi_device *); void acpi_remove_dir(struct acpi_device *); diff --git a/trunk/include/acpi/acpi_drivers.h b/trunk/include/acpi/acpi_drivers.h index 6a5bdcefec64..b425f9bb6d43 100644 --- a/trunk/include/acpi/acpi_drivers.h +++ b/trunk/include/acpi/acpi_drivers.h @@ -110,21 +110,4 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type); extern int acpi_specific_hotkey_enabled; -/*-------------------------------------------------------------------------- - Dock Station - -------------------------------------------------------------------------- */ -#if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE) -extern int is_dock_device(acpi_handle handle); -extern int register_dock_notifier(struct notifier_block *nb); -extern void unregister_dock_notifier(struct notifier_block *nb); -extern int register_hotplug_dock_device(acpi_handle handle, - acpi_notify_handler handler, void *context); -extern void unregister_hotplug_dock_device(acpi_handle handle); -#else -#define is_dock_device(h) (0) -#define register_dock_notifier(nb) (-ENODEV) -#define unregister_dock_notifier(nb) do { } while(0) -#define register_hotplug_dock_device(h1, h2, c) (-ENODEV) -#define unregister_hotplug_dock_device(h) do { } while(0) -#endif #endif /*__ACPI_DRIVERS_H__*/ diff --git a/trunk/include/acpi/acpiosxf.h b/trunk/include/acpi/acpiosxf.h index 89bc4a16c2e8..8f473c83b7c4 100644 --- a/trunk/include/acpi/acpiosxf.h +++ b/trunk/include/acpi/acpiosxf.h @@ -96,47 +96,25 @@ acpi_os_table_override(struct acpi_table_header *existing_table, struct acpi_table_header **new_table); /* - * Spinlock primitives - */ -acpi_status acpi_os_create_lock(acpi_spinlock * out_handle); - -void acpi_os_delete_lock(acpi_spinlock handle); - -acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle); - -void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags); - -/* - * Semaphore primitives + * Synchronization primitives */ acpi_status acpi_os_create_semaphore(u32 max_units, - u32 initial_units, acpi_semaphore * out_handle); + u32 initial_units, acpi_handle * out_handle); -acpi_status acpi_os_delete_semaphore(acpi_semaphore handle); +acpi_status acpi_os_delete_semaphore(acpi_handle handle); -acpi_status -acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout); - -acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units); - -/* - * Mutex primitives - */ -acpi_status acpi_os_create_mutex(acpi_mutex * out_handle); +acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout); -void acpi_os_delete_mutex(acpi_mutex handle); +acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units); -acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout); +acpi_status acpi_os_create_lock(acpi_handle * out_handle); -void acpi_os_release_mutex(acpi_mutex handle); +void acpi_os_delete_lock(acpi_handle handle); -/* Temporary macros for Mutex* interfaces, map to existing semaphore xfaces */ +acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle); -#define acpi_os_create_mutex(out_handle) acpi_os_create_semaphore (1, 1, out_handle) -#define acpi_os_delete_mutex(handle) (void) acpi_os_delete_semaphore (handle) -#define acpi_os_acquire_mutex(handle,time) acpi_os_wait_semaphore (handle, 1, time) -#define acpi_os_release_mutex(handle) (void) acpi_os_signal_semaphore (handle, 1) +void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags); /* * Memory allocation and mapping diff --git a/trunk/include/acpi/actypes.h b/trunk/include/acpi/actypes.h index 64b603cfe92e..77cf1236b05a 100644 --- a/trunk/include/acpi/actypes.h +++ b/trunk/include/acpi/actypes.h @@ -241,7 +241,7 @@ typedef acpi_native_uint acpi_size; /******************************************************************************* * - * OS-dependent and compiler-dependent types + * OS- or compiler-dependent types * * If the defaults below are not appropriate for the host system, they can * be defined in the compiler-specific or OS-specific header, and this will @@ -249,34 +249,27 @@ typedef acpi_native_uint acpi_size; * ******************************************************************************/ -/* Value returned by acpi_os_get_thread_id */ - -#ifndef acpi_thread_id -#define acpi_thread_id acpi_native_uint -#endif - -/* Object returned from acpi_os_create_lock */ - -#ifndef acpi_spinlock -#define acpi_spinlock void * -#endif - -/* Flags for acpi_os_acquire_lock/acpi_os_release_lock */ +/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ -#ifndef acpi_cpu_flags -#define acpi_cpu_flags acpi_native_uint +#ifndef acpi_uintptr_t +#define acpi_uintptr_t void * #endif -/* Object returned from acpi_os_create_cache */ - +/* + * If acpi_cache_t was not defined in the OS-dependent header, + * define it now. This is typically the case where the local cache + * manager implementation is to be used (ACPI_USE_LOCAL_CACHE) + */ #ifndef acpi_cache_t #define acpi_cache_t struct acpi_memory_list #endif -/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ - -#ifndef acpi_uintptr_t -#define acpi_uintptr_t void * +/* + * Allow the CPU flags word to be defined per-OS to simplify the use of the + * lock and unlock OSL interfaces. + */ +#ifndef acpi_cpu_flags +#define acpi_cpu_flags acpi_native_uint #endif /* @@ -305,6 +298,13 @@ typedef acpi_native_uint acpi_size; #define ACPI_EXPORT_SYMBOL(symbol) #endif +/* + * thread_id is returned by acpi_os_get_thread_id. + */ +#ifndef acpi_thread_id +#define acpi_thread_id acpi_native_uint +#endif + /******************************************************************************* * * Independent types @@ -380,11 +380,6 @@ struct uint32_struct { u32 hi; }; -/* Synchronization objects */ - -#define acpi_mutex void * -#define acpi_semaphore void * - /* * Acpi integer width. In ACPI version 1, integers are * 32 bits. In ACPI version 2, integers are 64 bits. diff --git a/trunk/include/acpi/platform/aclinux.h b/trunk/include/acpi/platform/aclinux.h index 3f853cabbd41..277d35bced03 100644 --- a/trunk/include/acpi/platform/aclinux.h +++ b/trunk/include/acpi/platform/aclinux.h @@ -58,13 +58,11 @@ #include #include #include -#include /* Host-dependent types and defines */ #define ACPI_MACHINE_WIDTH BITS_PER_LONG #define acpi_cache_t kmem_cache_t -#define acpi_spinlock spinlock_t * #define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); #define strtoul simple_strtoul diff --git a/trunk/include/acpi/processor.h b/trunk/include/acpi/processor.h index 9dd5b75961f8..77371b3cdc44 100644 --- a/trunk/include/acpi/processor.h +++ b/trunk/include/acpi/processor.h @@ -62,7 +62,6 @@ struct acpi_processor_cx { u32 latency_ticks; u32 power; u32 usage; - u64 time; struct acpi_processor_cx_policy promotion; struct acpi_processor_cx_policy demotion; }; diff --git a/trunk/include/linux/cpufreq.h b/trunk/include/linux/cpufreq.h index 35e137636b0b..466fbe9e4899 100644 --- a/trunk/include/linux/cpufreq.h +++ b/trunk/include/linux/cpufreq.h @@ -100,10 +100,8 @@ struct cpufreq_policy { #define CPUFREQ_INCOMPATIBLE (1) #define CPUFREQ_NOTIFY (2) -#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ -#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ -#define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ -#define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ +#define CPUFREQ_SHARED_TYPE_ALL (0) /* All dependent CPUs should set freq */ +#define CPUFREQ_SHARED_TYPE_ANY (1) /* Freq can be set from any dependent CPU */ /******************** cpufreq transition notifiers *******************/ diff --git a/trunk/include/linux/kobject.h b/trunk/include/linux/kobject.h index 0503b2ed8bae..2d229327959e 100644 --- a/trunk/include/linux/kobject.h +++ b/trunk/include/linux/kobject.h @@ -46,8 +46,6 @@ enum kobject_action { KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices (broken) */ KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* device offline */ KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* device online */ - KOBJ_UNDOCK = (__force kobject_action_t) 0x08, /* undocking */ - KOBJ_DOCK = (__force kobject_action_t) 0x09, /* dock */ }; struct kobject { diff --git a/trunk/lib/kobject_uevent.c b/trunk/lib/kobject_uevent.c index 2b1530fc573b..7f20e7b857cb 100644 --- a/trunk/lib/kobject_uevent.c +++ b/trunk/lib/kobject_uevent.c @@ -50,10 +50,6 @@ static char *action_to_string(enum kobject_action action) return "offline"; case KOBJ_ONLINE: return "online"; - case KOBJ_DOCK: - return "dock"; - case KOBJ_UNDOCK: - return "undock"; default: return NULL; }