diff options
Diffstat (limited to 'drivers/acpi')
114 files changed, 4167 insertions, 883 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 119d58db8342..0300bf612946 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -181,6 +181,12 @@ config ACPI_DOCK | |||
181 | This driver supports ACPI-controlled docking stations and removable | 181 | This driver supports ACPI-controlled docking stations and removable |
182 | drive bays such as the IBM Ultrabay and the Dell Module Bay. | 182 | drive bays such as the IBM Ultrabay and the Dell Module Bay. |
183 | 183 | ||
184 | config ACPI_I2C | ||
185 | def_tristate I2C | ||
186 | depends on I2C | ||
187 | help | ||
188 | ACPI I2C enumeration support. | ||
189 | |||
184 | config ACPI_PROCESSOR | 190 | config ACPI_PROCESSOR |
185 | tristate "Processor" | 191 | tristate "Processor" |
186 | select THERMAL | 192 | select THERMAL |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 82422fe90f81..2a4502becd13 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -21,9 +21,10 @@ obj-y += acpi.o \ | |||
21 | acpi-y += osl.o utils.o reboot.o | 21 | acpi-y += osl.o utils.o reboot.o |
22 | acpi-y += nvs.o | 22 | acpi-y += nvs.o |
23 | 23 | ||
24 | # sleep related files | 24 | # Power management related files |
25 | acpi-y += wakeup.o | 25 | acpi-y += wakeup.o |
26 | acpi-y += sleep.o | 26 | acpi-y += sleep.o |
27 | acpi-$(CONFIG_PM) += device_pm.o | ||
27 | acpi-$(CONFIG_ACPI_SLEEP) += proc.o | 28 | acpi-$(CONFIG_ACPI_SLEEP) += proc.o |
28 | 29 | ||
29 | 30 | ||
@@ -32,10 +33,12 @@ acpi-$(CONFIG_ACPI_SLEEP) += proc.o | |||
32 | # | 33 | # |
33 | acpi-y += bus.o glue.o | 34 | acpi-y += bus.o glue.o |
34 | acpi-y += scan.o | 35 | acpi-y += scan.o |
36 | acpi-y += resource.o | ||
35 | acpi-y += processor_core.o | 37 | acpi-y += processor_core.o |
36 | acpi-y += ec.o | 38 | acpi-y += ec.o |
37 | acpi-$(CONFIG_ACPI_DOCK) += dock.o | 39 | acpi-$(CONFIG_ACPI_DOCK) += dock.o |
38 | acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 40 | acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o |
41 | acpi-y += acpi_platform.o | ||
39 | acpi-y += power.o | 42 | acpi-y += power.o |
40 | acpi-y += event.o | 43 | acpi-y += event.o |
41 | acpi-y += sysfs.o | 44 | acpi-y += sysfs.o |
@@ -67,6 +70,7 @@ obj-$(CONFIG_ACPI_HED) += hed.o | |||
67 | obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o | 70 | obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o |
68 | obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o | 71 | obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o |
69 | obj-$(CONFIG_ACPI_BGRT) += bgrt.o | 72 | obj-$(CONFIG_ACPI_BGRT) += bgrt.o |
73 | obj-$(CONFIG_ACPI_I2C) += acpi_i2c.o | ||
70 | 74 | ||
71 | # processor has its own "processor." module_param namespace | 75 | # processor has its own "processor." module_param namespace |
72 | processor-y := processor_driver.o processor_throttling.o | 76 | processor-y := processor_driver.o processor_throttling.o |
diff --git a/drivers/acpi/acpi_i2c.c b/drivers/acpi/acpi_i2c.c new file mode 100644 index 000000000000..82045e3f5cac --- /dev/null +++ b/drivers/acpi/acpi_i2c.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * ACPI I2C enumeration support | ||
3 | * | ||
4 | * Copyright (C) 2012, Intel Corporation | ||
5 | * Author: Mika Westerberg <mika.westerberg@linux.intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/acpi.h> | ||
13 | #include <linux/device.h> | ||
14 | #include <linux/export.h> | ||
15 | #include <linux/i2c.h> | ||
16 | #include <linux/ioport.h> | ||
17 | |||
18 | ACPI_MODULE_NAME("i2c"); | ||
19 | |||
20 | static int acpi_i2c_add_resource(struct acpi_resource *ares, void *data) | ||
21 | { | ||
22 | struct i2c_board_info *info = data; | ||
23 | |||
24 | if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { | ||
25 | struct acpi_resource_i2c_serialbus *sb; | ||
26 | |||
27 | sb = &ares->data.i2c_serial_bus; | ||
28 | if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) { | ||
29 | info->addr = sb->slave_address; | ||
30 | if (sb->access_mode == ACPI_I2C_10BIT_MODE) | ||
31 | info->flags |= I2C_CLIENT_TEN; | ||
32 | } | ||
33 | } else if (info->irq < 0) { | ||
34 | struct resource r; | ||
35 | |||
36 | if (acpi_dev_resource_interrupt(ares, 0, &r)) | ||
37 | info->irq = r.start; | ||
38 | } | ||
39 | |||
40 | /* Tell the ACPI core to skip this resource */ | ||
41 | return 1; | ||
42 | } | ||
43 | |||
44 | static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level, | ||
45 | void *data, void **return_value) | ||
46 | { | ||
47 | struct i2c_adapter *adapter = data; | ||
48 | struct list_head resource_list; | ||
49 | struct i2c_board_info info; | ||
50 | struct acpi_device *adev; | ||
51 | int ret; | ||
52 | |||
53 | if (acpi_bus_get_device(handle, &adev)) | ||
54 | return AE_OK; | ||
55 | if (acpi_bus_get_status(adev) || !adev->status.present) | ||
56 | return AE_OK; | ||
57 | |||
58 | memset(&info, 0, sizeof(info)); | ||
59 | info.acpi_node.handle = handle; | ||
60 | info.irq = -1; | ||
61 | |||
62 | INIT_LIST_HEAD(&resource_list); | ||
63 | ret = acpi_dev_get_resources(adev, &resource_list, | ||
64 | acpi_i2c_add_resource, &info); | ||
65 | acpi_dev_free_resource_list(&resource_list); | ||
66 | |||
67 | if (ret < 0 || !info.addr) | ||
68 | return AE_OK; | ||
69 | |||
70 | strlcpy(info.type, dev_name(&adev->dev), sizeof(info.type)); | ||
71 | if (!i2c_new_device(adapter, &info)) { | ||
72 | dev_err(&adapter->dev, | ||
73 | "failed to add I2C device %s from ACPI\n", | ||
74 | dev_name(&adev->dev)); | ||
75 | } | ||
76 | |||
77 | return AE_OK; | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * acpi_i2c_register_devices - enumerate I2C slave devices behind adapter | ||
82 | * @adapter: pointer to adapter | ||
83 | * | ||
84 | * Enumerate all I2C slave devices behind this adapter by walking the ACPI | ||
85 | * namespace. When a device is found it will be added to the Linux device | ||
86 | * model and bound to the corresponding ACPI handle. | ||
87 | */ | ||
88 | void acpi_i2c_register_devices(struct i2c_adapter *adapter) | ||
89 | { | ||
90 | acpi_handle handle; | ||
91 | acpi_status status; | ||
92 | |||
93 | handle = ACPI_HANDLE(&adapter->dev); | ||
94 | if (!handle) | ||
95 | return; | ||
96 | |||
97 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, | ||
98 | acpi_i2c_add_device, NULL, | ||
99 | adapter, NULL); | ||
100 | if (ACPI_FAILURE(status)) | ||
101 | dev_warn(&adapter->dev, "failed to enumerate I2C slaves\n"); | ||
102 | } | ||
103 | EXPORT_SYMBOL_GPL(acpi_i2c_register_devices); | ||
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c new file mode 100644 index 000000000000..db129b9f52cb --- /dev/null +++ b/drivers/acpi/acpi_platform.c | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * ACPI support for platform bus type. | ||
3 | * | ||
4 | * Copyright (C) 2012, Intel Corporation | ||
5 | * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> | ||
6 | * Mathias Nyman <mathias.nyman@linux.intel.com> | ||
7 | * Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/acpi.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | |||
20 | #include "internal.h" | ||
21 | |||
22 | ACPI_MODULE_NAME("platform"); | ||
23 | |||
24 | /** | ||
25 | * acpi_create_platform_device - Create platform device for ACPI device node | ||
26 | * @adev: ACPI device node to create a platform device for. | ||
27 | * | ||
28 | * Check if the given @adev can be represented as a platform device and, if | ||
29 | * that's the case, create and register a platform device, populate its common | ||
30 | * resources and returns a pointer to it. Otherwise, return %NULL. | ||
31 | * | ||
32 | * The platform device's name will be taken from the @adev's _HID and _UID. | ||
33 | */ | ||
34 | struct platform_device *acpi_create_platform_device(struct acpi_device *adev) | ||
35 | { | ||
36 | struct platform_device *pdev = NULL; | ||
37 | struct acpi_device *acpi_parent; | ||
38 | struct platform_device_info pdevinfo; | ||
39 | struct resource_list_entry *rentry; | ||
40 | struct list_head resource_list; | ||
41 | struct resource *resources; | ||
42 | int count; | ||
43 | |||
44 | /* If the ACPI node already has a physical device attached, skip it. */ | ||
45 | if (adev->physical_node_count) | ||
46 | return NULL; | ||
47 | |||
48 | INIT_LIST_HEAD(&resource_list); | ||
49 | count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); | ||
50 | if (count <= 0) | ||
51 | return NULL; | ||
52 | |||
53 | resources = kmalloc(count * sizeof(struct resource), GFP_KERNEL); | ||
54 | if (!resources) { | ||
55 | dev_err(&adev->dev, "No memory for resources\n"); | ||
56 | acpi_dev_free_resource_list(&resource_list); | ||
57 | return NULL; | ||
58 | } | ||
59 | count = 0; | ||
60 | list_for_each_entry(rentry, &resource_list, node) | ||
61 | resources[count++] = rentry->res; | ||
62 | |||
63 | acpi_dev_free_resource_list(&resource_list); | ||
64 | |||
65 | memset(&pdevinfo, 0, sizeof(pdevinfo)); | ||
66 | /* | ||
67 | * If the ACPI node has a parent and that parent has a physical device | ||
68 | * attached to it, that physical device should be the parent of the | ||
69 | * platform device we are about to create. | ||
70 | */ | ||
71 | pdevinfo.parent = NULL; | ||
72 | acpi_parent = adev->parent; | ||
73 | if (acpi_parent) { | ||
74 | struct acpi_device_physical_node *entry; | ||
75 | struct list_head *list; | ||
76 | |||
77 | mutex_lock(&acpi_parent->physical_node_lock); | ||
78 | list = &acpi_parent->physical_node_list; | ||
79 | if (!list_empty(list)) { | ||
80 | entry = list_first_entry(list, | ||
81 | struct acpi_device_physical_node, | ||
82 | node); | ||
83 | pdevinfo.parent = entry->dev; | ||
84 | } | ||
85 | mutex_unlock(&acpi_parent->physical_node_lock); | ||
86 | } | ||
87 | pdevinfo.name = dev_name(&adev->dev); | ||
88 | pdevinfo.id = -1; | ||
89 | pdevinfo.res = resources; | ||
90 | pdevinfo.num_res = count; | ||
91 | pdevinfo.acpi_node.handle = adev->handle; | ||
92 | pdev = platform_device_register_full(&pdevinfo); | ||
93 | if (IS_ERR(pdev)) { | ||
94 | dev_err(&adev->dev, "platform device creation failed: %ld\n", | ||
95 | PTR_ERR(pdev)); | ||
96 | pdev = NULL; | ||
97 | } else { | ||
98 | dev_dbg(&adev->dev, "created platform device %s\n", | ||
99 | dev_name(&pdev->dev)); | ||
100 | } | ||
101 | |||
102 | kfree(resources); | ||
103 | return pdev; | ||
104 | } | ||
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 7f1d40797e80..c8bc24bd1f72 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile | |||
@@ -161,3 +161,6 @@ acpi-y += \ | |||
161 | utxfinit.o \ | 161 | utxfinit.o \ |
162 | utxferror.o \ | 162 | utxferror.o \ |
163 | utxfmutex.o | 163 | utxfmutex.o |
164 | |||
165 | acpi-$(ACPI_FUTURE_USAGE) += uttrack.o utcache.o utclib.o | ||
166 | |||
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h index 5e8abb07724f..432a318c9ed1 100644 --- a/drivers/acpi/acpica/acdebug.h +++ b/drivers/acpi/acpica/acdebug.h | |||
@@ -44,17 +44,28 @@ | |||
44 | #ifndef __ACDEBUG_H__ | 44 | #ifndef __ACDEBUG_H__ |
45 | #define __ACDEBUG_H__ | 45 | #define __ACDEBUG_H__ |
46 | 46 | ||
47 | #define ACPI_DEBUG_BUFFER_SIZE 4196 | 47 | #define ACPI_DEBUG_BUFFER_SIZE 0x4000 /* 16K buffer for return objects */ |
48 | 48 | ||
49 | struct command_info { | 49 | struct acpi_db_command_info { |
50 | char *name; /* Command Name */ | 50 | char *name; /* Command Name */ |
51 | u8 min_args; /* Minimum arguments required */ | 51 | u8 min_args; /* Minimum arguments required */ |
52 | }; | 52 | }; |
53 | 53 | ||
54 | struct argument_info { | 54 | struct acpi_db_command_help { |
55 | u8 line_count; /* Number of help lines */ | ||
56 | char *invocation; /* Command Invocation */ | ||
57 | char *description; /* Command Description */ | ||
58 | }; | ||
59 | |||
60 | struct acpi_db_argument_info { | ||
55 | char *name; /* Argument Name */ | 61 | char *name; /* Argument Name */ |
56 | }; | 62 | }; |
57 | 63 | ||
64 | struct acpi_db_execute_walk { | ||
65 | u32 count; | ||
66 | u32 max_count; | ||
67 | }; | ||
68 | |||
58 | #define PARAM_LIST(pl) pl | 69 | #define PARAM_LIST(pl) pl |
59 | #define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose) | 70 | #define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose) |
60 | #define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ | 71 | #define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ |
@@ -77,59 +88,71 @@ acpi_db_single_step(struct acpi_walk_state *walk_state, | |||
77 | /* | 88 | /* |
78 | * dbcmds - debug commands and output routines | 89 | * dbcmds - debug commands and output routines |
79 | */ | 90 | */ |
80 | acpi_status acpi_db_disassemble_method(char *name); | 91 | struct acpi_namespace_node *acpi_db_convert_to_node(char *in_string); |
81 | 92 | ||
82 | void acpi_db_display_table_info(char *table_arg); | 93 | void acpi_db_display_table_info(char *table_arg); |
83 | 94 | ||
84 | void acpi_db_unload_acpi_table(char *table_arg, char *instance_arg); | 95 | void acpi_db_display_template(char *buffer_arg); |
85 | 96 | ||
86 | void | 97 | void acpi_db_unload_acpi_table(char *name); |
87 | acpi_db_set_method_breakpoint(char *location, | ||
88 | struct acpi_walk_state *walk_state, | ||
89 | union acpi_parse_object *op); | ||
90 | 98 | ||
91 | void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op); | 99 | void acpi_db_send_notify(char *name, u32 value); |
92 | 100 | ||
93 | void acpi_db_get_bus_info(void); | 101 | void acpi_db_display_interfaces(char *action_arg, char *interface_name_arg); |
94 | 102 | ||
95 | void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op); | 103 | acpi_status acpi_db_sleep(char *object_arg); |
96 | 104 | ||
97 | void acpi_db_dump_namespace(char *start_arg, char *depth_arg); | 105 | void acpi_db_display_locks(void); |
98 | 106 | ||
99 | void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg); | 107 | void acpi_db_display_resources(char *object_arg); |
100 | 108 | ||
101 | void acpi_db_send_notify(char *name, u32 value); | 109 | ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_display_gpes(void)) |
110 | |||
111 | void acpi_db_display_handlers(void); | ||
112 | |||
113 | ACPI_HW_DEPENDENT_RETURN_VOID(void | ||
114 | acpi_db_generate_gpe(char *gpe_arg, | ||
115 | char *block_arg)) | ||
116 | |||
117 | /* | ||
118 | * dbmethod - control method commands | ||
119 | */ | ||
120 | void | ||
121 | acpi_db_set_method_breakpoint(char *location, | ||
122 | struct acpi_walk_state *walk_state, | ||
123 | union acpi_parse_object *op); | ||
124 | |||
125 | void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op); | ||
102 | 126 | ||
103 | void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg); | 127 | void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg); |
104 | 128 | ||
105 | acpi_status | 129 | acpi_status acpi_db_disassemble_method(char *name); |
106 | acpi_db_display_objects(char *obj_type_arg, char *display_count_arg); | ||
107 | 130 | ||
108 | void acpi_db_display_interfaces(char *action_arg, char *interface_name_arg); | 131 | void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op); |
109 | 132 | ||
110 | acpi_status acpi_db_find_name_in_namespace(char *name_arg); | 133 | void acpi_db_batch_execute(char *count_arg); |
111 | 134 | ||
135 | /* | ||
136 | * dbnames - namespace commands | ||
137 | */ | ||
112 | void acpi_db_set_scope(char *name); | 138 | void acpi_db_set_scope(char *name); |
113 | 139 | ||
114 | ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_db_sleep(char *object_arg)) | 140 | void acpi_db_dump_namespace(char *start_arg, char *depth_arg); |
115 | 141 | ||
116 | void acpi_db_find_references(char *object_arg); | 142 | void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg); |
117 | 143 | ||
118 | void acpi_db_display_locks(void); | 144 | acpi_status acpi_db_find_name_in_namespace(char *name_arg); |
119 | 145 | ||
120 | void acpi_db_display_resources(char *object_arg); | 146 | void acpi_db_check_predefined_names(void); |
121 | 147 | ||
122 | ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_display_gpes(void)) | 148 | acpi_status |
149 | acpi_db_display_objects(char *obj_type_arg, char *display_count_arg); | ||
123 | 150 | ||
124 | void acpi_db_check_integrity(void); | 151 | void acpi_db_check_integrity(void); |
125 | 152 | ||
126 | ACPI_HW_DEPENDENT_RETURN_VOID(void | 153 | void acpi_db_find_references(char *object_arg); |
127 | acpi_db_generate_gpe(char *gpe_arg, | ||
128 | char *block_arg)) | ||
129 | |||
130 | void acpi_db_check_predefined_names(void); | ||
131 | 154 | ||
132 | void acpi_db_batch_execute(void); | 155 | void acpi_db_get_bus_info(void); |
133 | 156 | ||
134 | /* | 157 | /* |
135 | * dbdisply - debug display commands | 158 | * dbdisply - debug display commands |
@@ -161,7 +184,8 @@ acpi_db_display_argument_object(union acpi_operand_object *obj_desc, | |||
161 | /* | 184 | /* |
162 | * dbexec - debugger control method execution | 185 | * dbexec - debugger control method execution |
163 | */ | 186 | */ |
164 | void acpi_db_execute(char *name, char **args, u32 flags); | 187 | void |
188 | acpi_db_execute(char *name, char **args, acpi_object_type * types, u32 flags); | ||
165 | 189 | ||
166 | void | 190 | void |
167 | acpi_db_create_execution_threads(char *num_threads_arg, | 191 | acpi_db_create_execution_threads(char *num_threads_arg, |
@@ -175,7 +199,8 @@ u32 acpi_db_get_cache_info(struct acpi_memory_list *cache); | |||
175 | * dbfileio - Debugger file I/O commands | 199 | * dbfileio - Debugger file I/O commands |
176 | */ | 200 | */ |
177 | acpi_object_type | 201 | acpi_object_type |
178 | acpi_db_match_argument(char *user_argument, struct argument_info *arguments); | 202 | acpi_db_match_argument(char *user_argument, |
203 | struct acpi_db_argument_info *arguments); | ||
179 | 204 | ||
180 | void acpi_db_close_debug_file(void); | 205 | void acpi_db_close_debug_file(void); |
181 | 206 | ||
@@ -208,6 +233,11 @@ acpi_db_command_dispatch(char *input_buffer, | |||
208 | 233 | ||
209 | void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context); | 234 | void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context); |
210 | 235 | ||
236 | acpi_status acpi_db_user_commands(char prompt, union acpi_parse_object *op); | ||
237 | |||
238 | char *acpi_db_get_next_token(char *string, | ||
239 | char **next, acpi_object_type * return_type); | ||
240 | |||
211 | /* | 241 | /* |
212 | * dbstats - Generation and display of ACPI table statistics | 242 | * dbstats - Generation and display of ACPI table statistics |
213 | */ | 243 | */ |
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h index 5935ba6707e2..ed33ebcdaebe 100644 --- a/drivers/acpi/acpica/acdispat.h +++ b/drivers/acpi/acpica/acdispat.h | |||
@@ -309,10 +309,13 @@ acpi_ds_obj_stack_push(void *object, struct acpi_walk_state *walk_state); | |||
309 | acpi_status | 309 | acpi_status |
310 | acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state); | 310 | acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state); |
311 | 311 | ||
312 | struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, union acpi_parse_object | 312 | struct acpi_walk_state * acpi_ds_create_walk_state(acpi_owner_id owner_id, |
313 | *origin, union acpi_operand_object | 313 | union acpi_parse_object |
314 | *mth_desc, struct acpi_thread_state | 314 | *origin, |
315 | *thread); | 315 | union acpi_operand_object |
316 | *mth_desc, | ||
317 | struct acpi_thread_state | ||
318 | *thread); | ||
316 | 319 | ||
317 | acpi_status | 320 | acpi_status |
318 | acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state, | 321 | acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state, |
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h index c0a43b38c6a3..e975c6720448 100644 --- a/drivers/acpi/acpica/acevents.h +++ b/drivers/acpi/acpica/acevents.h | |||
@@ -84,9 +84,11 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info); | |||
84 | 84 | ||
85 | acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info); | 85 | acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info); |
86 | 86 | ||
87 | acpi_status acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info); | 87 | acpi_status |
88 | acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info); | ||
88 | 89 | ||
89 | acpi_status acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info); | 90 | acpi_status |
91 | acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info); | ||
90 | 92 | ||
91 | struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, | 93 | struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, |
92 | u32 gpe_number); | 94 | u32 gpe_number); |
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index ce79100fb5eb..64472e4ec329 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h | |||
@@ -70,7 +70,7 @@ | |||
70 | 70 | ||
71 | /* | 71 | /* |
72 | * Enable "slack" in the AML interpreter? Default is FALSE, and the | 72 | * Enable "slack" in the AML interpreter? Default is FALSE, and the |
73 | * interpreter strictly follows the ACPI specification. Setting to TRUE | 73 | * interpreter strictly follows the ACPI specification. Setting to TRUE |
74 | * allows the interpreter to ignore certain errors and/or bad AML constructs. | 74 | * allows the interpreter to ignore certain errors and/or bad AML constructs. |
75 | * | 75 | * |
76 | * Currently, these features are enabled by this flag: | 76 | * Currently, these features are enabled by this flag: |
@@ -155,26 +155,6 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_no_resource_disassembly, FALSE); | |||
155 | 155 | ||
156 | /***************************************************************************** | 156 | /***************************************************************************** |
157 | * | 157 | * |
158 | * Debug support | ||
159 | * | ||
160 | ****************************************************************************/ | ||
161 | |||
162 | /* Procedure nesting level for debug output */ | ||
163 | |||
164 | extern u32 acpi_gbl_nesting_level; | ||
165 | |||
166 | ACPI_EXTERN u32 acpi_gpe_count; | ||
167 | ACPI_EXTERN u32 acpi_fixed_event_count[ACPI_NUM_FIXED_EVENTS]; | ||
168 | |||
169 | /* Support for dynamic control method tracing mechanism */ | ||
170 | |||
171 | ACPI_EXTERN u32 acpi_gbl_original_dbg_level; | ||
172 | ACPI_EXTERN u32 acpi_gbl_original_dbg_layer; | ||
173 | ACPI_EXTERN u32 acpi_gbl_trace_dbg_level; | ||
174 | ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer; | ||
175 | |||
176 | /***************************************************************************** | ||
177 | * | ||
178 | * ACPI Table globals | 158 | * ACPI Table globals |
179 | * | 159 | * |
180 | ****************************************************************************/ | 160 | ****************************************************************************/ |
@@ -259,15 +239,6 @@ ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE reg | |||
259 | * | 239 | * |
260 | ****************************************************************************/ | 240 | ****************************************************************************/ |
261 | 241 | ||
262 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | ||
263 | |||
264 | /* Lists for tracking memory allocations */ | ||
265 | |||
266 | ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; | ||
267 | ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; | ||
268 | ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats; | ||
269 | #endif | ||
270 | |||
271 | /* Object caches */ | 242 | /* Object caches */ |
272 | 243 | ||
273 | ACPI_EXTERN acpi_cache_t *acpi_gbl_namespace_cache; | 244 | ACPI_EXTERN acpi_cache_t *acpi_gbl_namespace_cache; |
@@ -326,6 +297,15 @@ extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS]; | |||
326 | 297 | ||
327 | #endif | 298 | #endif |
328 | 299 | ||
300 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | ||
301 | |||
302 | /* Lists for tracking memory allocations */ | ||
303 | |||
304 | ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; | ||
305 | ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; | ||
306 | ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats; | ||
307 | #endif | ||
308 | |||
329 | /***************************************************************************** | 309 | /***************************************************************************** |
330 | * | 310 | * |
331 | * Namespace globals | 311 | * Namespace globals |
@@ -396,13 +376,35 @@ ACPI_EXTERN struct acpi_gpe_block_info | |||
396 | #if (!ACPI_REDUCED_HARDWARE) | 376 | #if (!ACPI_REDUCED_HARDWARE) |
397 | 377 | ||
398 | ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized; | 378 | ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized; |
399 | ACPI_EXTERN ACPI_GBL_EVENT_HANDLER acpi_gbl_global_event_handler; | 379 | ACPI_EXTERN acpi_gbl_event_handler acpi_gbl_global_event_handler; |
400 | ACPI_EXTERN void *acpi_gbl_global_event_handler_context; | 380 | ACPI_EXTERN void *acpi_gbl_global_event_handler_context; |
401 | 381 | ||
402 | #endif /* !ACPI_REDUCED_HARDWARE */ | 382 | #endif /* !ACPI_REDUCED_HARDWARE */ |
403 | 383 | ||
404 | /***************************************************************************** | 384 | /***************************************************************************** |
405 | * | 385 | * |
386 | * Debug support | ||
387 | * | ||
388 | ****************************************************************************/ | ||
389 | |||
390 | /* Procedure nesting level for debug output */ | ||
391 | |||
392 | extern u32 acpi_gbl_nesting_level; | ||
393 | |||
394 | /* Event counters */ | ||
395 | |||
396 | ACPI_EXTERN u32 acpi_gpe_count; | ||
397 | ACPI_EXTERN u32 acpi_fixed_event_count[ACPI_NUM_FIXED_EVENTS]; | ||
398 | |||
399 | /* Support for dynamic control method tracing mechanism */ | ||
400 | |||
401 | ACPI_EXTERN u32 acpi_gbl_original_dbg_level; | ||
402 | ACPI_EXTERN u32 acpi_gbl_original_dbg_layer; | ||
403 | ACPI_EXTERN u32 acpi_gbl_trace_dbg_level; | ||
404 | ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer; | ||
405 | |||
406 | /***************************************************************************** | ||
407 | * | ||
406 | * Debugger globals | 408 | * Debugger globals |
407 | * | 409 | * |
408 | ****************************************************************************/ | 410 | ****************************************************************************/ |
@@ -426,10 +428,11 @@ ACPI_EXTERN u8 acpi_gbl_db_opt_stats; | |||
426 | ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; | 428 | ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; |
427 | 429 | ||
428 | ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; | 430 | ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; |
429 | ACPI_EXTERN char acpi_gbl_db_line_buf[80]; | 431 | ACPI_EXTERN acpi_object_type acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]; |
430 | ACPI_EXTERN char acpi_gbl_db_parsed_buf[80]; | 432 | ACPI_EXTERN char acpi_gbl_db_line_buf[ACPI_DB_LINE_BUFFER_SIZE]; |
431 | ACPI_EXTERN char acpi_gbl_db_scope_buf[40]; | 433 | ACPI_EXTERN char acpi_gbl_db_parsed_buf[ACPI_DB_LINE_BUFFER_SIZE]; |
432 | ACPI_EXTERN char acpi_gbl_db_debug_filename[40]; | 434 | ACPI_EXTERN char acpi_gbl_db_scope_buf[80]; |
435 | ACPI_EXTERN char acpi_gbl_db_debug_filename[80]; | ||
433 | ACPI_EXTERN u8 acpi_gbl_db_output_to_file; | 436 | ACPI_EXTERN u8 acpi_gbl_db_output_to_file; |
434 | ACPI_EXTERN char *acpi_gbl_db_buffer; | 437 | ACPI_EXTERN char *acpi_gbl_db_buffer; |
435 | ACPI_EXTERN char *acpi_gbl_db_filename; | 438 | ACPI_EXTERN char *acpi_gbl_db_filename; |
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index c816ee675094..ff8bd0061e8b 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h | |||
@@ -262,10 +262,10 @@ struct acpi_create_field_info { | |||
262 | }; | 262 | }; |
263 | 263 | ||
264 | typedef | 264 | typedef |
265 | acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state); | 265 | acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state); |
266 | 266 | ||
267 | /* | 267 | /* |
268 | * Bitmapped ACPI types. Used internally only | 268 | * Bitmapped ACPI types. Used internally only |
269 | */ | 269 | */ |
270 | #define ACPI_BTYPE_ANY 0x00000000 | 270 | #define ACPI_BTYPE_ANY 0x00000000 |
271 | #define ACPI_BTYPE_INTEGER 0x00000001 | 271 | #define ACPI_BTYPE_INTEGER 0x00000001 |
@@ -486,8 +486,10 @@ struct acpi_gpe_device_info { | |||
486 | struct acpi_namespace_node *gpe_device; | 486 | struct acpi_namespace_node *gpe_device; |
487 | }; | 487 | }; |
488 | 488 | ||
489 | typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info *gpe_xrupt_info, | 489 | typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info * |
490 | struct acpi_gpe_block_info *gpe_block, void *context); | 490 | gpe_xrupt_info, |
491 | struct acpi_gpe_block_info *gpe_block, | ||
492 | void *context); | ||
491 | 493 | ||
492 | /* Information about each particular fixed event */ | 494 | /* Information about each particular fixed event */ |
493 | 495 | ||
@@ -582,7 +584,7 @@ struct acpi_pscope_state { | |||
582 | }; | 584 | }; |
583 | 585 | ||
584 | /* | 586 | /* |
585 | * Thread state - one per thread across multiple walk states. Multiple walk | 587 | * Thread state - one per thread across multiple walk states. Multiple walk |
586 | * states are created when there are nested control methods executing. | 588 | * states are created when there are nested control methods executing. |
587 | */ | 589 | */ |
588 | struct acpi_thread_state { | 590 | struct acpi_thread_state { |
@@ -645,7 +647,7 @@ union acpi_generic_state { | |||
645 | * | 647 | * |
646 | ****************************************************************************/ | 648 | ****************************************************************************/ |
647 | 649 | ||
648 | typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state); | 650 | typedef acpi_status(*acpi_execute_op) (struct acpi_walk_state * walk_state); |
649 | 651 | ||
650 | /* Address Range info block */ | 652 | /* Address Range info block */ |
651 | 653 | ||
@@ -1031,6 +1033,7 @@ struct acpi_db_method_info { | |||
1031 | acpi_handle method; | 1033 | acpi_handle method; |
1032 | acpi_handle main_thread_gate; | 1034 | acpi_handle main_thread_gate; |
1033 | acpi_handle thread_complete_gate; | 1035 | acpi_handle thread_complete_gate; |
1036 | acpi_handle info_gate; | ||
1034 | acpi_thread_id *threads; | 1037 | acpi_thread_id *threads; |
1035 | u32 num_threads; | 1038 | u32 num_threads; |
1036 | u32 num_created; | 1039 | u32 num_created; |
@@ -1041,6 +1044,7 @@ struct acpi_db_method_info { | |||
1041 | u32 num_loops; | 1044 | u32 num_loops; |
1042 | char pathname[128]; | 1045 | char pathname[128]; |
1043 | char **args; | 1046 | char **args; |
1047 | acpi_object_type *types; | ||
1044 | 1048 | ||
1045 | /* | 1049 | /* |
1046 | * Arguments to be passed to method for the command | 1050 | * Arguments to be passed to method for the command |
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index a7f68c47f517..5efad99f2169 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h | |||
@@ -84,29 +84,29 @@ | |||
84 | 84 | ||
85 | /* These macros reverse the bytes during the move, converting little-endian to big endian */ | 85 | /* These macros reverse the bytes during the move, converting little-endian to big endian */ |
86 | 86 | ||
87 | /* Big Endian <== Little Endian */ | 87 | /* Big Endian <== Little Endian */ |
88 | /* Hi...Lo Lo...Hi */ | 88 | /* Hi...Lo Lo...Hi */ |
89 | /* 16-bit source, 16/32/64 destination */ | 89 | /* 16-bit source, 16/32/64 destination */ |
90 | 90 | ||
91 | #define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\ | 91 | #define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\ |
92 | (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];} | 92 | (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];} |
93 | 93 | ||
94 | #define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d))=0;\ | 94 | #define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d))=0;\ |
95 | ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ | 95 | ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ |
96 | ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} | 96 | ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} |
97 | 97 | ||
98 | #define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\ | 98 | #define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\ |
99 | ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\ | 99 | ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\ |
100 | ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];} | 100 | ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];} |
101 | 101 | ||
102 | /* 32-bit source, 16/32/64 destination */ | 102 | /* 32-bit source, 16/32/64 destination */ |
103 | 103 | ||
104 | #define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ | 104 | #define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ |
105 | 105 | ||
106 | #define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\ | 106 | #define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\ |
107 | (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\ | 107 | (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\ |
108 | (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ | 108 | (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ |
109 | (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} | 109 | (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} |
110 | 110 | ||
111 | #define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\ | 111 | #define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\ |
112 | ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\ | 112 | ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\ |
@@ -196,24 +196,12 @@ | |||
196 | #endif | 196 | #endif |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | /* Macros based on machine integer width */ | ||
200 | |||
201 | #if ACPI_MACHINE_WIDTH == 32 | ||
202 | #define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_32_TO_16(d, s) | ||
203 | |||
204 | #elif ACPI_MACHINE_WIDTH == 64 | ||
205 | #define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_64_TO_16(d, s) | ||
206 | |||
207 | #else | ||
208 | #error unknown ACPI_MACHINE_WIDTH | ||
209 | #endif | ||
210 | |||
211 | /* | 199 | /* |
212 | * Fast power-of-two math macros for non-optimized compilers | 200 | * Fast power-of-two math macros for non-optimized compilers |
213 | */ | 201 | */ |
214 | #define _ACPI_DIV(value, power_of2) ((u32) ((value) >> (power_of2))) | 202 | #define _ACPI_DIV(value, power_of2) ((u32) ((value) >> (power_of2))) |
215 | #define _ACPI_MUL(value, power_of2) ((u32) ((value) << (power_of2))) | 203 | #define _ACPI_MUL(value, power_of2) ((u32) ((value) << (power_of2))) |
216 | #define _ACPI_MOD(value, divisor) ((u32) ((value) & ((divisor) -1))) | 204 | #define _ACPI_MOD(value, divisor) ((u32) ((value) & ((divisor) -1))) |
217 | 205 | ||
218 | #define ACPI_DIV_2(a) _ACPI_DIV(a, 1) | 206 | #define ACPI_DIV_2(a) _ACPI_DIV(a, 1) |
219 | #define ACPI_MUL_2(a) _ACPI_MUL(a, 1) | 207 | #define ACPI_MUL_2(a) _ACPI_MUL(a, 1) |
@@ -238,12 +226,12 @@ | |||
238 | /* | 226 | /* |
239 | * Rounding macros (Power of two boundaries only) | 227 | * Rounding macros (Power of two boundaries only) |
240 | */ | 228 | */ |
241 | #define ACPI_ROUND_DOWN(value, boundary) (((acpi_size)(value)) & \ | 229 | #define ACPI_ROUND_DOWN(value, boundary) (((acpi_size)(value)) & \ |
242 | (~(((acpi_size) boundary)-1))) | 230 | (~(((acpi_size) boundary)-1))) |
243 | 231 | ||
244 | #define ACPI_ROUND_UP(value, boundary) ((((acpi_size)(value)) + \ | 232 | #define ACPI_ROUND_UP(value, boundary) ((((acpi_size)(value)) + \ |
245 | (((acpi_size) boundary)-1)) & \ | 233 | (((acpi_size) boundary)-1)) & \ |
246 | (~(((acpi_size) boundary)-1))) | 234 | (~(((acpi_size) boundary)-1))) |
247 | 235 | ||
248 | /* Note: sizeof(acpi_size) evaluates to either 4 or 8 (32- vs 64-bit mode) */ | 236 | /* Note: sizeof(acpi_size) evaluates to either 4 or 8 (32- vs 64-bit mode) */ |
249 | 237 | ||
@@ -264,7 +252,7 @@ | |||
264 | 252 | ||
265 | #define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary)) | 253 | #define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary)) |
266 | 254 | ||
267 | #define ACPI_IS_MISALIGNED(value) (((acpi_size) value) & (sizeof(acpi_size)-1)) | 255 | #define ACPI_IS_MISALIGNED(value) (((acpi_size) value) & (sizeof(acpi_size)-1)) |
268 | 256 | ||
269 | /* | 257 | /* |
270 | * Bitmask creation | 258 | * Bitmask creation |
@@ -355,7 +343,6 @@ | |||
355 | * Ascii error messages can be configured out | 343 | * Ascii error messages can be configured out |
356 | */ | 344 | */ |
357 | #ifndef ACPI_NO_ERROR_MESSAGES | 345 | #ifndef ACPI_NO_ERROR_MESSAGES |
358 | |||
359 | /* | 346 | /* |
360 | * Error reporting. Callers module and line number are inserted by AE_INFO, | 347 | * Error reporting. Callers module and line number are inserted by AE_INFO, |
361 | * the plist contains a set of parens to allow variable-length lists. | 348 | * the plist contains a set of parens to allow variable-length lists. |
@@ -375,18 +362,15 @@ | |||
375 | #define ACPI_WARN_PREDEFINED(plist) | 362 | #define ACPI_WARN_PREDEFINED(plist) |
376 | #define ACPI_INFO_PREDEFINED(plist) | 363 | #define ACPI_INFO_PREDEFINED(plist) |
377 | 364 | ||
378 | #endif /* ACPI_NO_ERROR_MESSAGES */ | 365 | #endif /* ACPI_NO_ERROR_MESSAGES */ |
379 | 366 | ||
380 | /* | 367 | /* |
381 | * Debug macros that are conditionally compiled | 368 | * Debug macros that are conditionally compiled |
382 | */ | 369 | */ |
383 | #ifdef ACPI_DEBUG_OUTPUT | 370 | #ifdef ACPI_DEBUG_OUTPUT |
384 | |||
385 | /* | 371 | /* |
386 | * Function entry tracing | 372 | * Function entry tracing |
387 | */ | 373 | */ |
388 | #ifdef CONFIG_ACPI_DEBUG_FUNC_TRACE | ||
389 | |||
390 | #define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ | 374 | #define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ |
391 | acpi_ut_trace(ACPI_DEBUG_PARAMETERS) | 375 | acpi_ut_trace(ACPI_DEBUG_PARAMETERS) |
392 | #define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \ | 376 | #define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \ |
@@ -464,45 +448,19 @@ | |||
464 | 448 | ||
465 | #endif /* ACPI_SIMPLE_RETURN_MACROS */ | 449 | #endif /* ACPI_SIMPLE_RETURN_MACROS */ |
466 | 450 | ||
467 | #else /* !CONFIG_ACPI_DEBUG_FUNC_TRACE */ | ||
468 | |||
469 | #define ACPI_FUNCTION_TRACE(a) | ||
470 | #define ACPI_FUNCTION_TRACE_PTR(a,b) | ||
471 | #define ACPI_FUNCTION_TRACE_U32(a,b) | ||
472 | #define ACPI_FUNCTION_TRACE_STR(a,b) | ||
473 | #define ACPI_FUNCTION_EXIT | ||
474 | #define ACPI_FUNCTION_STATUS_EXIT(s) | ||
475 | #define ACPI_FUNCTION_VALUE_EXIT(s) | ||
476 | #define ACPI_FUNCTION_TRACE(a) | ||
477 | #define ACPI_FUNCTION_ENTRY() | ||
478 | |||
479 | #define return_VOID return | ||
480 | #define return_ACPI_STATUS(s) return(s) | ||
481 | #define return_VALUE(s) return(s) | ||
482 | #define return_UINT8(s) return(s) | ||
483 | #define return_UINT32(s) return(s) | ||
484 | #define return_PTR(s) return(s) | ||
485 | |||
486 | #endif /* CONFIG_ACPI_DEBUG_FUNC_TRACE */ | ||
487 | |||
488 | /* Conditional execution */ | 451 | /* Conditional execution */ |
489 | 452 | ||
490 | #define ACPI_DEBUG_EXEC(a) a | 453 | #define ACPI_DEBUG_EXEC(a) a |
491 | #define ACPI_NORMAL_EXEC(a) | ||
492 | |||
493 | #define ACPI_DEBUG_DEFINE(a) a; | ||
494 | #define ACPI_DEBUG_ONLY_MEMBERS(a) a; | 454 | #define ACPI_DEBUG_ONLY_MEMBERS(a) a; |
495 | #define _VERBOSE_STRUCTURES | 455 | #define _VERBOSE_STRUCTURES |
496 | 456 | ||
497 | /* Stack and buffer dumping */ | 457 | /* Various object display routines for debug */ |
498 | 458 | ||
499 | #define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0) | 459 | #define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0) |
500 | #define ACPI_DUMP_OPERANDS(a, b, c) acpi_ex_dump_operands(a, b, c) | 460 | #define ACPI_DUMP_OPERANDS(a, b ,c) acpi_ex_dump_operands(a, b, c) |
501 | |||
502 | #define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b) | 461 | #define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b) |
503 | #define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d) | 462 | #define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d) |
504 | #define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a) | 463 | #define ACPI_DUMP_BUFFER(a, b) acpi_ut_debug_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) |
505 | #define ACPI_DUMP_BUFFER(a, b) acpi_ut_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) | ||
506 | 464 | ||
507 | #else | 465 | #else |
508 | /* | 466 | /* |
@@ -510,25 +468,23 @@ | |||
510 | * leaving no executable debug code! | 468 | * leaving no executable debug code! |
511 | */ | 469 | */ |
512 | #define ACPI_DEBUG_EXEC(a) | 470 | #define ACPI_DEBUG_EXEC(a) |
513 | #define ACPI_NORMAL_EXEC(a) a; | 471 | #define ACPI_DEBUG_ONLY_MEMBERS(a) |
514 | 472 | #define ACPI_FUNCTION_TRACE(a) | |
515 | #define ACPI_DEBUG_DEFINE(a) do { } while(0) | 473 | #define ACPI_FUNCTION_TRACE_PTR(a, b) |
516 | #define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while(0) | 474 | #define ACPI_FUNCTION_TRACE_U32(a, b) |
517 | #define ACPI_FUNCTION_TRACE(a) do { } while(0) | 475 | #define ACPI_FUNCTION_TRACE_STR(a, b) |
518 | #define ACPI_FUNCTION_TRACE_PTR(a, b) do { } while(0) | 476 | #define ACPI_FUNCTION_EXIT |
519 | #define ACPI_FUNCTION_TRACE_U32(a, b) do { } while(0) | 477 | #define ACPI_FUNCTION_STATUS_EXIT(s) |
520 | #define ACPI_FUNCTION_TRACE_STR(a, b) do { } while(0) | 478 | #define ACPI_FUNCTION_VALUE_EXIT(s) |
521 | #define ACPI_FUNCTION_EXIT do { } while(0) | 479 | #define ACPI_FUNCTION_ENTRY() |
522 | #define ACPI_FUNCTION_STATUS_EXIT(s) do { } while(0) | 480 | #define ACPI_DUMP_STACK_ENTRY(a) |
523 | #define ACPI_FUNCTION_VALUE_EXIT(s) do { } while(0) | 481 | #define ACPI_DUMP_OPERANDS(a, b, c) |
524 | #define ACPI_FUNCTION_ENTRY() do { } while(0) | 482 | #define ACPI_DUMP_ENTRY(a, b) |
525 | #define ACPI_DUMP_STACK_ENTRY(a) do { } while(0) | 483 | #define ACPI_DUMP_TABLES(a, b) |
526 | #define ACPI_DUMP_OPERANDS(a, b, c) do { } while(0) | 484 | #define ACPI_DUMP_PATHNAME(a, b, c, d) |
527 | #define ACPI_DUMP_ENTRY(a, b) do { } while(0) | 485 | #define ACPI_DUMP_BUFFER(a, b) |
528 | #define ACPI_DUMP_TABLES(a, b) do { } while(0) | 486 | #define ACPI_DEBUG_PRINT(pl) |
529 | #define ACPI_DUMP_PATHNAME(a, b, c, d) do { } while(0) | 487 | #define ACPI_DEBUG_PRINT_RAW(pl) |
530 | #define ACPI_DUMP_RESOURCE_LIST(a) do { } while(0) | ||
531 | #define ACPI_DUMP_BUFFER(a, b) do { } while(0) | ||
532 | 488 | ||
533 | #define return_VOID return | 489 | #define return_VOID return |
534 | #define return_ACPI_STATUS(s) return(s) | 490 | #define return_ACPI_STATUS(s) return(s) |
@@ -556,18 +512,6 @@ | |||
556 | #define ACPI_DEBUGGER_EXEC(a) | 512 | #define ACPI_DEBUGGER_EXEC(a) |
557 | #endif | 513 | #endif |
558 | 514 | ||
559 | #ifdef ACPI_DEBUG_OUTPUT | ||
560 | /* | ||
561 | * 1) Set name to blanks | ||
562 | * 2) Copy the object name | ||
563 | */ | ||
564 | #define ACPI_ADD_OBJECT_NAME(a,b) ACPI_MEMSET (a->common.name, ' ', sizeof (a->common.name));\ | ||
565 | ACPI_STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name)) | ||
566 | #else | ||
567 | |||
568 | #define ACPI_ADD_OBJECT_NAME(a,b) | ||
569 | #endif | ||
570 | |||
571 | /* | 515 | /* |
572 | * Memory allocation tracking (DEBUG ONLY) | 516 | * Memory allocation tracking (DEBUG ONLY) |
573 | */ | 517 | */ |
@@ -578,13 +522,13 @@ | |||
578 | /* Memory allocation */ | 522 | /* Memory allocation */ |
579 | 523 | ||
580 | #ifndef ACPI_ALLOCATE | 524 | #ifndef ACPI_ALLOCATE |
581 | #define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a), ACPI_MEM_PARAMETERS) | 525 | #define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size) (a), ACPI_MEM_PARAMETERS) |
582 | #endif | 526 | #endif |
583 | #ifndef ACPI_ALLOCATE_ZEROED | 527 | #ifndef ACPI_ALLOCATE_ZEROED |
584 | #define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size)(a), ACPI_MEM_PARAMETERS) | 528 | #define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size) (a), ACPI_MEM_PARAMETERS) |
585 | #endif | 529 | #endif |
586 | #ifndef ACPI_FREE | 530 | #ifndef ACPI_FREE |
587 | #define ACPI_FREE(a) acpio_os_free(a) | 531 | #define ACPI_FREE(a) acpi_os_free(a) |
588 | #endif | 532 | #endif |
589 | #define ACPI_MEM_TRACKING(a) | 533 | #define ACPI_MEM_TRACKING(a) |
590 | 534 | ||
@@ -592,16 +536,25 @@ | |||
592 | 536 | ||
593 | /* Memory allocation */ | 537 | /* Memory allocation */ |
594 | 538 | ||
595 | #define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS) | 539 | #define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size) (a), ACPI_MEM_PARAMETERS) |
596 | #define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS) | 540 | #define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track((acpi_size) (a), ACPI_MEM_PARAMETERS) |
597 | #define ACPI_FREE(a) acpi_ut_free_and_track(a, ACPI_MEM_PARAMETERS) | 541 | #define ACPI_FREE(a) acpi_ut_free_and_track(a, ACPI_MEM_PARAMETERS) |
598 | #define ACPI_MEM_TRACKING(a) a | 542 | #define ACPI_MEM_TRACKING(a) a |
599 | 543 | ||
600 | #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ | 544 | #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ |
601 | 545 | ||
602 | /* Preemption point */ | 546 | /* |
603 | #ifndef ACPI_PREEMPTION_POINT | 547 | * Macros used for ACPICA utilities only |
604 | #define ACPI_PREEMPTION_POINT() /* no preemption */ | 548 | */ |
605 | #endif | 549 | |
550 | /* Generate a UUID */ | ||
551 | |||
552 | #define ACPI_INIT_UUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ | ||
553 | (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \ | ||
554 | (b) & 0xFF, ((b) >> 8) & 0xFF, \ | ||
555 | (c) & 0xFF, ((c) >> 8) & 0xFF, \ | ||
556 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) | ||
557 | |||
558 | #define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) | ||
606 | 559 | ||
607 | #endif /* ACMACROS_H */ | 560 | #endif /* ACMACROS_H */ |
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h index 364a1303fb8f..24eb9eac9514 100644 --- a/drivers/acpi/acpica/acobject.h +++ b/drivers/acpi/acpica/acobject.h | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Name: acobject.h - Definition of union acpi_operand_object (Internal object only) | 3 | * Name: acobject.h - Definition of union acpi_operand_object (Internal object only) |
@@ -179,7 +178,7 @@ struct acpi_object_method { | |||
179 | union acpi_operand_object *mutex; | 178 | union acpi_operand_object *mutex; |
180 | u8 *aml_start; | 179 | u8 *aml_start; |
181 | union { | 180 | union { |
182 | ACPI_INTERNAL_METHOD implementation; | 181 | acpi_internal_method implementation; |
183 | union acpi_operand_object *handler; | 182 | union acpi_operand_object *handler; |
184 | } dispatch; | 183 | } dispatch; |
185 | 184 | ||
@@ -198,7 +197,7 @@ struct acpi_object_method { | |||
198 | 197 | ||
199 | /****************************************************************************** | 198 | /****************************************************************************** |
200 | * | 199 | * |
201 | * Objects that can be notified. All share a common notify_info area. | 200 | * Objects that can be notified. All share a common notify_info area. |
202 | * | 201 | * |
203 | *****************************************************************************/ | 202 | *****************************************************************************/ |
204 | 203 | ||
@@ -235,7 +234,7 @@ ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO}; | |||
235 | 234 | ||
236 | /****************************************************************************** | 235 | /****************************************************************************** |
237 | * | 236 | * |
238 | * Fields. All share a common header/info field. | 237 | * Fields. All share a common header/info field. |
239 | * | 238 | * |
240 | *****************************************************************************/ | 239 | *****************************************************************************/ |
241 | 240 | ||
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h index 9440d053fbb3..d786a5128b78 100644 --- a/drivers/acpi/acpica/acopcode.h +++ b/drivers/acpi/acpica/acopcode.h | |||
@@ -54,7 +54,7 @@ | |||
54 | #define _UNK 0x6B | 54 | #define _UNK 0x6B |
55 | 55 | ||
56 | /* | 56 | /* |
57 | * Reserved ASCII characters. Do not use any of these for | 57 | * Reserved ASCII characters. Do not use any of these for |
58 | * internal opcodes, since they are used to differentiate | 58 | * internal opcodes, since they are used to differentiate |
59 | * name strings from AML opcodes | 59 | * name strings from AML opcodes |
60 | */ | 60 | */ |
@@ -63,7 +63,7 @@ | |||
63 | #define _PFX 0x6D | 63 | #define _PFX 0x6D |
64 | 64 | ||
65 | /* | 65 | /* |
66 | * All AML opcodes and the parse-time arguments for each. Used by the AML | 66 | * All AML opcodes and the parse-time arguments for each. Used by the AML |
67 | * parser Each list is compressed into a 32-bit number and stored in the | 67 | * parser Each list is compressed into a 32-bit number and stored in the |
68 | * master opcode table (in psopcode.c). | 68 | * master opcode table (in psopcode.c). |
69 | */ | 69 | */ |
@@ -193,7 +193,7 @@ | |||
193 | #define ARGP_ZERO_OP ARG_NONE | 193 | #define ARGP_ZERO_OP ARG_NONE |
194 | 194 | ||
195 | /* | 195 | /* |
196 | * All AML opcodes and the runtime arguments for each. Used by the AML | 196 | * All AML opcodes and the runtime arguments for each. Used by the AML |
197 | * interpreter Each list is compressed into a 32-bit number and stored | 197 | * interpreter Each list is compressed into a 32-bit number and stored |
198 | * in the master opcode table (in psopcode.c). | 198 | * in the master opcode table (in psopcode.c). |
199 | * | 199 | * |
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h index b725d780d34d..eefcf47a61a0 100644 --- a/drivers/acpi/acpica/acparser.h +++ b/drivers/acpi/acpica/acparser.h | |||
@@ -150,8 +150,7 @@ u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state); | |||
150 | 150 | ||
151 | void | 151 | void |
152 | acpi_ps_pop_scope(struct acpi_parse_state *parser_state, | 152 | acpi_ps_pop_scope(struct acpi_parse_state *parser_state, |
153 | union acpi_parse_object **op, | 153 | union acpi_parse_object **op, u32 *arg_list, u32 *arg_count); |
154 | u32 * arg_list, u32 * arg_count); | ||
155 | 154 | ||
156 | acpi_status | 155 | acpi_status |
157 | acpi_ps_push_scope(struct acpi_parse_state *parser_state, | 156 | acpi_ps_push_scope(struct acpi_parse_state *parser_state, |
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h index 3080c017f5ba..9dfa1c83bd4e 100644 --- a/drivers/acpi/acpica/acpredef.h +++ b/drivers/acpi/acpica/acpredef.h | |||
@@ -150,8 +150,7 @@ enum acpi_return_package_types { | |||
150 | * is saved here (rather than in a separate table) in order to minimize the | 150 | * is saved here (rather than in a separate table) in order to minimize the |
151 | * overall size of the stored data. | 151 | * overall size of the stored data. |
152 | */ | 152 | */ |
153 | static const union acpi_predefined_info predefined_names[] = | 153 | static const union acpi_predefined_info predefined_names[] = { |
154 | { | ||
155 | {{"_AC0", 0, ACPI_RTYPE_INTEGER}}, | 154 | {{"_AC0", 0, ACPI_RTYPE_INTEGER}}, |
156 | {{"_AC1", 0, ACPI_RTYPE_INTEGER}}, | 155 | {{"_AC1", 0, ACPI_RTYPE_INTEGER}}, |
157 | {{"_AC2", 0, ACPI_RTYPE_INTEGER}}, | 156 | {{"_AC2", 0, ACPI_RTYPE_INTEGER}}, |
@@ -538,7 +537,8 @@ static const union acpi_predefined_info predefined_names[] = | |||
538 | 537 | ||
539 | /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ | 538 | /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ |
540 | 539 | ||
541 | {{"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}}, | 540 | {{"_WAK", 1, |
541 | ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}}, | ||
542 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */ | 542 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */ |
543 | 543 | ||
544 | /* _WDG/_WED are MS extensions defined by "Windows Instrumentation" */ | 544 | /* _WDG/_WED are MS extensions defined by "Windows Instrumentation" */ |
@@ -551,11 +551,12 @@ static const union acpi_predefined_info predefined_names[] = | |||
551 | }; | 551 | }; |
552 | 552 | ||
553 | #if 0 | 553 | #if 0 |
554 | |||
554 | /* This is an internally implemented control method, no need to check */ | 555 | /* This is an internally implemented control method, no need to check */ |
555 | {{"_OSI", 1, ACPI_RTYPE_INTEGER}}, | 556 | { { |
557 | "_OSI", 1, ACPI_RTYPE_INTEGER}}, | ||
556 | 558 | ||
557 | /* TBD: */ | 559 | /* TBD: */ |
558 | |||
559 | _PRT - currently ignore reversed entries. attempt to fix here? | 560 | _PRT - currently ignore reversed entries. attempt to fix here? |
560 | think about possibly fixing package elements like _BIF, etc. | 561 | think about possibly fixing package elements like _BIF, etc. |
561 | #endif | 562 | #endif |
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h index f196e2c9a71f..937e66c65d1e 100644 --- a/drivers/acpi/acpica/acstruct.h +++ b/drivers/acpi/acpica/acstruct.h | |||
@@ -53,7 +53,7 @@ | |||
53 | ****************************************************************************/ | 53 | ****************************************************************************/ |
54 | 54 | ||
55 | /* | 55 | /* |
56 | * Walk state - current state of a parse tree walk. Used for both a leisurely | 56 | * Walk state - current state of a parse tree walk. Used for both a leisurely |
57 | * stroll through the tree (for whatever reason), and for control method | 57 | * stroll through the tree (for whatever reason), and for control method |
58 | * execution. | 58 | * execution. |
59 | */ | 59 | */ |
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 5035327ebccc..b0f5f92b674a 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h | |||
@@ -69,6 +69,22 @@ extern const char *acpi_gbl_siz_decode[]; | |||
69 | extern const char *acpi_gbl_trs_decode[]; | 69 | extern const char *acpi_gbl_trs_decode[]; |
70 | extern const char *acpi_gbl_ttp_decode[]; | 70 | extern const char *acpi_gbl_ttp_decode[]; |
71 | extern const char *acpi_gbl_typ_decode[]; | 71 | extern const char *acpi_gbl_typ_decode[]; |
72 | extern const char *acpi_gbl_ppc_decode[]; | ||
73 | extern const char *acpi_gbl_ior_decode[]; | ||
74 | extern const char *acpi_gbl_dts_decode[]; | ||
75 | extern const char *acpi_gbl_ct_decode[]; | ||
76 | extern const char *acpi_gbl_sbt_decode[]; | ||
77 | extern const char *acpi_gbl_am_decode[]; | ||
78 | extern const char *acpi_gbl_sm_decode[]; | ||
79 | extern const char *acpi_gbl_wm_decode[]; | ||
80 | extern const char *acpi_gbl_cph_decode[]; | ||
81 | extern const char *acpi_gbl_cpo_decode[]; | ||
82 | extern const char *acpi_gbl_dp_decode[]; | ||
83 | extern const char *acpi_gbl_ed_decode[]; | ||
84 | extern const char *acpi_gbl_bpb_decode[]; | ||
85 | extern const char *acpi_gbl_sb_decode[]; | ||
86 | extern const char *acpi_gbl_fc_decode[]; | ||
87 | extern const char *acpi_gbl_pt_decode[]; | ||
72 | #endif | 88 | #endif |
73 | 89 | ||
74 | /* Types for Resource descriptor entries */ | 90 | /* Types for Resource descriptor entries */ |
@@ -79,14 +95,14 @@ extern const char *acpi_gbl_typ_decode[]; | |||
79 | #define ACPI_SMALL_VARIABLE_LENGTH 3 | 95 | #define ACPI_SMALL_VARIABLE_LENGTH 3 |
80 | 96 | ||
81 | typedef | 97 | typedef |
82 | acpi_status(*acpi_walk_aml_callback) (u8 * aml, | 98 | acpi_status(*acpi_walk_aml_callback) (u8 *aml, |
83 | u32 length, | 99 | u32 length, |
84 | u32 offset, | 100 | u32 offset, |
85 | u8 resource_index, void **context); | 101 | u8 resource_index, void **context); |
86 | 102 | ||
87 | typedef | 103 | typedef |
88 | acpi_status(*acpi_pkg_callback) (u8 object_type, | 104 | acpi_status(*acpi_pkg_callback) (u8 object_type, |
89 | union acpi_operand_object * source_object, | 105 | union acpi_operand_object *source_object, |
90 | union acpi_generic_state * state, | 106 | union acpi_generic_state * state, |
91 | void *context); | 107 | void *context); |
92 | 108 | ||
@@ -202,7 +218,9 @@ extern const u8 _acpi_ctype[]; | |||
202 | #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) | 218 | #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) |
203 | #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) | 219 | #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) |
204 | 220 | ||
205 | #endif /* ACPI_USE_SYSTEM_CLIBRARY */ | 221 | #endif /* !ACPI_USE_SYSTEM_CLIBRARY */ |
222 | |||
223 | #define ACPI_IS_ASCII(c) ((c) < 0x80) | ||
206 | 224 | ||
207 | /* | 225 | /* |
208 | * utcopy - Object construction and conversion interfaces | 226 | * utcopy - Object construction and conversion interfaces |
@@ -210,11 +228,11 @@ extern const u8 _acpi_ctype[]; | |||
210 | acpi_status | 228 | acpi_status |
211 | acpi_ut_build_simple_object(union acpi_operand_object *obj, | 229 | acpi_ut_build_simple_object(union acpi_operand_object *obj, |
212 | union acpi_object *user_obj, | 230 | union acpi_object *user_obj, |
213 | u8 * data_space, u32 * buffer_space_used); | 231 | u8 *data_space, u32 *buffer_space_used); |
214 | 232 | ||
215 | acpi_status | 233 | acpi_status |
216 | acpi_ut_build_package_object(union acpi_operand_object *obj, | 234 | acpi_ut_build_package_object(union acpi_operand_object *obj, |
217 | u8 * buffer, u32 * space_used); | 235 | u8 *buffer, u32 *space_used); |
218 | 236 | ||
219 | acpi_status | 237 | acpi_status |
220 | acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *obj, | 238 | acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *obj, |
@@ -287,9 +305,10 @@ acpi_ut_ptr_exit(u32 line_number, | |||
287 | const char *function_name, | 305 | const char *function_name, |
288 | const char *module_name, u32 component_id, u8 *ptr); | 306 | const char *module_name, u32 component_id, u8 *ptr); |
289 | 307 | ||
290 | void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id); | 308 | void |
309 | acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id); | ||
291 | 310 | ||
292 | void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display); | 311 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 offset); |
293 | 312 | ||
294 | void acpi_ut_report_error(char *module_name, u32 line_number); | 313 | void acpi_ut_report_error(char *module_name, u32 line_number); |
295 | 314 | ||
@@ -337,15 +356,19 @@ acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node, | |||
337 | */ | 356 | */ |
338 | acpi_status | 357 | acpi_status |
339 | acpi_ut_execute_HID(struct acpi_namespace_node *device_node, | 358 | acpi_ut_execute_HID(struct acpi_namespace_node *device_node, |
340 | struct acpica_device_id **return_id); | 359 | struct acpi_pnp_device_id ** return_id); |
341 | 360 | ||
342 | acpi_status | 361 | acpi_status |
343 | acpi_ut_execute_UID(struct acpi_namespace_node *device_node, | 362 | acpi_ut_execute_UID(struct acpi_namespace_node *device_node, |
344 | struct acpica_device_id **return_id); | 363 | struct acpi_pnp_device_id ** return_id); |
364 | |||
365 | acpi_status | ||
366 | acpi_ut_execute_SUB(struct acpi_namespace_node *device_node, | ||
367 | struct acpi_pnp_device_id **return_id); | ||
345 | 368 | ||
346 | acpi_status | 369 | acpi_status |
347 | acpi_ut_execute_CID(struct acpi_namespace_node *device_node, | 370 | acpi_ut_execute_CID(struct acpi_namespace_node *device_node, |
348 | struct acpica_device_id_list **return_cid_list); | 371 | struct acpi_pnp_device_id_list ** return_cid_list); |
349 | 372 | ||
350 | /* | 373 | /* |
351 | * utlock - reader/writer locks | 374 | * utlock - reader/writer locks |
@@ -479,15 +502,19 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object, | |||
479 | 502 | ||
480 | void acpi_ut_strupr(char *src_string); | 503 | void acpi_ut_strupr(char *src_string); |
481 | 504 | ||
505 | void acpi_ut_strlwr(char *src_string); | ||
506 | |||
507 | int acpi_ut_stricmp(char *string1, char *string2); | ||
508 | |||
482 | void acpi_ut_print_string(char *string, u8 max_length); | 509 | void acpi_ut_print_string(char *string, u8 max_length); |
483 | 510 | ||
484 | u8 acpi_ut_valid_acpi_name(u32 name); | 511 | u8 acpi_ut_valid_acpi_name(u32 name); |
485 | 512 | ||
486 | acpi_name acpi_ut_repair_name(char *name); | 513 | void acpi_ut_repair_name(char *name); |
487 | 514 | ||
488 | u8 acpi_ut_valid_acpi_char(char character, u32 position); | 515 | u8 acpi_ut_valid_acpi_char(char character, u32 position); |
489 | 516 | ||
490 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer); | 517 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer); |
491 | 518 | ||
492 | /* Values for Base above (16=Hex, 10=Decimal) */ | 519 | /* Values for Base above (16=Hex, 10=Decimal) */ |
493 | 520 | ||
@@ -508,12 +535,12 @@ acpi_ut_display_init_pathname(u8 type, | |||
508 | * utresrc | 535 | * utresrc |
509 | */ | 536 | */ |
510 | acpi_status | 537 | acpi_status |
511 | acpi_ut_walk_aml_resources(u8 * aml, | 538 | acpi_ut_walk_aml_resources(u8 *aml, |
512 | acpi_size aml_length, | 539 | acpi_size aml_length, |
513 | acpi_walk_aml_callback user_function, | 540 | acpi_walk_aml_callback user_function, |
514 | void **context); | 541 | void **context); |
515 | 542 | ||
516 | acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index); | 543 | acpi_status acpi_ut_validate_resource(void *aml, u8 *return_index); |
517 | 544 | ||
518 | u32 acpi_ut_get_descriptor_length(void *aml); | 545 | u32 acpi_ut_get_descriptor_length(void *aml); |
519 | 546 | ||
@@ -524,8 +551,7 @@ u8 acpi_ut_get_resource_header_length(void *aml); | |||
524 | u8 acpi_ut_get_resource_type(void *aml); | 551 | u8 acpi_ut_get_resource_type(void *aml); |
525 | 552 | ||
526 | acpi_status | 553 | acpi_status |
527 | acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, | 554 | acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag); |
528 | u8 ** end_tag); | ||
529 | 555 | ||
530 | /* | 556 | /* |
531 | * utmutex - mutex support | 557 | * utmutex - mutex support |
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h index af4947956ec2..968449685e06 100644 --- a/drivers/acpi/acpica/amlresrc.h +++ b/drivers/acpi/acpica/amlresrc.h | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: amlresrc.h - AML resource descriptors | 3 | * Module Name: amlresrc.h - AML resource descriptors |
diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c index 465f02134b89..57895db3231a 100644 --- a/drivers/acpi/acpica/dscontrol.c +++ b/drivers/acpi/acpica/dscontrol.c | |||
@@ -280,7 +280,7 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, | |||
280 | 280 | ||
281 | /* | 281 | /* |
282 | * Get the return value and save as the last result | 282 | * Get the return value and save as the last result |
283 | * value. This is the only place where walk_state->return_desc | 283 | * value. This is the only place where walk_state->return_desc |
284 | * is set to anything other than zero! | 284 | * is set to anything other than zero! |
285 | */ | 285 | */ |
286 | walk_state->return_desc = walk_state->operands[0]; | 286 | walk_state->return_desc = walk_state->operands[0]; |
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c index 3da6fd8530c5..b5b904ee815f 100644 --- a/drivers/acpi/acpica/dsfield.c +++ b/drivers/acpi/acpica/dsfield.c | |||
@@ -277,7 +277,7 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op, | |||
277 | * | 277 | * |
278 | * RETURN: Status | 278 | * RETURN: Status |
279 | * | 279 | * |
280 | * DESCRIPTION: Process all named fields in a field declaration. Names are | 280 | * DESCRIPTION: Process all named fields in a field declaration. Names are |
281 | * entered into the namespace. | 281 | * entered into the namespace. |
282 | * | 282 | * |
283 | ******************************************************************************/ | 283 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c index aa9a5d4e4052..52eb4e01622a 100644 --- a/drivers/acpi/acpica/dsmethod.c +++ b/drivers/acpi/acpica/dsmethod.c | |||
@@ -170,7 +170,7 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc) | |||
170 | * | 170 | * |
171 | * RETURN: Status | 171 | * RETURN: Status |
172 | * | 172 | * |
173 | * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, | 173 | * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, |
174 | * increments the thread count, and waits at the method semaphore | 174 | * increments the thread count, and waits at the method semaphore |
175 | * for clearance to execute. | 175 | * for clearance to execute. |
176 | * | 176 | * |
@@ -444,7 +444,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, | |||
444 | * RETURN: Status | 444 | * RETURN: Status |
445 | * | 445 | * |
446 | * DESCRIPTION: Restart a method that was preempted by another (nested) method | 446 | * DESCRIPTION: Restart a method that was preempted by another (nested) method |
447 | * invocation. Handle the return value (if any) from the callee. | 447 | * invocation. Handle the return value (if any) from the callee. |
448 | * | 448 | * |
449 | ******************************************************************************/ | 449 | ******************************************************************************/ |
450 | 450 | ||
@@ -530,7 +530,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state, | |||
530 | * | 530 | * |
531 | * RETURN: None | 531 | * RETURN: None |
532 | * | 532 | * |
533 | * DESCRIPTION: Terminate a control method. Delete everything that the method | 533 | * DESCRIPTION: Terminate a control method. Delete everything that the method |
534 | * created, delete all locals and arguments, and delete the parse | 534 | * created, delete all locals and arguments, and delete the parse |
535 | * tree if requested. | 535 | * tree if requested. |
536 | * | 536 | * |
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c index 8d55cebaa656..9a83b7e0f3ba 100644 --- a/drivers/acpi/acpica/dsmthdat.c +++ b/drivers/acpi/acpica/dsmthdat.c | |||
@@ -76,7 +76,7 @@ acpi_ds_method_data_get_type(u16 opcode, | |||
76 | * RETURN: Status | 76 | * RETURN: Status |
77 | * | 77 | * |
78 | * DESCRIPTION: Initialize the data structures that hold the method's arguments | 78 | * DESCRIPTION: Initialize the data structures that hold the method's arguments |
79 | * and locals. The data struct is an array of namespace nodes for | 79 | * and locals. The data struct is an array of namespace nodes for |
80 | * each - this allows ref_of and de_ref_of to work properly for these | 80 | * each - this allows ref_of and de_ref_of to work properly for these |
81 | * special data types. | 81 | * special data types. |
82 | * | 82 | * |
@@ -129,7 +129,7 @@ void acpi_ds_method_data_init(struct acpi_walk_state *walk_state) | |||
129 | * | 129 | * |
130 | * RETURN: None | 130 | * RETURN: None |
131 | * | 131 | * |
132 | * DESCRIPTION: Delete method locals and arguments. Arguments are only | 132 | * DESCRIPTION: Delete method locals and arguments. Arguments are only |
133 | * deleted if this method was called from another method. | 133 | * deleted if this method was called from another method. |
134 | * | 134 | * |
135 | ******************************************************************************/ | 135 | ******************************************************************************/ |
@@ -183,7 +183,7 @@ void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state) | |||
183 | * | 183 | * |
184 | * RETURN: Status | 184 | * RETURN: Status |
185 | * | 185 | * |
186 | * DESCRIPTION: Initialize arguments for a method. The parameter list is a list | 186 | * DESCRIPTION: Initialize arguments for a method. The parameter list is a list |
187 | * of ACPI operand objects, either null terminated or whose length | 187 | * of ACPI operand objects, either null terminated or whose length |
188 | * is defined by max_param_count. | 188 | * is defined by max_param_count. |
189 | * | 189 | * |
@@ -401,7 +401,7 @@ acpi_ds_method_data_get_value(u8 type, | |||
401 | * This means that either 1) The expected argument was | 401 | * This means that either 1) The expected argument was |
402 | * not passed to the method, or 2) A local variable | 402 | * not passed to the method, or 2) A local variable |
403 | * was referenced by the method (via the ASL) | 403 | * was referenced by the method (via the ASL) |
404 | * before it was initialized. Either case is an error. | 404 | * before it was initialized. Either case is an error. |
405 | */ | 405 | */ |
406 | 406 | ||
407 | /* If slack enabled, init the local_x/arg_x to an Integer of value zero */ | 407 | /* If slack enabled, init the local_x/arg_x to an Integer of value zero */ |
@@ -465,7 +465,7 @@ acpi_ds_method_data_get_value(u8 type, | |||
465 | * | 465 | * |
466 | * RETURN: None | 466 | * RETURN: None |
467 | * | 467 | * |
468 | * DESCRIPTION: Delete the entry at Opcode:Index. Inserts | 468 | * DESCRIPTION: Delete the entry at Opcode:Index. Inserts |
469 | * a null into the stack slot after the object is deleted. | 469 | * a null into the stack slot after the object is deleted. |
470 | * | 470 | * |
471 | ******************************************************************************/ | 471 | ******************************************************************************/ |
@@ -523,7 +523,7 @@ acpi_ds_method_data_delete_value(u8 type, | |||
523 | * | 523 | * |
524 | * RETURN: Status | 524 | * RETURN: Status |
525 | * | 525 | * |
526 | * DESCRIPTION: Store a value in an Arg or Local. The obj_desc is installed | 526 | * DESCRIPTION: Store a value in an Arg or Local. The obj_desc is installed |
527 | * as the new value for the Arg or Local and the reference count | 527 | * as the new value for the Arg or Local and the reference count |
528 | * for obj_desc is incremented. | 528 | * for obj_desc is incremented. |
529 | * | 529 | * |
@@ -566,7 +566,7 @@ acpi_ds_store_object_to_local(u8 type, | |||
566 | 566 | ||
567 | /* | 567 | /* |
568 | * If the reference count on the object is more than one, we must | 568 | * If the reference count on the object is more than one, we must |
569 | * take a copy of the object before we store. A reference count | 569 | * take a copy of the object before we store. A reference count |
570 | * of exactly 1 means that the object was just created during the | 570 | * of exactly 1 means that the object was just created during the |
571 | * evaluation of an expression, and we can safely use it since it | 571 | * evaluation of an expression, and we can safely use it since it |
572 | * is not used anywhere else. | 572 | * is not used anywhere else. |
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c index 68592dd34960..c9f15d3a3686 100644 --- a/drivers/acpi/acpica/dsobject.c +++ b/drivers/acpi/acpica/dsobject.c | |||
@@ -293,7 +293,7 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, | |||
293 | 293 | ||
294 | /* | 294 | /* |
295 | * Second arg is the buffer data (optional) byte_list can be either | 295 | * Second arg is the buffer data (optional) byte_list can be either |
296 | * individual bytes or a string initializer. In either case, a | 296 | * individual bytes or a string initializer. In either case, a |
297 | * byte_list appears in the AML. | 297 | * byte_list appears in the AML. |
298 | */ | 298 | */ |
299 | arg = op->common.value.arg; /* skip first arg */ | 299 | arg = op->common.value.arg; /* skip first arg */ |
@@ -568,7 +568,7 @@ acpi_ds_create_node(struct acpi_walk_state *walk_state, | |||
568 | 568 | ||
569 | /* | 569 | /* |
570 | * Because of the execution pass through the non-control-method | 570 | * Because of the execution pass through the non-control-method |
571 | * parts of the table, we can arrive here twice. Only init | 571 | * parts of the table, we can arrive here twice. Only init |
572 | * the named object node the first time through | 572 | * the named object node the first time through |
573 | */ | 573 | */ |
574 | if (acpi_ns_get_attached_object(node)) { | 574 | if (acpi_ns_get_attached_object(node)) { |
@@ -618,7 +618,7 @@ acpi_ds_create_node(struct acpi_walk_state *walk_state, | |||
618 | * RETURN: Status | 618 | * RETURN: Status |
619 | * | 619 | * |
620 | * DESCRIPTION: Initialize a namespace object from a parser Op and its | 620 | * DESCRIPTION: Initialize a namespace object from a parser Op and its |
621 | * associated arguments. The namespace object is a more compact | 621 | * associated arguments. The namespace object is a more compact |
622 | * representation of the Op and its arguments. | 622 | * representation of the Op and its arguments. |
623 | * | 623 | * |
624 | ******************************************************************************/ | 624 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c index aa34d8984d34..0df024e5fb63 100644 --- a/drivers/acpi/acpica/dsopcode.c +++ b/drivers/acpi/acpica/dsopcode.c | |||
@@ -649,7 +649,8 @@ acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state, | |||
649 | ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && | 649 | ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && |
650 | (op->common.parent->common.aml_opcode != | 650 | (op->common.parent->common.aml_opcode != |
651 | AML_VAR_PACKAGE_OP) | 651 | AML_VAR_PACKAGE_OP) |
652 | && (op->common.parent->common.aml_opcode != AML_NAME_OP))) { | 652 | && (op->common.parent->common.aml_opcode != |
653 | AML_NAME_OP))) { | ||
653 | walk_state->result_obj = obj_desc; | 654 | walk_state->result_obj = obj_desc; |
654 | } | 655 | } |
655 | } | 656 | } |
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c index 73a5447475f5..afeb99f49482 100644 --- a/drivers/acpi/acpica/dsutils.c +++ b/drivers/acpi/acpica/dsutils.c | |||
@@ -61,7 +61,7 @@ ACPI_MODULE_NAME("dsutils") | |||
61 | * | 61 | * |
62 | * RETURN: None. | 62 | * RETURN: None. |
63 | * | 63 | * |
64 | * DESCRIPTION: Clear and remove a reference on an implicit return value. Used | 64 | * DESCRIPTION: Clear and remove a reference on an implicit return value. Used |
65 | * to delete "stale" return values (if enabled, the return value | 65 | * to delete "stale" return values (if enabled, the return value |
66 | * from every operator is saved at least momentarily, in case the | 66 | * from every operator is saved at least momentarily, in case the |
67 | * parent method exits.) | 67 | * parent method exits.) |
@@ -107,7 +107,7 @@ void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state) | |||
107 | * | 107 | * |
108 | * DESCRIPTION: Implements the optional "implicit return". We save the result | 108 | * DESCRIPTION: Implements the optional "implicit return". We save the result |
109 | * of every ASL operator and control method invocation in case the | 109 | * of every ASL operator and control method invocation in case the |
110 | * parent method exit. Before storing a new return value, we | 110 | * parent method exit. Before storing a new return value, we |
111 | * delete the previous return value. | 111 | * delete the previous return value. |
112 | * | 112 | * |
113 | ******************************************************************************/ | 113 | ******************************************************************************/ |
@@ -198,7 +198,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
198 | * | 198 | * |
199 | * If there is no parent, or the parent is a scope_op, we are executing | 199 | * If there is no parent, or the parent is a scope_op, we are executing |
200 | * at the method level. An executing method typically has no parent, | 200 | * at the method level. An executing method typically has no parent, |
201 | * since each method is parsed separately. A method invoked externally | 201 | * since each method is parsed separately. A method invoked externally |
202 | * via execute_control_method has a scope_op as the parent. | 202 | * via execute_control_method has a scope_op as the parent. |
203 | */ | 203 | */ |
204 | if ((!op->common.parent) || | 204 | if ((!op->common.parent) || |
@@ -223,7 +223,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
223 | } | 223 | } |
224 | 224 | ||
225 | /* | 225 | /* |
226 | * Decide what to do with the result based on the parent. If | 226 | * Decide what to do with the result based on the parent. If |
227 | * the parent opcode will not use the result, delete the object. | 227 | * the parent opcode will not use the result, delete the object. |
228 | * Otherwise leave it as is, it will be deleted when it is used | 228 | * Otherwise leave it as is, it will be deleted when it is used |
229 | * as an operand later. | 229 | * as an operand later. |
@@ -266,7 +266,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
266 | 266 | ||
267 | /* | 267 | /* |
268 | * These opcodes allow term_arg(s) as operands and therefore | 268 | * These opcodes allow term_arg(s) as operands and therefore |
269 | * the operands can be method calls. The result is used. | 269 | * the operands can be method calls. The result is used. |
270 | */ | 270 | */ |
271 | goto result_used; | 271 | goto result_used; |
272 | 272 | ||
@@ -284,7 +284,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
284 | AML_BANK_FIELD_OP)) { | 284 | AML_BANK_FIELD_OP)) { |
285 | /* | 285 | /* |
286 | * These opcodes allow term_arg(s) as operands and therefore | 286 | * These opcodes allow term_arg(s) as operands and therefore |
287 | * the operands can be method calls. The result is used. | 287 | * the operands can be method calls. The result is used. |
288 | */ | 288 | */ |
289 | goto result_used; | 289 | goto result_used; |
290 | } | 290 | } |
@@ -329,9 +329,9 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
329 | * | 329 | * |
330 | * RETURN: Status | 330 | * RETURN: Status |
331 | * | 331 | * |
332 | * DESCRIPTION: Used after interpretation of an opcode. If there is an internal | 332 | * DESCRIPTION: Used after interpretation of an opcode. If there is an internal |
333 | * result descriptor, check if the parent opcode will actually use | 333 | * result descriptor, check if the parent opcode will actually use |
334 | * this result. If not, delete the result now so that it will | 334 | * this result. If not, delete the result now so that it will |
335 | * not become orphaned. | 335 | * not become orphaned. |
336 | * | 336 | * |
337 | ******************************************************************************/ | 337 | ******************************************************************************/ |
@@ -376,7 +376,7 @@ acpi_ds_delete_result_if_not_used(union acpi_parse_object *op, | |||
376 | * | 376 | * |
377 | * RETURN: Status | 377 | * RETURN: Status |
378 | * | 378 | * |
379 | * DESCRIPTION: Resolve all operands to their values. Used to prepare | 379 | * DESCRIPTION: Resolve all operands to their values. Used to prepare |
380 | * arguments to a control method invocation (a call from one | 380 | * arguments to a control method invocation (a call from one |
381 | * method to another.) | 381 | * method to another.) |
382 | * | 382 | * |
@@ -391,7 +391,7 @@ acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state) | |||
391 | 391 | ||
392 | /* | 392 | /* |
393 | * Attempt to resolve each of the valid operands | 393 | * Attempt to resolve each of the valid operands |
394 | * Method arguments are passed by reference, not by value. This means | 394 | * Method arguments are passed by reference, not by value. This means |
395 | * that the actual objects are passed, not copies of the objects. | 395 | * that the actual objects are passed, not copies of the objects. |
396 | */ | 396 | */ |
397 | for (i = 0; i < walk_state->num_operands; i++) { | 397 | for (i = 0; i < walk_state->num_operands; i++) { |
@@ -451,7 +451,7 @@ void acpi_ds_clear_operands(struct acpi_walk_state *walk_state) | |||
451 | * RETURN: Status | 451 | * RETURN: Status |
452 | * | 452 | * |
453 | * DESCRIPTION: Translate a parse tree object that is an argument to an AML | 453 | * DESCRIPTION: Translate a parse tree object that is an argument to an AML |
454 | * opcode to the equivalent interpreter object. This may include | 454 | * opcode to the equivalent interpreter object. This may include |
455 | * looking up a name or entering a new name into the internal | 455 | * looking up a name or entering a new name into the internal |
456 | * namespace. | 456 | * namespace. |
457 | * | 457 | * |
@@ -496,9 +496,9 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state, | |||
496 | /* | 496 | /* |
497 | * Special handling for buffer_field declarations. This is a deferred | 497 | * Special handling for buffer_field declarations. This is a deferred |
498 | * opcode that unfortunately defines the field name as the last | 498 | * opcode that unfortunately defines the field name as the last |
499 | * parameter instead of the first. We get here when we are performing | 499 | * parameter instead of the first. We get here when we are performing |
500 | * the deferred execution, so the actual name of the field is already | 500 | * the deferred execution, so the actual name of the field is already |
501 | * in the namespace. We don't want to attempt to look it up again | 501 | * in the namespace. We don't want to attempt to look it up again |
502 | * because we may be executing in a different scope than where the | 502 | * because we may be executing in a different scope than where the |
503 | * actual opcode exists. | 503 | * actual opcode exists. |
504 | */ | 504 | */ |
@@ -560,7 +560,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state, | |||
560 | * indicate this to the interpreter, set the | 560 | * indicate this to the interpreter, set the |
561 | * object to the root | 561 | * object to the root |
562 | */ | 562 | */ |
563 | obj_desc = ACPI_CAST_PTR(union | 563 | obj_desc = |
564 | ACPI_CAST_PTR(union | ||
564 | acpi_operand_object, | 565 | acpi_operand_object, |
565 | acpi_gbl_root_node); | 566 | acpi_gbl_root_node); |
566 | status = AE_OK; | 567 | status = AE_OK; |
@@ -604,8 +605,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state, | |||
604 | /* | 605 | /* |
605 | * If the name is null, this means that this is an | 606 | * If the name is null, this means that this is an |
606 | * optional result parameter that was not specified | 607 | * optional result parameter that was not specified |
607 | * in the original ASL. Create a Zero Constant for a | 608 | * in the original ASL. Create a Zero Constant for a |
608 | * placeholder. (Store to a constant is a Noop.) | 609 | * placeholder. (Store to a constant is a Noop.) |
609 | */ | 610 | */ |
610 | opcode = AML_ZERO_OP; /* Has no arguments! */ | 611 | opcode = AML_ZERO_OP; /* Has no arguments! */ |
611 | 612 | ||
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c index 642f3c053e87..58593931be96 100644 --- a/drivers/acpi/acpica/dswexec.c +++ b/drivers/acpi/acpica/dswexec.c | |||
@@ -57,7 +57,7 @@ ACPI_MODULE_NAME("dswexec") | |||
57 | /* | 57 | /* |
58 | * Dispatch table for opcode classes | 58 | * Dispatch table for opcode classes |
59 | */ | 59 | */ |
60 | static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch[] = { | 60 | static acpi_execute_op acpi_gbl_op_type_dispatch[] = { |
61 | acpi_ex_opcode_0A_0T_1R, | 61 | acpi_ex_opcode_0A_0T_1R, |
62 | acpi_ex_opcode_1A_0T_0R, | 62 | acpi_ex_opcode_1A_0T_0R, |
63 | acpi_ex_opcode_1A_0T_1R, | 63 | acpi_ex_opcode_1A_0T_1R, |
@@ -204,7 +204,7 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, | |||
204 | * RETURN: Status | 204 | * RETURN: Status |
205 | * | 205 | * |
206 | * DESCRIPTION: Descending callback used during the execution of control | 206 | * DESCRIPTION: Descending callback used during the execution of control |
207 | * methods. This is where most operators and operands are | 207 | * methods. This is where most operators and operands are |
208 | * dispatched to the interpreter. | 208 | * dispatched to the interpreter. |
209 | * | 209 | * |
210 | ****************************************************************************/ | 210 | ****************************************************************************/ |
@@ -297,7 +297,7 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state, | |||
297 | if (walk_state->walk_type & ACPI_WALK_METHOD) { | 297 | if (walk_state->walk_type & ACPI_WALK_METHOD) { |
298 | /* | 298 | /* |
299 | * Found a named object declaration during method execution; | 299 | * Found a named object declaration during method execution; |
300 | * we must enter this object into the namespace. The created | 300 | * we must enter this object into the namespace. The created |
301 | * object is temporary and will be deleted upon completion of | 301 | * object is temporary and will be deleted upon completion of |
302 | * the execution of this method. | 302 | * the execution of this method. |
303 | * | 303 | * |
@@ -348,7 +348,7 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state, | |||
348 | * RETURN: Status | 348 | * RETURN: Status |
349 | * | 349 | * |
350 | * DESCRIPTION: Ascending callback used during the execution of control | 350 | * DESCRIPTION: Ascending callback used during the execution of control |
351 | * methods. The only thing we really need to do here is to | 351 | * methods. The only thing we really need to do here is to |
352 | * notice the beginning of IF, ELSE, and WHILE blocks. | 352 | * notice the beginning of IF, ELSE, and WHILE blocks. |
353 | * | 353 | * |
354 | ****************************************************************************/ | 354 | ****************************************************************************/ |
@@ -432,7 +432,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) | |||
432 | if (ACPI_SUCCESS(status)) { | 432 | if (ACPI_SUCCESS(status)) { |
433 | /* | 433 | /* |
434 | * Dispatch the request to the appropriate interpreter handler | 434 | * Dispatch the request to the appropriate interpreter handler |
435 | * routine. There is one routine per opcode "type" based upon the | 435 | * routine. There is one routine per opcode "type" based upon the |
436 | * number of opcode arguments and return type. | 436 | * number of opcode arguments and return type. |
437 | */ | 437 | */ |
438 | status = | 438 | status = |
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c index 89c0114210c0..379835748357 100644 --- a/drivers/acpi/acpica/dswload2.c +++ b/drivers/acpi/acpica/dswload2.c | |||
@@ -254,7 +254,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, | |||
254 | acpi_ut_get_type_name(node->type), | 254 | acpi_ut_get_type_name(node->type), |
255 | acpi_ut_get_node_name(node))); | 255 | acpi_ut_get_node_name(node))); |
256 | 256 | ||
257 | return (AE_AML_OPERAND_TYPE); | 257 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
258 | } | 258 | } |
259 | break; | 259 | break; |
260 | 260 | ||
@@ -602,7 +602,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) | |||
602 | region_space, | 602 | region_space, |
603 | walk_state); | 603 | walk_state); |
604 | if (ACPI_FAILURE(status)) { | 604 | if (ACPI_FAILURE(status)) { |
605 | return (status); | 605 | return_ACPI_STATUS(status); |
606 | } | 606 | } |
607 | 607 | ||
608 | acpi_ex_exit_interpreter(); | 608 | acpi_ex_exit_interpreter(); |
diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c index d0e6555061e4..3e65a15a735f 100644 --- a/drivers/acpi/acpica/dswstate.c +++ b/drivers/acpi/acpica/dswstate.c | |||
@@ -51,8 +51,9 @@ | |||
51 | ACPI_MODULE_NAME("dswstate") | 51 | ACPI_MODULE_NAME("dswstate") |
52 | 52 | ||
53 | /* Local prototypes */ | 53 | /* Local prototypes */ |
54 | static acpi_status acpi_ds_result_stack_push(struct acpi_walk_state *ws); | 54 | static acpi_status |
55 | static acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *ws); | 55 | acpi_ds_result_stack_push(struct acpi_walk_state *walk_state); |
56 | static acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *walk_state); | ||
56 | 57 | ||
57 | /******************************************************************************* | 58 | /******************************************************************************* |
58 | * | 59 | * |
@@ -347,7 +348,7 @@ acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state) | |||
347 | * | 348 | * |
348 | * RETURN: Status | 349 | * RETURN: Status |
349 | * | 350 | * |
350 | * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT | 351 | * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT |
351 | * deleted by this routine. | 352 | * deleted by this routine. |
352 | * | 353 | * |
353 | ******************************************************************************/ | 354 | ******************************************************************************/ |
@@ -491,7 +492,7 @@ acpi_ds_push_walk_state(struct acpi_walk_state *walk_state, | |||
491 | * RETURN: A walk_state object popped from the thread's stack | 492 | * RETURN: A walk_state object popped from the thread's stack |
492 | * | 493 | * |
493 | * DESCRIPTION: Remove and return the walkstate object that is at the head of | 494 | * DESCRIPTION: Remove and return the walkstate object that is at the head of |
494 | * the walk stack for the given walk list. NULL indicates that | 495 | * the walk stack for the given walk list. NULL indicates that |
495 | * the list is empty. | 496 | * the list is empty. |
496 | * | 497 | * |
497 | ******************************************************************************/ | 498 | ******************************************************************************/ |
@@ -531,14 +532,17 @@ struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread) | |||
531 | * | 532 | * |
532 | * RETURN: Pointer to the new walk state. | 533 | * RETURN: Pointer to the new walk state. |
533 | * | 534 | * |
534 | * DESCRIPTION: Allocate and initialize a new walk state. The current walk | 535 | * DESCRIPTION: Allocate and initialize a new walk state. The current walk |
535 | * state is set to this new state. | 536 | * state is set to this new state. |
536 | * | 537 | * |
537 | ******************************************************************************/ | 538 | ******************************************************************************/ |
538 | 539 | ||
539 | struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, union acpi_parse_object | 540 | struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, |
540 | *origin, union acpi_operand_object | 541 | union acpi_parse_object |
541 | *method_desc, struct acpi_thread_state | 542 | *origin, |
543 | union acpi_operand_object | ||
544 | *method_desc, | ||
545 | struct acpi_thread_state | ||
542 | *thread) | 546 | *thread) |
543 | { | 547 | { |
544 | struct acpi_walk_state *walk_state; | 548 | struct acpi_walk_state *walk_state; |
@@ -653,7 +657,7 @@ acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state, | |||
653 | /* | 657 | /* |
654 | * Setup the current scope. | 658 | * Setup the current scope. |
655 | * Find a Named Op that has a namespace node associated with it. | 659 | * Find a Named Op that has a namespace node associated with it. |
656 | * search upwards from this Op. Current scope is the first | 660 | * search upwards from this Op. Current scope is the first |
657 | * Op with a namespace node. | 661 | * Op with a namespace node. |
658 | */ | 662 | */ |
659 | extra_op = parser_state->start_op; | 663 | extra_op = parser_state->start_op; |
@@ -704,13 +708,13 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state) | |||
704 | ACPI_FUNCTION_TRACE_PTR(ds_delete_walk_state, walk_state); | 708 | ACPI_FUNCTION_TRACE_PTR(ds_delete_walk_state, walk_state); |
705 | 709 | ||
706 | if (!walk_state) { | 710 | if (!walk_state) { |
707 | return; | 711 | return_VOID; |
708 | } | 712 | } |
709 | 713 | ||
710 | if (walk_state->descriptor_type != ACPI_DESC_TYPE_WALK) { | 714 | if (walk_state->descriptor_type != ACPI_DESC_TYPE_WALK) { |
711 | ACPI_ERROR((AE_INFO, "%p is not a valid walk state", | 715 | ACPI_ERROR((AE_INFO, "%p is not a valid walk state", |
712 | walk_state)); | 716 | walk_state)); |
713 | return; | 717 | return_VOID; |
714 | } | 718 | } |
715 | 719 | ||
716 | /* There should not be any open scopes */ | 720 | /* There should not be any open scopes */ |
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index ef0193d74b5d..36d120574423 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c | |||
@@ -89,7 +89,8 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info) | |||
89 | /* Set the mask bit only if there are references to this GPE */ | 89 | /* Set the mask bit only if there are references to this GPE */ |
90 | 90 | ||
91 | if (gpe_event_info->runtime_count) { | 91 | if (gpe_event_info->runtime_count) { |
92 | ACPI_SET_BIT(gpe_register_info->enable_for_run, (u8)register_bit); | 92 | ACPI_SET_BIT(gpe_register_info->enable_for_run, |
93 | (u8)register_bit); | ||
93 | } | 94 | } |
94 | 95 | ||
95 | return_ACPI_STATUS(AE_OK); | 96 | return_ACPI_STATUS(AE_OK); |
@@ -106,8 +107,7 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info) | |||
106 | * DESCRIPTION: Clear a GPE of stale events and enable it. | 107 | * DESCRIPTION: Clear a GPE of stale events and enable it. |
107 | * | 108 | * |
108 | ******************************************************************************/ | 109 | ******************************************************************************/ |
109 | acpi_status | 110 | acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) |
110 | acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) | ||
111 | { | 111 | { |
112 | acpi_status status; | 112 | acpi_status status; |
113 | 113 | ||
@@ -131,8 +131,8 @@ acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
131 | } | 131 | } |
132 | 132 | ||
133 | /* Enable the requested GPE */ | 133 | /* Enable the requested GPE */ |
134 | status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE); | ||
135 | 134 | ||
135 | status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE); | ||
136 | return_ACPI_STATUS(status); | 136 | return_ACPI_STATUS(status); |
137 | } | 137 | } |
138 | 138 | ||
@@ -150,7 +150,8 @@ acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
150 | * | 150 | * |
151 | ******************************************************************************/ | 151 | ******************************************************************************/ |
152 | 152 | ||
153 | acpi_status acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info) | 153 | acpi_status |
154 | acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info) | ||
154 | { | 155 | { |
155 | acpi_status status = AE_OK; | 156 | acpi_status status = AE_OK; |
156 | 157 | ||
@@ -191,7 +192,8 @@ acpi_status acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info | |||
191 | * | 192 | * |
192 | ******************************************************************************/ | 193 | ******************************************************************************/ |
193 | 194 | ||
194 | acpi_status acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info) | 195 | acpi_status |
196 | acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info) | ||
195 | { | 197 | { |
196 | acpi_status status = AE_OK; | 198 | acpi_status status = AE_OK; |
197 | 199 | ||
@@ -208,7 +210,8 @@ acpi_status acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_i | |||
208 | 210 | ||
209 | status = acpi_ev_update_gpe_enable_mask(gpe_event_info); | 211 | status = acpi_ev_update_gpe_enable_mask(gpe_event_info); |
210 | if (ACPI_SUCCESS(status)) { | 212 | if (ACPI_SUCCESS(status)) { |
211 | status = acpi_hw_low_set_gpe(gpe_event_info, | 213 | status = |
214 | acpi_hw_low_set_gpe(gpe_event_info, | ||
212 | ACPI_GPE_DISABLE); | 215 | ACPI_GPE_DISABLE); |
213 | } | 216 | } |
214 | 217 | ||
@@ -306,7 +309,8 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, | |||
306 | 309 | ||
307 | /* A Non-NULL gpe_device means this is a GPE Block Device */ | 310 | /* A Non-NULL gpe_device means this is a GPE Block Device */ |
308 | 311 | ||
309 | obj_desc = acpi_ns_get_attached_object((struct acpi_namespace_node *) | 312 | obj_desc = |
313 | acpi_ns_get_attached_object((struct acpi_namespace_node *) | ||
310 | gpe_device); | 314 | gpe_device); |
311 | if (!obj_desc || !obj_desc->device.gpe_block) { | 315 | if (!obj_desc || !obj_desc->device.gpe_block) { |
312 | return (NULL); | 316 | return (NULL); |
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c index 8cf4c104c7b7..1571a61a7833 100644 --- a/drivers/acpi/acpica/evgpeblk.c +++ b/drivers/acpi/acpica/evgpeblk.c | |||
@@ -486,7 +486,8 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
486 | if (ACPI_FAILURE(status)) { | 486 | if (ACPI_FAILURE(status)) { |
487 | ACPI_EXCEPTION((AE_INFO, status, | 487 | ACPI_EXCEPTION((AE_INFO, status, |
488 | "Could not enable GPE 0x%02X", | 488 | "Could not enable GPE 0x%02X", |
489 | gpe_index + gpe_block->block_base_number)); | 489 | gpe_index + |
490 | gpe_block->block_base_number)); | ||
490 | continue; | 491 | continue; |
491 | } | 492 | } |
492 | 493 | ||
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c index cb50dd91bc18..228a0c3b1d49 100644 --- a/drivers/acpi/acpica/evgpeutil.c +++ b/drivers/acpi/acpica/evgpeutil.c | |||
@@ -374,7 +374,8 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
374 | gpe_event_info->dispatch.handler = NULL; | 374 | gpe_event_info->dispatch.handler = NULL; |
375 | gpe_event_info->flags &= | 375 | gpe_event_info->flags &= |
376 | ~ACPI_GPE_DISPATCH_MASK; | 376 | ~ACPI_GPE_DISPATCH_MASK; |
377 | } else if ((gpe_event_info-> | 377 | } else |
378 | if ((gpe_event_info-> | ||
378 | flags & ACPI_GPE_DISPATCH_MASK) == | 379 | flags & ACPI_GPE_DISPATCH_MASK) == |
379 | ACPI_GPE_DISPATCH_NOTIFY) { | 380 | ACPI_GPE_DISPATCH_NOTIFY) { |
380 | 381 | ||
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c index 4c1c8261166f..1474241bfc7e 100644 --- a/drivers/acpi/acpica/evrgnini.c +++ b/drivers/acpi/acpica/evrgnini.c | |||
@@ -227,8 +227,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle, | |||
227 | 227 | ||
228 | /* Install a handler for this PCI root bridge */ | 228 | /* Install a handler for this PCI root bridge */ |
229 | 229 | ||
230 | status = | 230 | status = acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); |
231 | acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); | ||
232 | if (ACPI_FAILURE(status)) { | 231 | if (ACPI_FAILURE(status)) { |
233 | if (status == AE_SAME_HANDLER) { | 232 | if (status == AE_SAME_HANDLER) { |
234 | /* | 233 | /* |
@@ -350,8 +349,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle, | |||
350 | static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node) | 349 | static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node) |
351 | { | 350 | { |
352 | acpi_status status; | 351 | acpi_status status; |
353 | struct acpica_device_id *hid; | 352 | struct acpi_pnp_device_id *hid; |
354 | struct acpica_device_id_list *cid; | 353 | struct acpi_pnp_device_id_list *cid; |
355 | u32 i; | 354 | u32 i; |
356 | u8 match; | 355 | u8 match; |
357 | 356 | ||
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c index 7587eb6c9584..ae668f32cf16 100644 --- a/drivers/acpi/acpica/evxface.c +++ b/drivers/acpi/acpica/evxface.c | |||
@@ -398,7 +398,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) | |||
398 | * | 398 | * |
399 | ******************************************************************************/ | 399 | ******************************************************************************/ |
400 | acpi_status | 400 | acpi_status |
401 | acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, void *context) | 401 | acpi_install_global_event_handler(acpi_gbl_event_handler handler, void *context) |
402 | { | 402 | { |
403 | acpi_status status; | 403 | acpi_status status; |
404 | 404 | ||
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c index 87c5f2332260..3f30e753b652 100644 --- a/drivers/acpi/acpica/evxfgpe.c +++ b/drivers/acpi/acpica/evxfgpe.c | |||
@@ -221,7 +221,8 @@ acpi_setup_gpe_for_wake(acpi_handle wake_device, | |||
221 | if (wake_device == ACPI_ROOT_OBJECT) { | 221 | if (wake_device == ACPI_ROOT_OBJECT) { |
222 | device_node = acpi_gbl_root_node; | 222 | device_node = acpi_gbl_root_node; |
223 | } else { | 223 | } else { |
224 | device_node = ACPI_CAST_PTR(struct acpi_namespace_node, wake_device); | 224 | device_node = |
225 | ACPI_CAST_PTR(struct acpi_namespace_node, wake_device); | ||
225 | } | 226 | } |
226 | 227 | ||
227 | /* Validate WakeDevice is of type Device */ | 228 | /* Validate WakeDevice is of type Device */ |
@@ -324,7 +325,8 @@ ACPI_EXPORT_SYMBOL(acpi_setup_gpe_for_wake) | |||
324 | * | 325 | * |
325 | ******************************************************************************/ | 326 | ******************************************************************************/ |
326 | 327 | ||
327 | acpi_status acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action) | 328 | acpi_status |
329 | acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action) | ||
328 | { | 330 | { |
329 | acpi_status status = AE_OK; | 331 | acpi_status status = AE_OK; |
330 | struct acpi_gpe_event_info *gpe_event_info; | 332 | struct acpi_gpe_event_info *gpe_event_info; |
@@ -567,7 +569,7 @@ acpi_install_gpe_block(acpi_handle gpe_device, | |||
567 | 569 | ||
568 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | 570 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
569 | if (ACPI_FAILURE(status)) { | 571 | if (ACPI_FAILURE(status)) { |
570 | return (status); | 572 | return_ACPI_STATUS(status); |
571 | } | 573 | } |
572 | 574 | ||
573 | node = acpi_ns_validate_handle(gpe_device); | 575 | node = acpi_ns_validate_handle(gpe_device); |
@@ -650,7 +652,7 @@ acpi_status acpi_remove_gpe_block(acpi_handle gpe_device) | |||
650 | 652 | ||
651 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | 653 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
652 | if (ACPI_FAILURE(status)) { | 654 | if (ACPI_FAILURE(status)) { |
653 | return (status); | 655 | return_ACPI_STATUS(status); |
654 | } | 656 | } |
655 | 657 | ||
656 | node = acpi_ns_validate_handle(gpe_device); | 658 | node = acpi_ns_validate_handle(gpe_device); |
@@ -694,8 +696,7 @@ ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block) | |||
694 | * the FADT-defined gpe blocks. Otherwise, the GPE block device. | 696 | * the FADT-defined gpe blocks. Otherwise, the GPE block device. |
695 | * | 697 | * |
696 | ******************************************************************************/ | 698 | ******************************************************************************/ |
697 | acpi_status | 699 | acpi_status acpi_get_gpe_device(u32 index, acpi_handle * gpe_device) |
698 | acpi_get_gpe_device(u32 index, acpi_handle *gpe_device) | ||
699 | { | 700 | { |
700 | struct acpi_gpe_device_info info; | 701 | struct acpi_gpe_device_info info; |
701 | acpi_status status; | 702 | acpi_status status; |
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c index bfb062e4c4b4..4492a4e03022 100644 --- a/drivers/acpi/acpica/exconvrt.c +++ b/drivers/acpi/acpica/exconvrt.c | |||
@@ -516,8 +516,8 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, | |||
516 | string_length--; | 516 | string_length--; |
517 | } | 517 | } |
518 | 518 | ||
519 | return_desc = acpi_ut_create_string_object((acpi_size) | 519 | return_desc = |
520 | string_length); | 520 | acpi_ut_create_string_object((acpi_size) string_length); |
521 | if (!return_desc) { | 521 | if (!return_desc) { |
522 | return_ACPI_STATUS(AE_NO_MEMORY); | 522 | return_ACPI_STATUS(AE_NO_MEMORY); |
523 | } | 523 | } |
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c index 691d4763102c..66554bc6f9a8 100644 --- a/drivers/acpi/acpica/excreate.c +++ b/drivers/acpi/acpica/excreate.c | |||
@@ -78,7 +78,7 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) | |||
78 | (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { | 78 | (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { |
79 | /* | 79 | /* |
80 | * Dereference an existing alias so that we don't create a chain | 80 | * Dereference an existing alias so that we don't create a chain |
81 | * of aliases. With this code, we guarantee that an alias is | 81 | * of aliases. With this code, we guarantee that an alias is |
82 | * always exactly one level of indirection away from the | 82 | * always exactly one level of indirection away from the |
83 | * actual aliased name. | 83 | * actual aliased name. |
84 | */ | 84 | */ |
@@ -90,7 +90,7 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) | |||
90 | /* | 90 | /* |
91 | * For objects that can never change (i.e., the NS node will | 91 | * For objects that can never change (i.e., the NS node will |
92 | * permanently point to the same object), we can simply attach | 92 | * permanently point to the same object), we can simply attach |
93 | * the object to the new NS node. For other objects (such as | 93 | * the object to the new NS node. For other objects (such as |
94 | * Integers, buffers, etc.), we have to point the Alias node | 94 | * Integers, buffers, etc.), we have to point the Alias node |
95 | * to the original Node. | 95 | * to the original Node. |
96 | */ | 96 | */ |
@@ -139,7 +139,7 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) | |||
139 | 139 | ||
140 | /* | 140 | /* |
141 | * The new alias assumes the type of the target, and it points | 141 | * The new alias assumes the type of the target, and it points |
142 | * to the same object. The reference count of the object has an | 142 | * to the same object. The reference count of the object has an |
143 | * additional reference to prevent deletion out from under either the | 143 | * additional reference to prevent deletion out from under either the |
144 | * target node or the alias Node | 144 | * target node or the alias Node |
145 | */ | 145 | */ |
@@ -243,8 +243,7 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state) | |||
243 | 243 | ||
244 | /* Init object and attach to NS node */ | 244 | /* Init object and attach to NS node */ |
245 | 245 | ||
246 | obj_desc->mutex.sync_level = | 246 | obj_desc->mutex.sync_level = (u8)walk_state->operands[1]->integer.value; |
247 | (u8) walk_state->operands[1]->integer.value; | ||
248 | obj_desc->mutex.node = | 247 | obj_desc->mutex.node = |
249 | (struct acpi_namespace_node *)walk_state->operands[0]; | 248 | (struct acpi_namespace_node *)walk_state->operands[0]; |
250 | 249 | ||
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c index bc5b9a6a1316..d7c9f51608a7 100644 --- a/drivers/acpi/acpica/exdebug.c +++ b/drivers/acpi/acpica/exdebug.c | |||
@@ -145,10 +145,10 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, | |||
145 | case ACPI_TYPE_BUFFER: | 145 | case ACPI_TYPE_BUFFER: |
146 | 146 | ||
147 | acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length); | 147 | acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length); |
148 | acpi_ut_dump_buffer2(source_desc->buffer.pointer, | 148 | acpi_ut_dump_buffer(source_desc->buffer.pointer, |
149 | (source_desc->buffer.length < 256) ? | 149 | (source_desc->buffer.length < 256) ? |
150 | source_desc->buffer.length : 256, | 150 | source_desc->buffer.length : 256, |
151 | DB_BYTE_DISPLAY); | 151 | DB_BYTE_DISPLAY, 0); |
152 | break; | 152 | break; |
153 | 153 | ||
154 | case ACPI_TYPE_STRING: | 154 | case ACPI_TYPE_STRING: |
@@ -190,7 +190,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, | |||
190 | 190 | ||
191 | acpi_os_printf("Table Index 0x%X\n", | 191 | acpi_os_printf("Table Index 0x%X\n", |
192 | source_desc->reference.value); | 192 | source_desc->reference.value); |
193 | return; | 193 | return_VOID; |
194 | 194 | ||
195 | default: | 195 | default: |
196 | break; | 196 | break; |
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c index 213c081776fc..858b43a7dcf6 100644 --- a/drivers/acpi/acpica/exdump.c +++ b/drivers/acpi/acpica/exdump.c | |||
@@ -464,7 +464,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) | |||
464 | 464 | ||
465 | ACPI_FUNCTION_NAME(ex_dump_operand) | 465 | ACPI_FUNCTION_NAME(ex_dump_operand) |
466 | 466 | ||
467 | if (!((ACPI_LV_EXEC & acpi_dbg_level) | 467 | if (! |
468 | ((ACPI_LV_EXEC & acpi_dbg_level) | ||
468 | && (_COMPONENT & acpi_dbg_layer))) { | 469 | && (_COMPONENT & acpi_dbg_layer))) { |
469 | return; | 470 | return; |
470 | } | 471 | } |
@@ -777,7 +778,7 @@ acpi_ex_dump_operands(union acpi_operand_object **operands, | |||
777 | * PARAMETERS: title - Descriptive text | 778 | * PARAMETERS: title - Descriptive text |
778 | * value - Value to be displayed | 779 | * value - Value to be displayed |
779 | * | 780 | * |
780 | * DESCRIPTION: Object dump output formatting functions. These functions | 781 | * DESCRIPTION: Object dump output formatting functions. These functions |
781 | * reduce the number of format strings required and keeps them | 782 | * reduce the number of format strings required and keeps them |
782 | * all in one place for easy modification. | 783 | * all in one place for easy modification. |
783 | * | 784 | * |
@@ -810,7 +811,8 @@ void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags) | |||
810 | ACPI_FUNCTION_ENTRY(); | 811 | ACPI_FUNCTION_ENTRY(); |
811 | 812 | ||
812 | if (!flags) { | 813 | if (!flags) { |
813 | if (!((ACPI_LV_OBJECTS & acpi_dbg_level) | 814 | if (! |
815 | ((ACPI_LV_OBJECTS & acpi_dbg_level) | ||
814 | && (_COMPONENT & acpi_dbg_layer))) { | 816 | && (_COMPONENT & acpi_dbg_layer))) { |
815 | return; | 817 | return; |
816 | } | 818 | } |
@@ -940,10 +942,11 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc, | |||
940 | acpi_os_printf("[Buffer] Length %.2X = ", | 942 | acpi_os_printf("[Buffer] Length %.2X = ", |
941 | obj_desc->buffer.length); | 943 | obj_desc->buffer.length); |
942 | if (obj_desc->buffer.length) { | 944 | if (obj_desc->buffer.length) { |
943 | acpi_ut_dump_buffer(ACPI_CAST_PTR | 945 | acpi_ut_debug_dump_buffer(ACPI_CAST_PTR |
944 | (u8, obj_desc->buffer.pointer), | 946 | (u8, |
945 | obj_desc->buffer.length, | 947 | obj_desc->buffer.pointer), |
946 | DB_DWORD_DISPLAY, _COMPONENT); | 948 | obj_desc->buffer.length, |
949 | DB_DWORD_DISPLAY, _COMPONENT); | ||
947 | } else { | 950 | } else { |
948 | acpi_os_printf("\n"); | 951 | acpi_os_printf("\n"); |
949 | } | 952 | } |
@@ -996,7 +999,8 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags) | |||
996 | } | 999 | } |
997 | 1000 | ||
998 | if (!flags) { | 1001 | if (!flags) { |
999 | if (!((ACPI_LV_OBJECTS & acpi_dbg_level) | 1002 | if (! |
1003 | ((ACPI_LV_OBJECTS & acpi_dbg_level) | ||
1000 | && (_COMPONENT & acpi_dbg_layer))) { | 1004 | && (_COMPONENT & acpi_dbg_layer))) { |
1001 | return_VOID; | 1005 | return_VOID; |
1002 | } | 1006 | } |
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c index dc092f5b35d6..ebc55fbf3ff7 100644 --- a/drivers/acpi/acpica/exfield.c +++ b/drivers/acpi/acpica/exfield.c | |||
@@ -59,7 +59,7 @@ ACPI_MODULE_NAME("exfield") | |||
59 | * | 59 | * |
60 | * RETURN: Status | 60 | * RETURN: Status |
61 | * | 61 | * |
62 | * DESCRIPTION: Read from a named field. Returns either an Integer or a | 62 | * DESCRIPTION: Read from a named field. Returns either an Integer or a |
63 | * Buffer, depending on the size of the field. | 63 | * Buffer, depending on the size of the field. |
64 | * | 64 | * |
65 | ******************************************************************************/ | 65 | ******************************************************************************/ |
@@ -149,7 +149,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, | |||
149 | * Allocate a buffer for the contents of the field. | 149 | * Allocate a buffer for the contents of the field. |
150 | * | 150 | * |
151 | * If the field is larger than the current integer width, create | 151 | * If the field is larger than the current integer width, create |
152 | * a BUFFER to hold it. Otherwise, use an INTEGER. This allows | 152 | * a BUFFER to hold it. Otherwise, use an INTEGER. This allows |
153 | * the use of arithmetic operators on the returned value if the | 153 | * the use of arithmetic operators on the returned value if the |
154 | * field size is equal or smaller than an Integer. | 154 | * field size is equal or smaller than an Integer. |
155 | * | 155 | * |
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c index a7784152ed30..aa2ccfb7cb61 100644 --- a/drivers/acpi/acpica/exfldio.c +++ b/drivers/acpi/acpica/exfldio.c | |||
@@ -54,8 +54,7 @@ ACPI_MODULE_NAME("exfldio") | |||
54 | /* Local prototypes */ | 54 | /* Local prototypes */ |
55 | static acpi_status | 55 | static acpi_status |
56 | acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, | 56 | acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, |
57 | u32 field_datum_byte_offset, | 57 | u32 field_datum_byte_offset, u64 *value, u32 read_write); |
58 | u64 *value, u32 read_write); | ||
59 | 58 | ||
60 | static u8 | 59 | static u8 |
61 | acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value); | 60 | acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value); |
@@ -155,7 +154,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, | |||
155 | #endif | 154 | #endif |
156 | 155 | ||
157 | /* | 156 | /* |
158 | * Validate the request. The entire request from the byte offset for a | 157 | * Validate the request. The entire request from the byte offset for a |
159 | * length of one field datum (access width) must fit within the region. | 158 | * length of one field datum (access width) must fit within the region. |
160 | * (Region length is specified in bytes) | 159 | * (Region length is specified in bytes) |
161 | */ | 160 | */ |
@@ -183,7 +182,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, | |||
183 | obj_desc->common_field.access_byte_width) { | 182 | obj_desc->common_field.access_byte_width) { |
184 | /* | 183 | /* |
185 | * This is the case where the access_type (acc_word, etc.) is wider | 184 | * This is the case where the access_type (acc_word, etc.) is wider |
186 | * than the region itself. For example, a region of length one | 185 | * than the region itself. For example, a region of length one |
187 | * byte, and a field with Dword access specified. | 186 | * byte, and a field with Dword access specified. |
188 | */ | 187 | */ |
189 | ACPI_ERROR((AE_INFO, | 188 | ACPI_ERROR((AE_INFO, |
@@ -321,7 +320,7 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc, | |||
321 | * | 320 | * |
322 | * DESCRIPTION: Check if a value is out of range of the field being written. | 321 | * DESCRIPTION: Check if a value is out of range of the field being written. |
323 | * Used to check if the values written to Index and Bank registers | 322 | * Used to check if the values written to Index and Bank registers |
324 | * are out of range. Normally, the value is simply truncated | 323 | * are out of range. Normally, the value is simply truncated |
325 | * to fit the field, but this case is most likely a serious | 324 | * to fit the field, but this case is most likely a serious |
326 | * coding error in the ASL. | 325 | * coding error in the ASL. |
327 | * | 326 | * |
@@ -370,7 +369,7 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value) | |||
370 | * | 369 | * |
371 | * RETURN: Status | 370 | * RETURN: Status |
372 | * | 371 | * |
373 | * DESCRIPTION: Read or Write a single datum of a field. The field_type is | 372 | * DESCRIPTION: Read or Write a single datum of a field. The field_type is |
374 | * demultiplexed here to handle the different types of fields | 373 | * demultiplexed here to handle the different types of fields |
375 | * (buffer_field, region_field, index_field, bank_field) | 374 | * (buffer_field, region_field, index_field, bank_field) |
376 | * | 375 | * |
@@ -860,7 +859,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, | |||
860 | ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length); | 859 | ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length); |
861 | /* | 860 | /* |
862 | * We must have a buffer that is at least as long as the field | 861 | * We must have a buffer that is at least as long as the field |
863 | * we are writing to. This is because individual fields are | 862 | * we are writing to. This is because individual fields are |
864 | * indivisible and partial writes are not supported -- as per | 863 | * indivisible and partial writes are not supported -- as per |
865 | * the ACPI specification. | 864 | * the ACPI specification. |
866 | */ | 865 | */ |
@@ -875,7 +874,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, | |||
875 | 874 | ||
876 | /* | 875 | /* |
877 | * Copy the original data to the new buffer, starting | 876 | * Copy the original data to the new buffer, starting |
878 | * at Byte zero. All unused (upper) bytes of the | 877 | * at Byte zero. All unused (upper) bytes of the |
879 | * buffer will be 0. | 878 | * buffer will be 0. |
880 | */ | 879 | */ |
881 | ACPI_MEMCPY((char *)new_buffer, (char *)buffer, buffer_length); | 880 | ACPI_MEMCPY((char *)new_buffer, (char *)buffer, buffer_length); |
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c index 271c0c57ea10..84058705ed12 100644 --- a/drivers/acpi/acpica/exmisc.c +++ b/drivers/acpi/acpica/exmisc.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes | 3 | * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes |
@@ -254,7 +253,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, | |||
254 | ACPI_FUNCTION_TRACE(ex_do_concatenate); | 253 | ACPI_FUNCTION_TRACE(ex_do_concatenate); |
255 | 254 | ||
256 | /* | 255 | /* |
257 | * Convert the second operand if necessary. The first operand | 256 | * Convert the second operand if necessary. The first operand |
258 | * determines the type of the second operand, (See the Data Types | 257 | * determines the type of the second operand, (See the Data Types |
259 | * section of the ACPI specification.) Both object types are | 258 | * section of the ACPI specification.) Both object types are |
260 | * guaranteed to be either Integer/String/Buffer by the operand | 259 | * guaranteed to be either Integer/String/Buffer by the operand |
@@ -573,7 +572,7 @@ acpi_ex_do_logical_op(u16 opcode, | |||
573 | ACPI_FUNCTION_TRACE(ex_do_logical_op); | 572 | ACPI_FUNCTION_TRACE(ex_do_logical_op); |
574 | 573 | ||
575 | /* | 574 | /* |
576 | * Convert the second operand if necessary. The first operand | 575 | * Convert the second operand if necessary. The first operand |
577 | * determines the type of the second operand, (See the Data Types | 576 | * determines the type of the second operand, (See the Data Types |
578 | * section of the ACPI 3.0+ specification.) Both object types are | 577 | * section of the ACPI 3.0+ specification.) Both object types are |
579 | * guaranteed to be either Integer/String/Buffer by the operand | 578 | * guaranteed to be either Integer/String/Buffer by the operand |
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c index bcceda5be9e3..d1f449d93dcf 100644 --- a/drivers/acpi/acpica/exmutex.c +++ b/drivers/acpi/acpica/exmutex.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exmutex - ASL Mutex Acquire/Release functions | 3 | * Module Name: exmutex - ASL Mutex Acquire/Release functions |
@@ -305,7 +304,7 @@ acpi_status acpi_ex_release_mutex_object(union acpi_operand_object *obj_desc) | |||
305 | ACPI_FUNCTION_TRACE(ex_release_mutex_object); | 304 | ACPI_FUNCTION_TRACE(ex_release_mutex_object); |
306 | 305 | ||
307 | if (obj_desc->mutex.acquisition_depth == 0) { | 306 | if (obj_desc->mutex.acquisition_depth == 0) { |
308 | return (AE_NOT_ACQUIRED); | 307 | return_ACPI_STATUS(AE_NOT_ACQUIRED); |
309 | } | 308 | } |
310 | 309 | ||
311 | /* Match multiple Acquires with multiple Releases */ | 310 | /* Match multiple Acquires with multiple Releases */ |
@@ -462,7 +461,7 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread) | |||
462 | union acpi_operand_object *next = thread->acquired_mutex_list; | 461 | union acpi_operand_object *next = thread->acquired_mutex_list; |
463 | union acpi_operand_object *obj_desc; | 462 | union acpi_operand_object *obj_desc; |
464 | 463 | ||
465 | ACPI_FUNCTION_ENTRY(); | 464 | ACPI_FUNCTION_NAME(ex_release_all_mutexes); |
466 | 465 | ||
467 | /* Traverse the list of owned mutexes, releasing each one */ | 466 | /* Traverse the list of owned mutexes, releasing each one */ |
468 | 467 | ||
@@ -474,6 +473,10 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread) | |||
474 | obj_desc->mutex.next = NULL; | 473 | obj_desc->mutex.next = NULL; |
475 | obj_desc->mutex.acquisition_depth = 0; | 474 | obj_desc->mutex.acquisition_depth = 0; |
476 | 475 | ||
476 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
477 | "Force-releasing held mutex: %p\n", | ||
478 | obj_desc)); | ||
479 | |||
477 | /* Release the mutex, special case for Global Lock */ | 480 | /* Release the mutex, special case for Global Lock */ |
478 | 481 | ||
479 | if (obj_desc == acpi_gbl_global_lock_mutex) { | 482 | if (obj_desc == acpi_gbl_global_lock_mutex) { |
diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c index fcc75fa27d32..2ff578a16adc 100644 --- a/drivers/acpi/acpica/exnames.c +++ b/drivers/acpi/acpica/exnames.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exnames - interpreter/scanner name load/execute | 3 | * Module Name: exnames - interpreter/scanner name load/execute |
@@ -53,8 +52,7 @@ ACPI_MODULE_NAME("exnames") | |||
53 | /* Local prototypes */ | 52 | /* Local prototypes */ |
54 | static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs); | 53 | static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs); |
55 | 54 | ||
56 | static acpi_status | 55 | static acpi_status acpi_ex_name_segment(u8 **in_aml_address, char *name_string); |
57 | acpi_ex_name_segment(u8 ** in_aml_address, char *name_string); | ||
58 | 56 | ||
59 | /******************************************************************************* | 57 | /******************************************************************************* |
60 | * | 58 | * |
@@ -64,7 +62,7 @@ acpi_ex_name_segment(u8 ** in_aml_address, char *name_string); | |||
64 | * (-1)==root, 0==none | 62 | * (-1)==root, 0==none |
65 | * num_name_segs - count of 4-character name segments | 63 | * num_name_segs - count of 4-character name segments |
66 | * | 64 | * |
67 | * RETURN: A pointer to the allocated string segment. This segment must | 65 | * RETURN: A pointer to the allocated string segment. This segment must |
68 | * be deleted by the caller. | 66 | * be deleted by the caller. |
69 | * | 67 | * |
70 | * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name | 68 | * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name |
@@ -178,7 +176,8 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) | |||
178 | 176 | ||
179 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n")); | 177 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n")); |
180 | 178 | ||
181 | for (index = 0; (index < ACPI_NAME_SIZE) | 179 | for (index = 0; |
180 | (index < ACPI_NAME_SIZE) | ||
182 | && (acpi_ut_valid_acpi_char(*aml_address, 0)); index++) { | 181 | && (acpi_ut_valid_acpi_char(*aml_address, 0)); index++) { |
183 | char_buf[index] = *aml_address++; | 182 | char_buf[index] = *aml_address++; |
184 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index])); | 183 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index])); |
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c index 9ba8c73cea16..bbf01e9bf057 100644 --- a/drivers/acpi/acpica/exoparg1.c +++ b/drivers/acpi/acpica/exoparg1.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exoparg1 - AML execution - opcodes with 1 argument | 3 | * Module Name: exoparg1 - AML execution - opcodes with 1 argument |
@@ -606,7 +605,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
606 | } | 605 | } |
607 | 606 | ||
608 | /* | 607 | /* |
609 | * Set result to ONES (TRUE) if Value == 0. Note: | 608 | * Set result to ONES (TRUE) if Value == 0. Note: |
610 | * return_desc->Integer.Value is initially == 0 (FALSE) from above. | 609 | * return_desc->Integer.Value is initially == 0 (FALSE) from above. |
611 | */ | 610 | */ |
612 | if (!operand[0]->integer.value) { | 611 | if (!operand[0]->integer.value) { |
@@ -618,7 +617,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
618 | case AML_INCREMENT_OP: /* Increment (Operand) */ | 617 | case AML_INCREMENT_OP: /* Increment (Operand) */ |
619 | 618 | ||
620 | /* | 619 | /* |
621 | * Create a new integer. Can't just get the base integer and | 620 | * Create a new integer. Can't just get the base integer and |
622 | * increment it because it may be an Arg or Field. | 621 | * increment it because it may be an Arg or Field. |
623 | */ | 622 | */ |
624 | return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); | 623 | return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
@@ -686,7 +685,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
686 | 685 | ||
687 | /* | 686 | /* |
688 | * Note: The operand is not resolved at this point because we want to | 687 | * Note: The operand is not resolved at this point because we want to |
689 | * get the associated object, not its value. For example, we don't | 688 | * get the associated object, not its value. For example, we don't |
690 | * want to resolve a field_unit to its value, we want the actual | 689 | * want to resolve a field_unit to its value, we want the actual |
691 | * field_unit object. | 690 | * field_unit object. |
692 | */ | 691 | */ |
@@ -727,7 +726,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
727 | 726 | ||
728 | /* | 727 | /* |
729 | * The type of the base object must be integer, buffer, string, or | 728 | * The type of the base object must be integer, buffer, string, or |
730 | * package. All others are not supported. | 729 | * package. All others are not supported. |
731 | * | 730 | * |
732 | * NOTE: Integer is not specifically supported by the ACPI spec, | 731 | * NOTE: Integer is not specifically supported by the ACPI spec, |
733 | * but is supported implicitly via implicit operand conversion. | 732 | * but is supported implicitly via implicit operand conversion. |
@@ -965,7 +964,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
965 | case ACPI_TYPE_PACKAGE: | 964 | case ACPI_TYPE_PACKAGE: |
966 | 965 | ||
967 | /* | 966 | /* |
968 | * Return the referenced element of the package. We must | 967 | * Return the referenced element of the package. We must |
969 | * add another reference to the referenced object, however. | 968 | * add another reference to the referenced object, however. |
970 | */ | 969 | */ |
971 | return_desc = | 970 | return_desc = |
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c index 879e8a277b94..ee5634a074c4 100644 --- a/drivers/acpi/acpica/exoparg2.c +++ b/drivers/acpi/acpica/exoparg2.c | |||
@@ -123,7 +123,7 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state) | |||
123 | /* | 123 | /* |
124 | * Dispatch the notify to the appropriate handler | 124 | * Dispatch the notify to the appropriate handler |
125 | * NOTE: the request is queued for execution after this method | 125 | * NOTE: the request is queued for execution after this method |
126 | * completes. The notify handlers are NOT invoked synchronously | 126 | * completes. The notify handlers are NOT invoked synchronously |
127 | * from this thread -- because handlers may in turn run other | 127 | * from this thread -- because handlers may in turn run other |
128 | * control methods. | 128 | * control methods. |
129 | */ | 129 | */ |
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c index 71fcc65c9ffa..2c89b4651f08 100644 --- a/drivers/acpi/acpica/exoparg3.c +++ b/drivers/acpi/acpica/exoparg3.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exoparg3 - AML execution - opcodes with 3 arguments | 3 | * Module Name: exoparg3 - AML execution - opcodes with 3 arguments |
@@ -158,7 +157,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) | |||
158 | case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ | 157 | case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ |
159 | 158 | ||
160 | /* | 159 | /* |
161 | * Create the return object. The Source operand is guaranteed to be | 160 | * Create the return object. The Source operand is guaranteed to be |
162 | * either a String or a Buffer, so just use its type. | 161 | * either a String or a Buffer, so just use its type. |
163 | */ | 162 | */ |
164 | return_desc = acpi_ut_create_internal_object((operand[0])-> | 163 | return_desc = acpi_ut_create_internal_object((operand[0])-> |
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c index 0786b8659061..3e08695c3b30 100644 --- a/drivers/acpi/acpica/exoparg6.c +++ b/drivers/acpi/acpica/exoparg6.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exoparg6 - AML execution - opcodes with 6 arguments | 3 | * Module Name: exoparg6 - AML execution - opcodes with 6 arguments |
@@ -198,7 +197,7 @@ acpi_ex_do_match(u32 match_op, | |||
198 | return (FALSE); | 197 | return (FALSE); |
199 | } | 198 | } |
200 | 199 | ||
201 | return logical_result; | 200 | return (logical_result); |
202 | } | 201 | } |
203 | 202 | ||
204 | /******************************************************************************* | 203 | /******************************************************************************* |
@@ -269,7 +268,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) | |||
269 | * and the next should be examined. | 268 | * and the next should be examined. |
270 | * | 269 | * |
271 | * Upon finding a match, the loop will terminate via "break" at | 270 | * Upon finding a match, the loop will terminate via "break" at |
272 | * the bottom. If it terminates "normally", match_value will be | 271 | * the bottom. If it terminates "normally", match_value will be |
273 | * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no | 272 | * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no |
274 | * match was found. | 273 | * match was found. |
275 | */ | 274 | */ |
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c index 81eca60d2748..ba9db4de7c89 100644 --- a/drivers/acpi/acpica/exprep.c +++ b/drivers/acpi/acpica/exprep.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities | 3 | * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities |
@@ -78,8 +77,8 @@ acpi_ex_generate_access(u32 field_bit_offset, | |||
78 | * any_acc keyword. | 77 | * any_acc keyword. |
79 | * | 78 | * |
80 | * NOTE: Need to have the region_length in order to check for boundary | 79 | * NOTE: Need to have the region_length in order to check for boundary |
81 | * conditions (end-of-region). However, the region_length is a deferred | 80 | * conditions (end-of-region). However, the region_length is a deferred |
82 | * operation. Therefore, to complete this implementation, the generation | 81 | * operation. Therefore, to complete this implementation, the generation |
83 | * of this access width must be deferred until the region length has | 82 | * of this access width must be deferred until the region length has |
84 | * been evaluated. | 83 | * been evaluated. |
85 | * | 84 | * |
@@ -308,7 +307,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, | |||
308 | * RETURN: Status | 307 | * RETURN: Status |
309 | * | 308 | * |
310 | * DESCRIPTION: Initialize the areas of the field object that are common | 309 | * DESCRIPTION: Initialize the areas of the field object that are common |
311 | * to the various types of fields. Note: This is very "sensitive" | 310 | * to the various types of fields. Note: This is very "sensitive" |
312 | * code because we are solving the general case for field | 311 | * code because we are solving the general case for field |
313 | * alignment. | 312 | * alignment. |
314 | * | 313 | * |
@@ -336,13 +335,13 @@ acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc, | |||
336 | obj_desc->common_field.bit_length = field_bit_length; | 335 | obj_desc->common_field.bit_length = field_bit_length; |
337 | 336 | ||
338 | /* | 337 | /* |
339 | * Decode the access type so we can compute offsets. The access type gives | 338 | * Decode the access type so we can compute offsets. The access type gives |
340 | * two pieces of information - the width of each field access and the | 339 | * two pieces of information - the width of each field access and the |
341 | * necessary byte_alignment (address granularity) of the access. | 340 | * necessary byte_alignment (address granularity) of the access. |
342 | * | 341 | * |
343 | * For any_acc, the access_bit_width is the largest width that is both | 342 | * For any_acc, the access_bit_width is the largest width that is both |
344 | * necessary and possible in an attempt to access the whole field in one | 343 | * necessary and possible in an attempt to access the whole field in one |
345 | * I/O operation. However, for any_acc, the byte_alignment is always one | 344 | * I/O operation. However, for any_acc, the byte_alignment is always one |
346 | * byte. | 345 | * byte. |
347 | * | 346 | * |
348 | * For all Buffer Fields, the byte_alignment is always one byte. | 347 | * For all Buffer Fields, the byte_alignment is always one byte. |
@@ -363,7 +362,7 @@ acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc, | |||
363 | 362 | ||
364 | /* | 363 | /* |
365 | * base_byte_offset is the address of the start of the field within the | 364 | * base_byte_offset is the address of the start of the field within the |
366 | * region. It is the byte address of the first *datum* (field-width data | 365 | * region. It is the byte address of the first *datum* (field-width data |
367 | * unit) of the field. (i.e., the first datum that contains at least the | 366 | * unit) of the field. (i.e., the first datum that contains at least the |
368 | * first *bit* of the field.) | 367 | * first *bit* of the field.) |
369 | * | 368 | * |
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c index 1f1ce0c3d2f8..1db2c0bfde0b 100644 --- a/drivers/acpi/acpica/exregion.c +++ b/drivers/acpi/acpica/exregion.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exregion - ACPI default op_region (address space) handlers | 3 | * Module Name: exregion - ACPI default op_region (address space) handlers |
@@ -202,7 +201,7 @@ acpi_ex_system_memory_space_handler(u32 function, | |||
202 | * Perform the memory read or write | 201 | * Perform the memory read or write |
203 | * | 202 | * |
204 | * Note: For machines that do not support non-aligned transfers, the target | 203 | * Note: For machines that do not support non-aligned transfers, the target |
205 | * address was checked for alignment above. We do not attempt to break the | 204 | * address was checked for alignment above. We do not attempt to break the |
206 | * transfer up into smaller (byte-size) chunks because the AML specifically | 205 | * transfer up into smaller (byte-size) chunks because the AML specifically |
207 | * asked for a transfer width that the hardware may require. | 206 | * asked for a transfer width that the hardware may require. |
208 | */ | 207 | */ |
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c index fa50e77e64a8..6239956786eb 100644 --- a/drivers/acpi/acpica/exresnte.c +++ b/drivers/acpi/acpica/exresnte.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exresnte - AML Interpreter object resolution | 3 | * Module Name: exresnte - AML Interpreter object resolution |
@@ -58,8 +57,8 @@ ACPI_MODULE_NAME("exresnte") | |||
58 | * PARAMETERS: object_ptr - Pointer to a location that contains | 57 | * PARAMETERS: object_ptr - Pointer to a location that contains |
59 | * a pointer to a NS node, and will receive a | 58 | * a pointer to a NS node, and will receive a |
60 | * pointer to the resolved object. | 59 | * pointer to the resolved object. |
61 | * walk_state - Current state. Valid only if executing AML | 60 | * walk_state - Current state. Valid only if executing AML |
62 | * code. NULL if simply resolving an object | 61 | * code. NULL if simply resolving an object |
63 | * | 62 | * |
64 | * RETURN: Status | 63 | * RETURN: Status |
65 | * | 64 | * |
@@ -67,7 +66,7 @@ ACPI_MODULE_NAME("exresnte") | |||
67 | * | 66 | * |
68 | * Note: for some of the data types, the pointer attached to the Node | 67 | * Note: for some of the data types, the pointer attached to the Node |
69 | * can be either a pointer to an actual internal object or a pointer into the | 68 | * can be either a pointer to an actual internal object or a pointer into the |
70 | * AML stream itself. These types are currently: | 69 | * AML stream itself. These types are currently: |
71 | * | 70 | * |
72 | * ACPI_TYPE_INTEGER | 71 | * ACPI_TYPE_INTEGER |
73 | * ACPI_TYPE_STRING | 72 | * ACPI_TYPE_STRING |
@@ -89,7 +88,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, | |||
89 | ACPI_FUNCTION_TRACE(ex_resolve_node_to_value); | 88 | ACPI_FUNCTION_TRACE(ex_resolve_node_to_value); |
90 | 89 | ||
91 | /* | 90 | /* |
92 | * The stack pointer points to a struct acpi_namespace_node (Node). Get the | 91 | * The stack pointer points to a struct acpi_namespace_node (Node). Get the |
93 | * object that is attached to the Node. | 92 | * object that is attached to the Node. |
94 | */ | 93 | */ |
95 | node = *object_ptr; | 94 | node = *object_ptr; |
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c index bbf40ac27585..cc176b245e22 100644 --- a/drivers/acpi/acpica/exresolv.c +++ b/drivers/acpi/acpica/exresolv.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exresolv - AML Interpreter object resolution | 3 | * Module Name: exresolv - AML Interpreter object resolution |
@@ -327,7 +326,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, | |||
327 | * | 326 | * |
328 | * RETURN: Status | 327 | * RETURN: Status |
329 | * | 328 | * |
330 | * DESCRIPTION: Return the base object and type. Traverse a reference list if | 329 | * DESCRIPTION: Return the base object and type. Traverse a reference list if |
331 | * necessary to get to the base object. | 330 | * necessary to get to the base object. |
332 | * | 331 | * |
333 | ******************************************************************************/ | 332 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c index f232fbabdea8..b9ebff2f6a09 100644 --- a/drivers/acpi/acpica/exresop.c +++ b/drivers/acpi/acpica/exresop.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exresop - AML Interpreter operand/object resolution | 3 | * Module Name: exresop - AML Interpreter operand/object resolution |
@@ -87,7 +86,7 @@ acpi_ex_check_object_type(acpi_object_type type_needed, | |||
87 | if (type_needed == ACPI_TYPE_LOCAL_REFERENCE) { | 86 | if (type_needed == ACPI_TYPE_LOCAL_REFERENCE) { |
88 | /* | 87 | /* |
89 | * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference | 88 | * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference |
90 | * objects and thus allow them to be targets. (As per the ACPI | 89 | * objects and thus allow them to be targets. (As per the ACPI |
91 | * specification, a store to a constant is a noop.) | 90 | * specification, a store to a constant is a noop.) |
92 | */ | 91 | */ |
93 | if ((this_type == ACPI_TYPE_INTEGER) && | 92 | if ((this_type == ACPI_TYPE_INTEGER) && |
@@ -337,7 +336,8 @@ acpi_ex_resolve_operands(u16 opcode, | |||
337 | if ((opcode == AML_STORE_OP) && | 336 | if ((opcode == AML_STORE_OP) && |
338 | ((*stack_ptr)->common.type == | 337 | ((*stack_ptr)->common.type == |
339 | ACPI_TYPE_LOCAL_REFERENCE) | 338 | ACPI_TYPE_LOCAL_REFERENCE) |
340 | && ((*stack_ptr)->reference.class == ACPI_REFCLASS_INDEX)) { | 339 | && ((*stack_ptr)->reference.class == |
340 | ACPI_REFCLASS_INDEX)) { | ||
341 | goto next_operand; | 341 | goto next_operand; |
342 | } | 342 | } |
343 | break; | 343 | break; |
@@ -638,7 +638,7 @@ acpi_ex_resolve_operands(u16 opcode, | |||
638 | if (acpi_gbl_enable_interpreter_slack) { | 638 | if (acpi_gbl_enable_interpreter_slack) { |
639 | /* | 639 | /* |
640 | * Enable original behavior of Store(), allowing any and all | 640 | * Enable original behavior of Store(), allowing any and all |
641 | * objects as the source operand. The ACPI spec does not | 641 | * objects as the source operand. The ACPI spec does not |
642 | * allow this, however. | 642 | * allow this, however. |
643 | */ | 643 | */ |
644 | break; | 644 | break; |
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c index 5fffe7ab5ece..90431f12f831 100644 --- a/drivers/acpi/acpica/exstore.c +++ b/drivers/acpi/acpica/exstore.c | |||
@@ -374,7 +374,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, | |||
374 | * with the input value. | 374 | * with the input value. |
375 | * | 375 | * |
376 | * When storing into an object the data is converted to the | 376 | * When storing into an object the data is converted to the |
377 | * target object type then stored in the object. This means | 377 | * target object type then stored in the object. This means |
378 | * that the target object type (for an initialized target) will | 378 | * that the target object type (for an initialized target) will |
379 | * not be changed by a store operation. | 379 | * not be changed by a store operation. |
380 | * | 380 | * |
@@ -491,7 +491,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc, | |||
491 | acpi_ut_get_object_type_name(source_desc), | 491 | acpi_ut_get_object_type_name(source_desc), |
492 | source_desc, node)); | 492 | source_desc, node)); |
493 | 493 | ||
494 | /* No conversions for all other types. Just attach the source object */ | 494 | /* No conversions for all other types. Just attach the source object */ |
495 | 495 | ||
496 | status = acpi_ns_attach_object(node, source_desc, | 496 | status = acpi_ns_attach_object(node, source_desc, |
497 | source_desc->common.type); | 497 | source_desc->common.type); |
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c index b35bed52e061..87153bbc4b43 100644 --- a/drivers/acpi/acpica/exstoren.c +++ b/drivers/acpi/acpica/exstoren.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exstoren - AML Interpreter object store support, | 3 | * Module Name: exstoren - AML Interpreter object store support, |
@@ -61,7 +60,7 @@ ACPI_MODULE_NAME("exstoren") | |||
61 | * | 60 | * |
62 | * RETURN: Status, resolved object in source_desc_ptr. | 61 | * RETURN: Status, resolved object in source_desc_ptr. |
63 | * | 62 | * |
64 | * DESCRIPTION: Resolve an object. If the object is a reference, dereference | 63 | * DESCRIPTION: Resolve an object. If the object is a reference, dereference |
65 | * it and return the actual object in the source_desc_ptr. | 64 | * it and return the actual object in the source_desc_ptr. |
66 | * | 65 | * |
67 | ******************************************************************************/ | 66 | ******************************************************************************/ |
@@ -93,7 +92,7 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, | |||
93 | 92 | ||
94 | /* | 93 | /* |
95 | * Stores into a Field/Region or into a Integer/Buffer/String | 94 | * Stores into a Field/Region or into a Integer/Buffer/String |
96 | * are all essentially the same. This case handles the | 95 | * are all essentially the same. This case handles the |
97 | * "interchangeable" types Integer, String, and Buffer. | 96 | * "interchangeable" types Integer, String, and Buffer. |
98 | */ | 97 | */ |
99 | if (source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) { | 98 | if (source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) { |
@@ -167,7 +166,7 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, | |||
167 | * | 166 | * |
168 | * RETURN: Status | 167 | * RETURN: Status |
169 | * | 168 | * |
170 | * DESCRIPTION: "Store" an object to another object. This may include | 169 | * DESCRIPTION: "Store" an object to another object. This may include |
171 | * converting the source type to the target type (implicit | 170 | * converting the source type to the target type (implicit |
172 | * conversion), and a copy of the value of the source to | 171 | * conversion), and a copy of the value of the source to |
173 | * the target. | 172 | * the target. |
@@ -178,14 +177,14 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, | |||
178 | * with the input value. | 177 | * with the input value. |
179 | * | 178 | * |
180 | * When storing into an object the data is converted to the | 179 | * When storing into an object the data is converted to the |
181 | * target object type then stored in the object. This means | 180 | * target object type then stored in the object. This means |
182 | * that the target object type (for an initialized target) will | 181 | * that the target object type (for an initialized target) will |
183 | * not be changed by a store operation. | 182 | * not be changed by a store operation. |
184 | * | 183 | * |
185 | * This module allows destination types of Number, String, | 184 | * This module allows destination types of Number, String, |
186 | * Buffer, and Package. | 185 | * Buffer, and Package. |
187 | * | 186 | * |
188 | * Assumes parameters are already validated. NOTE: source_desc | 187 | * Assumes parameters are already validated. NOTE: source_desc |
189 | * resolution (from a reference object) must be performed by | 188 | * resolution (from a reference object) must be performed by |
190 | * the caller if necessary. | 189 | * the caller if necessary. |
191 | * | 190 | * |
diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c index 53c248473547..b5f339cb1305 100644 --- a/drivers/acpi/acpica/exstorob.c +++ b/drivers/acpi/acpica/exstorob.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exstorob - AML Interpreter object store support, store to object | 3 | * Module Name: exstorob - AML Interpreter object store support, store to object |
@@ -108,7 +107,7 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc, | |||
108 | #ifdef ACPI_OBSOLETE_BEHAVIOR | 107 | #ifdef ACPI_OBSOLETE_BEHAVIOR |
109 | /* | 108 | /* |
110 | * NOTE: ACPI versions up to 3.0 specified that the buffer must be | 109 | * NOTE: ACPI versions up to 3.0 specified that the buffer must be |
111 | * truncated if the string is smaller than the buffer. However, "other" | 110 | * truncated if the string is smaller than the buffer. However, "other" |
112 | * implementations of ACPI never did this and thus became the defacto | 111 | * implementations of ACPI never did this and thus became the defacto |
113 | * standard. ACPI 3.0A changes this behavior such that the buffer | 112 | * standard. ACPI 3.0A changes this behavior such that the buffer |
114 | * is no longer truncated. | 113 | * is no longer truncated. |
@@ -117,7 +116,7 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc, | |||
117 | /* | 116 | /* |
118 | * OBSOLETE BEHAVIOR: | 117 | * OBSOLETE BEHAVIOR: |
119 | * If the original source was a string, we must truncate the buffer, | 118 | * If the original source was a string, we must truncate the buffer, |
120 | * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer | 119 | * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer |
121 | * copy must not truncate the original buffer. | 120 | * copy must not truncate the original buffer. |
122 | */ | 121 | */ |
123 | if (original_src_type == ACPI_TYPE_STRING) { | 122 | if (original_src_type == ACPI_TYPE_STRING) { |
diff --git a/drivers/acpi/acpica/exsystem.c b/drivers/acpi/acpica/exsystem.c index b760641e2fc6..c8a0ad5c1f55 100644 --- a/drivers/acpi/acpica/exsystem.c +++ b/drivers/acpi/acpica/exsystem.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exsystem - Interface to OS services | 3 | * Module Name: exsystem - Interface to OS services |
@@ -59,7 +58,7 @@ ACPI_MODULE_NAME("exsystem") | |||
59 | * RETURN: Status | 58 | * RETURN: Status |
60 | * | 59 | * |
61 | * DESCRIPTION: Implements a semaphore wait with a check to see if the | 60 | * DESCRIPTION: Implements a semaphore wait with a check to see if the |
62 | * semaphore is available immediately. If it is not, the | 61 | * semaphore is available immediately. If it is not, the |
63 | * interpreter is released before waiting. | 62 | * interpreter is released before waiting. |
64 | * | 63 | * |
65 | ******************************************************************************/ | 64 | ******************************************************************************/ |
@@ -104,7 +103,7 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) | |||
104 | * RETURN: Status | 103 | * RETURN: Status |
105 | * | 104 | * |
106 | * DESCRIPTION: Implements a mutex wait with a check to see if the | 105 | * DESCRIPTION: Implements a mutex wait with a check to see if the |
107 | * mutex is available immediately. If it is not, the | 106 | * mutex is available immediately. If it is not, the |
108 | * interpreter is released before waiting. | 107 | * interpreter is released before waiting. |
109 | * | 108 | * |
110 | ******************************************************************************/ | 109 | ******************************************************************************/ |
@@ -152,7 +151,7 @@ acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout) | |||
152 | * DESCRIPTION: Suspend running thread for specified amount of time. | 151 | * DESCRIPTION: Suspend running thread for specified amount of time. |
153 | * Note: ACPI specification requires that Stall() does not | 152 | * Note: ACPI specification requires that Stall() does not |
154 | * relinquish the processor, and delays longer than 100 usec | 153 | * relinquish the processor, and delays longer than 100 usec |
155 | * should use Sleep() instead. We allow stalls up to 255 usec | 154 | * should use Sleep() instead. We allow stalls up to 255 usec |
156 | * for compatibility with other interpreters and existing BIOSs. | 155 | * for compatibility with other interpreters and existing BIOSs. |
157 | * | 156 | * |
158 | ******************************************************************************/ | 157 | ******************************************************************************/ |
@@ -254,7 +253,7 @@ acpi_status acpi_ex_system_signal_event(union acpi_operand_object * obj_desc) | |||
254 | * RETURN: Status | 253 | * RETURN: Status |
255 | * | 254 | * |
256 | * DESCRIPTION: Provides an access point to perform synchronization operations | 255 | * DESCRIPTION: Provides an access point to perform synchronization operations |
257 | * within the AML. This operation is a request to wait for an | 256 | * within the AML. This operation is a request to wait for an |
258 | * event. | 257 | * event. |
259 | * | 258 | * |
260 | ******************************************************************************/ | 259 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c index d1ab7917eed7..264d22d8018c 100644 --- a/drivers/acpi/acpica/exutils.c +++ b/drivers/acpi/acpica/exutils.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: exutils - interpreter/scanner utilities | 3 | * Module Name: exutils - interpreter/scanner utilities |
@@ -45,12 +44,12 @@ | |||
45 | /* | 44 | /* |
46 | * DEFINE_AML_GLOBALS is tested in amlcode.h | 45 | * DEFINE_AML_GLOBALS is tested in amlcode.h |
47 | * to determine whether certain global names should be "defined" or only | 46 | * to determine whether certain global names should be "defined" or only |
48 | * "declared" in the current compilation. This enhances maintainability | 47 | * "declared" in the current compilation. This enhances maintainability |
49 | * by enabling a single header file to embody all knowledge of the names | 48 | * by enabling a single header file to embody all knowledge of the names |
50 | * in question. | 49 | * in question. |
51 | * | 50 | * |
52 | * Exactly one module of any executable should #define DEFINE_GLOBALS | 51 | * Exactly one module of any executable should #define DEFINE_GLOBALS |
53 | * before #including the header files which use this convention. The | 52 | * before #including the header files which use this convention. The |
54 | * names in question will be defined and initialized in that module, | 53 | * names in question will be defined and initialized in that module, |
55 | * and declared as extern in all other modules which #include those | 54 | * and declared as extern in all other modules which #include those |
56 | * header files. | 55 | * header files. |
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c index a1e71d0ef57b..90a9aea1cee9 100644 --- a/drivers/acpi/acpica/hwacpi.c +++ b/drivers/acpi/acpica/hwacpi.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface | 3 | * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface |
@@ -136,7 +135,7 @@ acpi_status acpi_hw_set_mode(u32 mode) | |||
136 | * | 135 | * |
137 | * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY | 136 | * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY |
138 | * | 137 | * |
139 | * DESCRIPTION: Return current operating state of system. Determined by | 138 | * DESCRIPTION: Return current operating state of system. Determined by |
140 | * querying the SCI_EN bit. | 139 | * querying the SCI_EN bit. |
141 | * | 140 | * |
142 | ******************************************************************************/ | 141 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c index db4076580e2b..64560045052d 100644 --- a/drivers/acpi/acpica/hwgpe.c +++ b/drivers/acpi/acpica/hwgpe.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: hwgpe - Low level GPE enable/disable/clear functions | 3 | * Module Name: hwgpe - Low level GPE enable/disable/clear functions |
@@ -339,7 +338,8 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
339 | 338 | ||
340 | acpi_status | 339 | acpi_status |
341 | acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | 340 | acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
342 | struct acpi_gpe_block_info *gpe_block, void *context) | 341 | struct acpi_gpe_block_info * gpe_block, |
342 | void *context) | ||
343 | { | 343 | { |
344 | u32 i; | 344 | u32 i; |
345 | acpi_status status; | 345 | acpi_status status; |
diff --git a/drivers/acpi/acpica/hwpci.c b/drivers/acpi/acpica/hwpci.c index 1455ddcdc32c..65bc3453a29c 100644 --- a/drivers/acpi/acpica/hwpci.c +++ b/drivers/acpi/acpica/hwpci.c | |||
@@ -259,7 +259,7 @@ acpi_hw_process_pci_list(struct acpi_pci_id *pci_id, | |||
259 | status = acpi_hw_get_pci_device_info(pci_id, info->device, | 259 | status = acpi_hw_get_pci_device_info(pci_id, info->device, |
260 | &bus_number, &is_bridge); | 260 | &bus_number, &is_bridge); |
261 | if (ACPI_FAILURE(status)) { | 261 | if (ACPI_FAILURE(status)) { |
262 | return_ACPI_STATUS(status); | 262 | return (status); |
263 | } | 263 | } |
264 | 264 | ||
265 | info = info->next; | 265 | info = info->next; |
@@ -271,7 +271,7 @@ acpi_hw_process_pci_list(struct acpi_pci_id *pci_id, | |||
271 | pci_id->segment, pci_id->bus, pci_id->device, | 271 | pci_id->segment, pci_id->bus, pci_id->device, |
272 | pci_id->function, status, bus_number, is_bridge)); | 272 | pci_id->function, status, bus_number, is_bridge)); |
273 | 273 | ||
274 | return_ACPI_STATUS(AE_OK); | 274 | return (AE_OK); |
275 | } | 275 | } |
276 | 276 | ||
277 | /******************************************************************************* | 277 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 4af6d20ef077..f4e57503576b 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /******************************************************************************* | 1 | /******************************************************************************* |
3 | * | 2 | * |
4 | * Module Name: hwregs - Read/write access functions for the various ACPI | 3 | * Module Name: hwregs - Read/write access functions for the various ACPI |
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c index b6411f16832f..bfdce22f3798 100644 --- a/drivers/acpi/acpica/hwtimer.c +++ b/drivers/acpi/acpica/hwtimer.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Name: hwtimer.c - ACPI Power Management Timer Interface | 3 | * Name: hwtimer.c - ACPI Power Management Timer Interface |
@@ -101,8 +100,7 @@ acpi_status acpi_get_timer(u32 * ticks) | |||
101 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 100 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
102 | } | 101 | } |
103 | 102 | ||
104 | status = | 103 | status = acpi_hw_read(ticks, &acpi_gbl_FADT.xpm_timer_block); |
105 | acpi_hw_read(ticks, &acpi_gbl_FADT.xpm_timer_block); | ||
106 | 104 | ||
107 | return_ACPI_STATUS(status); | 105 | return_ACPI_STATUS(status); |
108 | } | 106 | } |
@@ -129,7 +127,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_timer) | |||
129 | * a versatile and accurate timer. | 127 | * a versatile and accurate timer. |
130 | * | 128 | * |
131 | * Note that this function accommodates only a single timer | 129 | * Note that this function accommodates only a single timer |
132 | * rollover. Thus for 24-bit timers, this function should only | 130 | * rollover. Thus for 24-bit timers, this function should only |
133 | * be used for calculating durations less than ~4.6 seconds | 131 | * be used for calculating durations less than ~4.6 seconds |
134 | * (~20 minutes for 32-bit timers) -- calculations below: | 132 | * (~20 minutes for 32-bit timers) -- calculations below: |
135 | * | 133 | * |
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c index c99d546b217f..b6aae58299dc 100644 --- a/drivers/acpi/acpica/hwvalid.c +++ b/drivers/acpi/acpica/hwvalid.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: hwvalid - I/O request validation | 3 | * Module Name: hwvalid - I/O request validation |
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index 7bfd649d1996..05a154c3c9ac 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /****************************************************************************** | 1 | /****************************************************************************** |
3 | * | 2 | * |
4 | * Module Name: hwxface - Public ACPICA hardware interfaces | 3 | * Module Name: hwxface - Public ACPICA hardware interfaces |
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c index 0ff1ecea5c3a..ae443fe2ebf6 100644 --- a/drivers/acpi/acpica/hwxfsleep.c +++ b/drivers/acpi/acpica/hwxfsleep.c | |||
@@ -49,8 +49,7 @@ | |||
49 | ACPI_MODULE_NAME("hwxfsleep") | 49 | ACPI_MODULE_NAME("hwxfsleep") |
50 | 50 | ||
51 | /* Local prototypes */ | 51 | /* Local prototypes */ |
52 | static acpi_status | 52 | static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id); |
53 | acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id); | ||
54 | 53 | ||
55 | /* | 54 | /* |
56 | * Dispatch table used to efficiently branch to the various sleep | 55 | * Dispatch table used to efficiently branch to the various sleep |
@@ -234,8 +233,7 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios) | |||
234 | * function. | 233 | * function. |
235 | * | 234 | * |
236 | ******************************************************************************/ | 235 | ******************************************************************************/ |
237 | static acpi_status | 236 | static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id) |
238 | acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id) | ||
239 | { | 237 | { |
240 | acpi_status status; | 238 | acpi_status status; |
241 | struct acpi_sleep_functions *sleep_functions = | 239 | struct acpi_sleep_functions *sleep_functions = |
@@ -369,8 +367,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) | |||
369 | return_ACPI_STATUS(AE_AML_OPERAND_VALUE); | 367 | return_ACPI_STATUS(AE_AML_OPERAND_VALUE); |
370 | } | 368 | } |
371 | 369 | ||
372 | status = | 370 | status = acpi_hw_sleep_dispatch(sleep_state, ACPI_SLEEP_FUNCTION_ID); |
373 | acpi_hw_sleep_dispatch(sleep_state, ACPI_SLEEP_FUNCTION_ID); | ||
374 | return_ACPI_STATUS(status); | 371 | return_ACPI_STATUS(status); |
375 | } | 372 | } |
376 | 373 | ||
@@ -396,8 +393,7 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) | |||
396 | ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); | 393 | ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); |
397 | 394 | ||
398 | status = | 395 | status = |
399 | acpi_hw_sleep_dispatch(sleep_state, | 396 | acpi_hw_sleep_dispatch(sleep_state, ACPI_WAKE_PREP_FUNCTION_ID); |
400 | ACPI_WAKE_PREP_FUNCTION_ID); | ||
401 | return_ACPI_STATUS(status); | 397 | return_ACPI_STATUS(status); |
402 | } | 398 | } |
403 | 399 | ||
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c index 23db53ce2293..d70eaf39dfdf 100644 --- a/drivers/acpi/acpica/nsaccess.c +++ b/drivers/acpi/acpica/nsaccess.c | |||
@@ -110,11 +110,11 @@ acpi_status acpi_ns_root_initialize(void) | |||
110 | status = acpi_ns_lookup(NULL, init_val->name, init_val->type, | 110 | status = acpi_ns_lookup(NULL, init_val->name, init_val->type, |
111 | ACPI_IMODE_LOAD_PASS2, | 111 | ACPI_IMODE_LOAD_PASS2, |
112 | ACPI_NS_NO_UPSEARCH, NULL, &new_node); | 112 | ACPI_NS_NO_UPSEARCH, NULL, &new_node); |
113 | 113 | if (ACPI_FAILURE(status)) { | |
114 | if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */ | ||
115 | ACPI_EXCEPTION((AE_INFO, status, | 114 | ACPI_EXCEPTION((AE_INFO, status, |
116 | "Could not create predefined name %s", | 115 | "Could not create predefined name %s", |
117 | init_val->name)); | 116 | init_val->name)); |
117 | continue; | ||
118 | } | 118 | } |
119 | 119 | ||
120 | /* | 120 | /* |
@@ -179,8 +179,7 @@ acpi_status acpi_ns_root_initialize(void) | |||
179 | 179 | ||
180 | /* Build an object around the static string */ | 180 | /* Build an object around the static string */ |
181 | 181 | ||
182 | obj_desc->string.length = | 182 | obj_desc->string.length = (u32)ACPI_STRLEN(val); |
183 | (u32) ACPI_STRLEN(val); | ||
184 | obj_desc->string.pointer = val; | 183 | obj_desc->string.pointer = val; |
185 | obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; | 184 | obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; |
186 | break; | 185 | break; |
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c index ac389e5bb594..15143c44f5e5 100644 --- a/drivers/acpi/acpica/nsalloc.c +++ b/drivers/acpi/acpica/nsalloc.c | |||
@@ -332,7 +332,7 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) | |||
332 | * | 332 | * |
333 | * RETURN: None. | 333 | * RETURN: None. |
334 | * | 334 | * |
335 | * DESCRIPTION: Delete a subtree of the namespace. This includes all objects | 335 | * DESCRIPTION: Delete a subtree of the namespace. This includes all objects |
336 | * stored within the subtree. | 336 | * stored within the subtree. |
337 | * | 337 | * |
338 | ******************************************************************************/ | 338 | ******************************************************************************/ |
@@ -418,7 +418,7 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node) | |||
418 | * RETURN: Status | 418 | * RETURN: Status |
419 | * | 419 | * |
420 | * DESCRIPTION: Delete entries within the namespace that are owned by a | 420 | * DESCRIPTION: Delete entries within the namespace that are owned by a |
421 | * specific ID. Used to delete entire ACPI tables. All | 421 | * specific ID. Used to delete entire ACPI tables. All |
422 | * reference counts are updated. | 422 | * reference counts are updated. |
423 | * | 423 | * |
424 | * MUTEX: Locks namespace during deletion walk. | 424 | * MUTEX: Locks namespace during deletion walk. |
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c index 2526aaf945ee..924b3c71473a 100644 --- a/drivers/acpi/acpica/nsdump.c +++ b/drivers/acpi/acpica/nsdump.c | |||
@@ -209,14 +209,6 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, | |||
209 | "Invalid ACPI Object Type 0x%08X", type)); | 209 | "Invalid ACPI Object Type 0x%08X", type)); |
210 | } | 210 | } |
211 | 211 | ||
212 | if (!acpi_ut_valid_acpi_name(this_node->name.integer)) { | ||
213 | this_node->name.integer = | ||
214 | acpi_ut_repair_name(this_node->name.ascii); | ||
215 | |||
216 | ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X", | ||
217 | this_node->name.integer)); | ||
218 | } | ||
219 | |||
220 | acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); | 212 | acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); |
221 | } | 213 | } |
222 | 214 | ||
@@ -700,7 +692,7 @@ void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level) | |||
700 | * | 692 | * |
701 | * PARAMETERS: search_base - Root of subtree to be dumped, or | 693 | * PARAMETERS: search_base - Root of subtree to be dumped, or |
702 | * NS_ALL to dump the entire namespace | 694 | * NS_ALL to dump the entire namespace |
703 | * max_depth - Maximum depth of dump. Use INT_MAX | 695 | * max_depth - Maximum depth of dump. Use INT_MAX |
704 | * for an effectively unlimited depth. | 696 | * for an effectively unlimited depth. |
705 | * | 697 | * |
706 | * RETURN: None | 698 | * RETURN: None |
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c index 95ffe8dfa1f1..4328e2adfeb9 100644 --- a/drivers/acpi/acpica/nsinit.c +++ b/drivers/acpi/acpica/nsinit.c | |||
@@ -96,8 +96,8 @@ acpi_status acpi_ns_initialize_objects(void) | |||
96 | /* Walk entire namespace from the supplied root */ | 96 | /* Walk entire namespace from the supplied root */ |
97 | 97 | ||
98 | status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, | 98 | status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, |
99 | ACPI_UINT32_MAX, acpi_ns_init_one_object, NULL, | 99 | ACPI_UINT32_MAX, acpi_ns_init_one_object, |
100 | &info, NULL); | 100 | NULL, &info, NULL); |
101 | if (ACPI_FAILURE(status)) { | 101 | if (ACPI_FAILURE(status)) { |
102 | ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); | 102 | ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); |
103 | } | 103 | } |
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c index 76935ff29289..911f99127b99 100644 --- a/drivers/acpi/acpica/nsload.c +++ b/drivers/acpi/acpica/nsload.c | |||
@@ -80,8 +80,8 @@ acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node) | |||
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Parse the table and load the namespace with all named | 82 | * Parse the table and load the namespace with all named |
83 | * objects found within. Control methods are NOT parsed | 83 | * objects found within. Control methods are NOT parsed |
84 | * at this time. In fact, the control methods cannot be | 84 | * at this time. In fact, the control methods cannot be |
85 | * parsed until the entire namespace is loaded, because | 85 | * parsed until the entire namespace is loaded, because |
86 | * if a control method makes a forward reference (call) | 86 | * if a control method makes a forward reference (call) |
87 | * to another control method, we can't continue parsing | 87 | * to another control method, we can't continue parsing |
@@ -122,7 +122,7 @@ acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node) | |||
122 | } | 122 | } |
123 | 123 | ||
124 | /* | 124 | /* |
125 | * Now we can parse the control methods. We always parse | 125 | * Now we can parse the control methods. We always parse |
126 | * them here for a sanity check, and if configured for | 126 | * them here for a sanity check, and if configured for |
127 | * just-in-time parsing, we delete the control method | 127 | * just-in-time parsing, we delete the control method |
128 | * parse trees. | 128 | * parse trees. |
@@ -166,7 +166,7 @@ acpi_status acpi_ns_load_namespace(void) | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /* | 168 | /* |
169 | * Load the namespace. The DSDT is required, | 169 | * Load the namespace. The DSDT is required, |
170 | * but the SSDT and PSDT tables are optional. | 170 | * but the SSDT and PSDT tables are optional. |
171 | */ | 171 | */ |
172 | status = acpi_ns_load_table_by_type(ACPI_TABLE_ID_DSDT); | 172 | status = acpi_ns_load_table_by_type(ACPI_TABLE_ID_DSDT); |
@@ -283,7 +283,7 @@ static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle) | |||
283 | * RETURN: Status | 283 | * RETURN: Status |
284 | * | 284 | * |
285 | * DESCRIPTION: Shrinks the namespace, typically in response to an undocking | 285 | * DESCRIPTION: Shrinks the namespace, typically in response to an undocking |
286 | * event. Deletes an entire subtree starting from (and | 286 | * event. Deletes an entire subtree starting from (and |
287 | * including) the given handle. | 287 | * including) the given handle. |
288 | * | 288 | * |
289 | ******************************************************************************/ | 289 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c index 96e0eb609bb4..55a175eadcc3 100644 --- a/drivers/acpi/acpica/nsnames.c +++ b/drivers/acpi/acpica/nsnames.c | |||
@@ -195,7 +195,7 @@ acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node) | |||
195 | ACPI_ERROR((AE_INFO, | 195 | ACPI_ERROR((AE_INFO, |
196 | "Invalid Namespace Node (%p) while traversing namespace", | 196 | "Invalid Namespace Node (%p) while traversing namespace", |
197 | next_node)); | 197 | next_node)); |
198 | return 0; | 198 | return (0); |
199 | } | 199 | } |
200 | size += ACPI_PATH_SEGMENT_LENGTH; | 200 | size += ACPI_PATH_SEGMENT_LENGTH; |
201 | next_node = next_node->parent; | 201 | next_node = next_node->parent; |
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c index d6c9a3cc6716..e69f7fa2579d 100644 --- a/drivers/acpi/acpica/nsobject.c +++ b/drivers/acpi/acpica/nsobject.c | |||
@@ -61,7 +61,7 @@ ACPI_MODULE_NAME("nsobject") | |||
61 | * RETURN: Status | 61 | * RETURN: Status |
62 | * | 62 | * |
63 | * DESCRIPTION: Record the given object as the value associated with the | 63 | * DESCRIPTION: Record the given object as the value associated with the |
64 | * name whose acpi_handle is passed. If Object is NULL | 64 | * name whose acpi_handle is passed. If Object is NULL |
65 | * and Type is ACPI_TYPE_ANY, set the name as having no value. | 65 | * and Type is ACPI_TYPE_ANY, set the name as having no value. |
66 | * Note: Future may require that the Node->Flags field be passed | 66 | * Note: Future may require that the Node->Flags field be passed |
67 | * as a parameter. | 67 | * as a parameter. |
@@ -133,7 +133,7 @@ acpi_ns_attach_object(struct acpi_namespace_node *node, | |||
133 | ((struct acpi_namespace_node *)object)->object) { | 133 | ((struct acpi_namespace_node *)object)->object) { |
134 | /* | 134 | /* |
135 | * Value passed is a name handle and that name has a | 135 | * Value passed is a name handle and that name has a |
136 | * non-null value. Use that name's value and type. | 136 | * non-null value. Use that name's value and type. |
137 | */ | 137 | */ |
138 | obj_desc = ((struct acpi_namespace_node *)object)->object; | 138 | obj_desc = ((struct acpi_namespace_node *)object)->object; |
139 | object_type = ((struct acpi_namespace_node *)object)->type; | 139 | object_type = ((struct acpi_namespace_node *)object)->type; |
@@ -321,7 +321,7 @@ union acpi_operand_object *acpi_ns_get_secondary_object(union | |||
321 | * | 321 | * |
322 | * RETURN: Status | 322 | * RETURN: Status |
323 | * | 323 | * |
324 | * DESCRIPTION: Low-level attach data. Create and attach a Data object. | 324 | * DESCRIPTION: Low-level attach data. Create and attach a Data object. |
325 | * | 325 | * |
326 | ******************************************************************************/ | 326 | ******************************************************************************/ |
327 | 327 | ||
@@ -377,7 +377,7 @@ acpi_ns_attach_data(struct acpi_namespace_node *node, | |||
377 | * | 377 | * |
378 | * RETURN: Status | 378 | * RETURN: Status |
379 | * | 379 | * |
380 | * DESCRIPTION: Low-level detach data. Delete the data node, but the caller | 380 | * DESCRIPTION: Low-level detach data. Delete the data node, but the caller |
381 | * is responsible for the actual data. | 381 | * is responsible for the actual data. |
382 | * | 382 | * |
383 | ******************************************************************************/ | 383 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c index ec7ba2d3463c..233f756d5cfa 100644 --- a/drivers/acpi/acpica/nsparse.c +++ b/drivers/acpi/acpica/nsparse.c | |||
@@ -168,11 +168,11 @@ acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node) | |||
168 | /* | 168 | /* |
169 | * AML Parse, pass 1 | 169 | * AML Parse, pass 1 |
170 | * | 170 | * |
171 | * In this pass, we load most of the namespace. Control methods | 171 | * In this pass, we load most of the namespace. Control methods |
172 | * are not parsed until later. A parse tree is not created. Instead, | 172 | * are not parsed until later. A parse tree is not created. Instead, |
173 | * each Parser Op subtree is deleted when it is finished. This saves | 173 | * each Parser Op subtree is deleted when it is finished. This saves |
174 | * a great deal of memory, and allows a small cache of parse objects | 174 | * a great deal of memory, and allows a small cache of parse objects |
175 | * to service the entire parse. The second pass of the parse then | 175 | * to service the entire parse. The second pass of the parse then |
176 | * performs another complete parse of the AML. | 176 | * performs another complete parse of the AML. |
177 | */ | 177 | */ |
178 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n")); | 178 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n")); |
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c index 456cc859f869..1d2d8ffc1bc5 100644 --- a/drivers/acpi/acpica/nssearch.c +++ b/drivers/acpi/acpica/nssearch.c | |||
@@ -314,22 +314,7 @@ acpi_ns_search_and_enter(u32 target_name, | |||
314 | * this problem, and we want to be able to enable ACPI support for them, | 314 | * this problem, and we want to be able to enable ACPI support for them, |
315 | * even though there are a few bad names. | 315 | * even though there are a few bad names. |
316 | */ | 316 | */ |
317 | if (!acpi_ut_valid_acpi_name(target_name)) { | 317 | acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name)); |
318 | target_name = | ||
319 | acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name)); | ||
320 | |||
321 | /* Report warning only if in strict mode or debug mode */ | ||
322 | |||
323 | if (!acpi_gbl_enable_interpreter_slack) { | ||
324 | ACPI_WARNING((AE_INFO, | ||
325 | "Found bad character(s) in name, repaired: [%4.4s]\n", | ||
326 | ACPI_CAST_PTR(char, &target_name))); | ||
327 | } else { | ||
328 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
329 | "Found bad character(s) in name, repaired: [%4.4s]\n", | ||
330 | ACPI_CAST_PTR(char, &target_name))); | ||
331 | } | ||
332 | } | ||
333 | 318 | ||
334 | /* Try to find the name in the namespace level specified by the caller */ | 319 | /* Try to find the name in the namespace level specified by the caller */ |
335 | 320 | ||
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c index ef753a41e087..b5b4cb72a8a8 100644 --- a/drivers/acpi/acpica/nsutils.c +++ b/drivers/acpi/acpica/nsutils.c | |||
@@ -530,7 +530,7 @@ acpi_ns_externalize_name(u32 internal_name_length, | |||
530 | ((num_segments > 0) ? (num_segments - 1) : 0) + 1; | 530 | ((num_segments > 0) ? (num_segments - 1) : 0) + 1; |
531 | 531 | ||
532 | /* | 532 | /* |
533 | * Check to see if we're still in bounds. If not, there's a problem | 533 | * Check to see if we're still in bounds. If not, there's a problem |
534 | * with internal_name (invalid format). | 534 | * with internal_name (invalid format). |
535 | */ | 535 | */ |
536 | if (required_length > internal_name_length) { | 536 | if (required_length > internal_name_length) { |
@@ -557,10 +557,14 @@ acpi_ns_externalize_name(u32 internal_name_length, | |||
557 | (*converted_name)[j++] = '.'; | 557 | (*converted_name)[j++] = '.'; |
558 | } | 558 | } |
559 | 559 | ||
560 | (*converted_name)[j++] = internal_name[names_index++]; | 560 | /* Copy and validate the 4-char name segment */ |
561 | (*converted_name)[j++] = internal_name[names_index++]; | 561 | |
562 | (*converted_name)[j++] = internal_name[names_index++]; | 562 | ACPI_MOVE_NAME(&(*converted_name)[j], |
563 | (*converted_name)[j++] = internal_name[names_index++]; | 563 | &internal_name[names_index]); |
564 | acpi_ut_repair_name(&(*converted_name)[j]); | ||
565 | |||
566 | j += ACPI_NAME_SIZE; | ||
567 | names_index += ACPI_NAME_SIZE; | ||
564 | } | 568 | } |
565 | } | 569 | } |
566 | 570 | ||
@@ -681,7 +685,7 @@ u32 acpi_ns_opens_scope(acpi_object_type type) | |||
681 | * \ (backslash) and ^ (carat) prefixes, and the | 685 | * \ (backslash) and ^ (carat) prefixes, and the |
682 | * . (period) to separate segments are supported. | 686 | * . (period) to separate segments are supported. |
683 | * prefix_node - Root of subtree to be searched, or NS_ALL for the | 687 | * prefix_node - Root of subtree to be searched, or NS_ALL for the |
684 | * root of the name space. If Name is fully | 688 | * root of the name space. If Name is fully |
685 | * qualified (first s8 is '\'), the passed value | 689 | * qualified (first s8 is '\'), the passed value |
686 | * of Scope will not be accessed. | 690 | * of Scope will not be accessed. |
687 | * flags - Used to indicate whether to perform upsearch or | 691 | * flags - Used to indicate whether to perform upsearch or |
@@ -689,7 +693,7 @@ u32 acpi_ns_opens_scope(acpi_object_type type) | |||
689 | * return_node - Where the Node is returned | 693 | * return_node - Where the Node is returned |
690 | * | 694 | * |
691 | * DESCRIPTION: Look up a name relative to a given scope and return the | 695 | * DESCRIPTION: Look up a name relative to a given scope and return the |
692 | * corresponding Node. NOTE: Scope can be null. | 696 | * corresponding Node. NOTE: Scope can be null. |
693 | * | 697 | * |
694 | * MUTEX: Locks namespace | 698 | * MUTEX: Locks namespace |
695 | * | 699 | * |
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c index 730bccc5e7f7..0483877f26b8 100644 --- a/drivers/acpi/acpica/nswalk.c +++ b/drivers/acpi/acpica/nswalk.c | |||
@@ -60,8 +60,8 @@ ACPI_MODULE_NAME("nswalk") | |||
60 | * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if | 60 | * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if |
61 | * none is found. | 61 | * none is found. |
62 | * | 62 | * |
63 | * DESCRIPTION: Return the next peer node within the namespace. If Handle | 63 | * DESCRIPTION: Return the next peer node within the namespace. If Handle |
64 | * is valid, Scope is ignored. Otherwise, the first node | 64 | * is valid, Scope is ignored. Otherwise, the first node |
65 | * within Scope is returned. | 65 | * within Scope is returned. |
66 | * | 66 | * |
67 | ******************************************************************************/ | 67 | ******************************************************************************/ |
@@ -97,8 +97,8 @@ struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node | |||
97 | * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if | 97 | * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if |
98 | * none is found. | 98 | * none is found. |
99 | * | 99 | * |
100 | * DESCRIPTION: Return the next peer node within the namespace. If Handle | 100 | * DESCRIPTION: Return the next peer node within the namespace. If Handle |
101 | * is valid, Scope is ignored. Otherwise, the first node | 101 | * is valid, Scope is ignored. Otherwise, the first node |
102 | * within Scope is returned. | 102 | * within Scope is returned. |
103 | * | 103 | * |
104 | ******************************************************************************/ | 104 | ******************************************************************************/ |
@@ -305,7 +305,7 @@ acpi_ns_walk_namespace(acpi_object_type type, | |||
305 | 305 | ||
306 | /* | 306 | /* |
307 | * Depth first search: Attempt to go down another level in the | 307 | * Depth first search: Attempt to go down another level in the |
308 | * namespace if we are allowed to. Don't go any further if we have | 308 | * namespace if we are allowed to. Don't go any further if we have |
309 | * reached the caller specified maximum depth or if the user | 309 | * reached the caller specified maximum depth or if the user |
310 | * function has specified that the maximum depth has been reached. | 310 | * function has specified that the maximum depth has been reached. |
311 | */ | 311 | */ |
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index 9692e6702333..d6a9f77972b6 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c | |||
@@ -61,16 +61,16 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info); | |||
61 | * PARAMETERS: handle - Object handle (optional) | 61 | * PARAMETERS: handle - Object handle (optional) |
62 | * pathname - Object pathname (optional) | 62 | * pathname - Object pathname (optional) |
63 | * external_params - List of parameters to pass to method, | 63 | * external_params - List of parameters to pass to method, |
64 | * terminated by NULL. May be NULL | 64 | * terminated by NULL. May be NULL |
65 | * if no parameters are being passed. | 65 | * if no parameters are being passed. |
66 | * return_buffer - Where to put method's return value (if | 66 | * return_buffer - Where to put method's return value (if |
67 | * any). If NULL, no value is returned. | 67 | * any). If NULL, no value is returned. |
68 | * return_type - Expected type of return object | 68 | * return_type - Expected type of return object |
69 | * | 69 | * |
70 | * RETURN: Status | 70 | * RETURN: Status |
71 | * | 71 | * |
72 | * DESCRIPTION: Find and evaluate the given object, passing the given | 72 | * DESCRIPTION: Find and evaluate the given object, passing the given |
73 | * parameters if necessary. One of "Handle" or "Pathname" must | 73 | * parameters if necessary. One of "Handle" or "Pathname" must |
74 | * be valid (non-null) | 74 | * be valid (non-null) |
75 | * | 75 | * |
76 | ******************************************************************************/ | 76 | ******************************************************************************/ |
@@ -155,15 +155,15 @@ ACPI_EXPORT_SYMBOL(acpi_evaluate_object_typed) | |||
155 | * PARAMETERS: handle - Object handle (optional) | 155 | * PARAMETERS: handle - Object handle (optional) |
156 | * pathname - Object pathname (optional) | 156 | * pathname - Object pathname (optional) |
157 | * external_params - List of parameters to pass to method, | 157 | * external_params - List of parameters to pass to method, |
158 | * terminated by NULL. May be NULL | 158 | * terminated by NULL. May be NULL |
159 | * if no parameters are being passed. | 159 | * if no parameters are being passed. |
160 | * return_buffer - Where to put method's return value (if | 160 | * return_buffer - Where to put method's return value (if |
161 | * any). If NULL, no value is returned. | 161 | * any). If NULL, no value is returned. |
162 | * | 162 | * |
163 | * RETURN: Status | 163 | * RETURN: Status |
164 | * | 164 | * |
165 | * DESCRIPTION: Find and evaluate the given object, passing the given | 165 | * DESCRIPTION: Find and evaluate the given object, passing the given |
166 | * parameters if necessary. One of "Handle" or "Pathname" must | 166 | * parameters if necessary. One of "Handle" or "Pathname" must |
167 | * be valid (non-null) | 167 | * be valid (non-null) |
168 | * | 168 | * |
169 | ******************************************************************************/ | 169 | ******************************************************************************/ |
@@ -542,15 +542,15 @@ acpi_ns_get_device_callback(acpi_handle obj_handle, | |||
542 | acpi_status status; | 542 | acpi_status status; |
543 | struct acpi_namespace_node *node; | 543 | struct acpi_namespace_node *node; |
544 | u32 flags; | 544 | u32 flags; |
545 | struct acpica_device_id *hid; | 545 | struct acpi_pnp_device_id *hid; |
546 | struct acpica_device_id_list *cid; | 546 | struct acpi_pnp_device_id_list *cid; |
547 | u32 i; | 547 | u32 i; |
548 | u8 found; | 548 | u8 found; |
549 | int no_match; | 549 | int no_match; |
550 | 550 | ||
551 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | 551 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
552 | if (ACPI_FAILURE(status)) { | 552 | if (ACPI_FAILURE(status)) { |
553 | return (status); | 553 | return_ACPI_STATUS(status); |
554 | } | 554 | } |
555 | 555 | ||
556 | node = acpi_ns_validate_handle(obj_handle); | 556 | node = acpi_ns_validate_handle(obj_handle); |
@@ -656,7 +656,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle, | |||
656 | * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, | 656 | * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, |
657 | * starting (and ending) at the object specified by start_handle. | 657 | * starting (and ending) at the object specified by start_handle. |
658 | * The user_function is called whenever an object of type | 658 | * The user_function is called whenever an object of type |
659 | * Device is found. If the user function returns | 659 | * Device is found. If the user function returns |
660 | * a non-zero value, the search is terminated immediately and this | 660 | * a non-zero value, the search is terminated immediately and this |
661 | * value is returned to the caller. | 661 | * value is returned to the caller. |
662 | * | 662 | * |
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c index 08e9610b34ca..811c6f13f476 100644 --- a/drivers/acpi/acpica/nsxfname.c +++ b/drivers/acpi/acpica/nsxfname.c | |||
@@ -53,8 +53,8 @@ | |||
53 | ACPI_MODULE_NAME("nsxfname") | 53 | ACPI_MODULE_NAME("nsxfname") |
54 | 54 | ||
55 | /* Local prototypes */ | 55 | /* Local prototypes */ |
56 | static char *acpi_ns_copy_device_id(struct acpica_device_id *dest, | 56 | static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, |
57 | struct acpica_device_id *source, | 57 | struct acpi_pnp_device_id *source, |
58 | char *string_area); | 58 | char *string_area); |
59 | 59 | ||
60 | /****************************************************************************** | 60 | /****************************************************************************** |
@@ -69,8 +69,8 @@ static char *acpi_ns_copy_device_id(struct acpica_device_id *dest, | |||
69 | * RETURN: Status | 69 | * RETURN: Status |
70 | * | 70 | * |
71 | * DESCRIPTION: This routine will search for a caller specified name in the | 71 | * DESCRIPTION: This routine will search for a caller specified name in the |
72 | * name space. The caller can restrict the search region by | 72 | * name space. The caller can restrict the search region by |
73 | * specifying a non NULL parent. The parent value is itself a | 73 | * specifying a non NULL parent. The parent value is itself a |
74 | * namespace handle. | 74 | * namespace handle. |
75 | * | 75 | * |
76 | ******************************************************************************/ | 76 | ******************************************************************************/ |
@@ -149,7 +149,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_handle) | |||
149 | * RETURN: Pointer to a string containing the fully qualified Name. | 149 | * RETURN: Pointer to a string containing the fully qualified Name. |
150 | * | 150 | * |
151 | * DESCRIPTION: This routine returns the fully qualified name associated with | 151 | * DESCRIPTION: This routine returns the fully qualified name associated with |
152 | * the Handle parameter. This and the acpi_pathname_to_handle are | 152 | * the Handle parameter. This and the acpi_pathname_to_handle are |
153 | * complementary functions. | 153 | * complementary functions. |
154 | * | 154 | * |
155 | ******************************************************************************/ | 155 | ******************************************************************************/ |
@@ -202,8 +202,7 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer) | |||
202 | 202 | ||
203 | /* Just copy the ACPI name from the Node and zero terminate it */ | 203 | /* Just copy the ACPI name from the Node and zero terminate it */ |
204 | 204 | ||
205 | ACPI_STRNCPY(buffer->pointer, acpi_ut_get_node_name(node), | 205 | ACPI_MOVE_NAME(buffer->pointer, acpi_ut_get_node_name(node)); |
206 | ACPI_NAME_SIZE); | ||
207 | ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0; | 206 | ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0; |
208 | status = AE_OK; | 207 | status = AE_OK; |
209 | 208 | ||
@@ -219,20 +218,21 @@ ACPI_EXPORT_SYMBOL(acpi_get_name) | |||
219 | * | 218 | * |
220 | * FUNCTION: acpi_ns_copy_device_id | 219 | * FUNCTION: acpi_ns_copy_device_id |
221 | * | 220 | * |
222 | * PARAMETERS: dest - Pointer to the destination DEVICE_ID | 221 | * PARAMETERS: dest - Pointer to the destination PNP_DEVICE_ID |
223 | * source - Pointer to the source DEVICE_ID | 222 | * source - Pointer to the source PNP_DEVICE_ID |
224 | * string_area - Pointer to where to copy the dest string | 223 | * string_area - Pointer to where to copy the dest string |
225 | * | 224 | * |
226 | * RETURN: Pointer to the next string area | 225 | * RETURN: Pointer to the next string area |
227 | * | 226 | * |
228 | * DESCRIPTION: Copy a single DEVICE_ID, including the string data. | 227 | * DESCRIPTION: Copy a single PNP_DEVICE_ID, including the string data. |
229 | * | 228 | * |
230 | ******************************************************************************/ | 229 | ******************************************************************************/ |
231 | static char *acpi_ns_copy_device_id(struct acpica_device_id *dest, | 230 | static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, |
232 | struct acpica_device_id *source, | 231 | struct acpi_pnp_device_id *source, |
233 | char *string_area) | 232 | char *string_area) |
234 | { | 233 | { |
235 | /* Create the destination DEVICE_ID */ | 234 | |
235 | /* Create the destination PNP_DEVICE_ID */ | ||
236 | 236 | ||
237 | dest->string = string_area; | 237 | dest->string = string_area; |
238 | dest->length = source->length; | 238 | dest->length = source->length; |
@@ -256,8 +256,8 @@ static char *acpi_ns_copy_device_id(struct acpica_device_id *dest, | |||
256 | * namespace node and possibly by running several standard | 256 | * namespace node and possibly by running several standard |
257 | * control methods (Such as in the case of a device.) | 257 | * control methods (Such as in the case of a device.) |
258 | * | 258 | * |
259 | * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, | 259 | * For Device and Processor objects, run the Device _HID, _UID, _CID, _SUB, |
260 | * _ADR, _sx_w, and _sx_d methods. | 260 | * _STA, _ADR, _sx_w, and _sx_d methods. |
261 | * | 261 | * |
262 | * Note: Allocates the return buffer, must be freed by the caller. | 262 | * Note: Allocates the return buffer, must be freed by the caller. |
263 | * | 263 | * |
@@ -269,9 +269,10 @@ acpi_get_object_info(acpi_handle handle, | |||
269 | { | 269 | { |
270 | struct acpi_namespace_node *node; | 270 | struct acpi_namespace_node *node; |
271 | struct acpi_device_info *info; | 271 | struct acpi_device_info *info; |
272 | struct acpica_device_id_list *cid_list = NULL; | 272 | struct acpi_pnp_device_id_list *cid_list = NULL; |
273 | struct acpica_device_id *hid = NULL; | 273 | struct acpi_pnp_device_id *hid = NULL; |
274 | struct acpica_device_id *uid = NULL; | 274 | struct acpi_pnp_device_id *uid = NULL; |
275 | struct acpi_pnp_device_id *sub = NULL; | ||
275 | char *next_id_string; | 276 | char *next_id_string; |
276 | acpi_object_type type; | 277 | acpi_object_type type; |
277 | acpi_name name; | 278 | acpi_name name; |
@@ -316,7 +317,7 @@ acpi_get_object_info(acpi_handle handle, | |||
316 | if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) { | 317 | if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) { |
317 | /* | 318 | /* |
318 | * Get extra info for ACPI Device/Processor objects only: | 319 | * Get extra info for ACPI Device/Processor objects only: |
319 | * Run the Device _HID, _UID, and _CID methods. | 320 | * Run the Device _HID, _UID, _SUB, and _CID methods. |
320 | * | 321 | * |
321 | * Note: none of these methods are required, so they may or may | 322 | * Note: none of these methods are required, so they may or may |
322 | * not be present for this device. The Info->Valid bitfield is used | 323 | * not be present for this device. The Info->Valid bitfield is used |
@@ -339,6 +340,14 @@ acpi_get_object_info(acpi_handle handle, | |||
339 | valid |= ACPI_VALID_UID; | 340 | valid |= ACPI_VALID_UID; |
340 | } | 341 | } |
341 | 342 | ||
343 | /* Execute the Device._SUB method */ | ||
344 | |||
345 | status = acpi_ut_execute_SUB(node, &sub); | ||
346 | if (ACPI_SUCCESS(status)) { | ||
347 | info_size += sub->length; | ||
348 | valid |= ACPI_VALID_SUB; | ||
349 | } | ||
350 | |||
342 | /* Execute the Device._CID method */ | 351 | /* Execute the Device._CID method */ |
343 | 352 | ||
344 | status = acpi_ut_execute_CID(node, &cid_list); | 353 | status = acpi_ut_execute_CID(node, &cid_list); |
@@ -348,7 +357,7 @@ acpi_get_object_info(acpi_handle handle, | |||
348 | 357 | ||
349 | info_size += | 358 | info_size += |
350 | (cid_list->list_size - | 359 | (cid_list->list_size - |
351 | sizeof(struct acpica_device_id_list)); | 360 | sizeof(struct acpi_pnp_device_id_list)); |
352 | valid |= ACPI_VALID_CID; | 361 | valid |= ACPI_VALID_CID; |
353 | } | 362 | } |
354 | } | 363 | } |
@@ -418,16 +427,17 @@ acpi_get_object_info(acpi_handle handle, | |||
418 | next_id_string = ACPI_CAST_PTR(char, info->compatible_id_list.ids); | 427 | next_id_string = ACPI_CAST_PTR(char, info->compatible_id_list.ids); |
419 | if (cid_list) { | 428 | if (cid_list) { |
420 | 429 | ||
421 | /* Point past the CID DEVICE_ID array */ | 430 | /* Point past the CID PNP_DEVICE_ID array */ |
422 | 431 | ||
423 | next_id_string += | 432 | next_id_string += |
424 | ((acpi_size) cid_list->count * | 433 | ((acpi_size) cid_list->count * |
425 | sizeof(struct acpica_device_id)); | 434 | sizeof(struct acpi_pnp_device_id)); |
426 | } | 435 | } |
427 | 436 | ||
428 | /* | 437 | /* |
429 | * Copy the HID, UID, and CIDs to the return buffer. The variable-length | 438 | * Copy the HID, UID, SUB, and CIDs to the return buffer. |
430 | * strings are copied to the reserved area at the end of the buffer. | 439 | * The variable-length strings are copied to the reserved area |
440 | * at the end of the buffer. | ||
431 | * | 441 | * |
432 | * For HID and CID, check if the ID is a PCI Root Bridge. | 442 | * For HID and CID, check if the ID is a PCI Root Bridge. |
433 | */ | 443 | */ |
@@ -445,6 +455,11 @@ acpi_get_object_info(acpi_handle handle, | |||
445 | uid, next_id_string); | 455 | uid, next_id_string); |
446 | } | 456 | } |
447 | 457 | ||
458 | if (sub) { | ||
459 | next_id_string = acpi_ns_copy_device_id(&info->subsystem_id, | ||
460 | sub, next_id_string); | ||
461 | } | ||
462 | |||
448 | if (cid_list) { | 463 | if (cid_list) { |
449 | info->compatible_id_list.count = cid_list->count; | 464 | info->compatible_id_list.count = cid_list->count; |
450 | info->compatible_id_list.list_size = cid_list->list_size; | 465 | info->compatible_id_list.list_size = cid_list->list_size; |
@@ -481,6 +496,9 @@ acpi_get_object_info(acpi_handle handle, | |||
481 | if (uid) { | 496 | if (uid) { |
482 | ACPI_FREE(uid); | 497 | ACPI_FREE(uid); |
483 | } | 498 | } |
499 | if (sub) { | ||
500 | ACPI_FREE(sub); | ||
501 | } | ||
484 | if (cid_list) { | 502 | if (cid_list) { |
485 | ACPI_FREE(cid_list); | 503 | ACPI_FREE(cid_list); |
486 | } | 504 | } |
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c index 6766fc4f088f..9d029dac6b64 100644 --- a/drivers/acpi/acpica/nsxfobj.c +++ b/drivers/acpi/acpica/nsxfobj.c | |||
@@ -220,8 +220,8 @@ ACPI_EXPORT_SYMBOL(acpi_get_parent) | |||
220 | * | 220 | * |
221 | * RETURN: Status | 221 | * RETURN: Status |
222 | * | 222 | * |
223 | * DESCRIPTION: Return the next peer object within the namespace. If Handle is | 223 | * DESCRIPTION: Return the next peer object within the namespace. If Handle is |
224 | * valid, Scope is ignored. Otherwise, the first object within | 224 | * valid, Scope is ignored. Otherwise, the first object within |
225 | * Scope is returned. | 225 | * Scope is returned. |
226 | * | 226 | * |
227 | ******************************************************************************/ | 227 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c index 844464c4f901..cb79e2d4d743 100644 --- a/drivers/acpi/acpica/psargs.c +++ b/drivers/acpi/acpica/psargs.c | |||
@@ -120,7 +120,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) | |||
120 | * RETURN: Pointer to end-of-package +1 | 120 | * RETURN: Pointer to end-of-package +1 |
121 | * | 121 | * |
122 | * DESCRIPTION: Get next package length and return a pointer past the end of | 122 | * DESCRIPTION: Get next package length and return a pointer past the end of |
123 | * the package. Consumes the package length field | 123 | * the package. Consumes the package length field |
124 | * | 124 | * |
125 | ******************************************************************************/ | 125 | ******************************************************************************/ |
126 | 126 | ||
@@ -147,8 +147,8 @@ u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state) | |||
147 | * RETURN: Pointer to the start of the name string (pointer points into | 147 | * RETURN: Pointer to the start of the name string (pointer points into |
148 | * the AML. | 148 | * the AML. |
149 | * | 149 | * |
150 | * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name | 150 | * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name |
151 | * prefix characters. Set parser state to point past the string. | 151 | * prefix characters. Set parser state to point past the string. |
152 | * (Name is consumed from the AML.) | 152 | * (Name is consumed from the AML.) |
153 | * | 153 | * |
154 | ******************************************************************************/ | 154 | ******************************************************************************/ |
@@ -220,7 +220,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) | |||
220 | * | 220 | * |
221 | * DESCRIPTION: Get next name (if method call, return # of required args). | 221 | * DESCRIPTION: Get next name (if method call, return # of required args). |
222 | * Names are looked up in the internal namespace to determine | 222 | * Names are looked up in the internal namespace to determine |
223 | * if the name represents a control method. If a method | 223 | * if the name represents a control method. If a method |
224 | * is found, the number of arguments to the method is returned. | 224 | * is found, the number of arguments to the method is returned. |
225 | * This information is critical for parsing to continue correctly. | 225 | * This information is critical for parsing to continue correctly. |
226 | * | 226 | * |
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c index 799162c1b6df..5607805aab26 100644 --- a/drivers/acpi/acpica/psloop.c +++ b/drivers/acpi/acpica/psloop.c | |||
@@ -133,18 +133,46 @@ static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state) | |||
133 | 133 | ||
134 | case AML_CLASS_UNKNOWN: | 134 | case AML_CLASS_UNKNOWN: |
135 | 135 | ||
136 | /* The opcode is unrecognized. Just skip unknown opcodes */ | 136 | /* The opcode is unrecognized. Complain and skip unknown opcodes */ |
137 | 137 | ||
138 | ACPI_ERROR((AE_INFO, | 138 | if (walk_state->pass_number == 2) { |
139 | "Found unknown opcode 0x%X at AML address %p offset 0x%X, ignoring", | 139 | ACPI_ERROR((AE_INFO, |
140 | walk_state->opcode, walk_state->parser_state.aml, | 140 | "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring", |
141 | walk_state->aml_offset)); | 141 | walk_state->opcode, |
142 | (u32)(walk_state->aml_offset + | ||
143 | sizeof(struct acpi_table_header)))); | ||
142 | 144 | ||
143 | ACPI_DUMP_BUFFER(walk_state->parser_state.aml, 128); | 145 | ACPI_DUMP_BUFFER(walk_state->parser_state.aml - 16, 48); |
144 | 146 | ||
145 | /* Assume one-byte bad opcode */ | 147 | #ifdef ACPI_ASL_COMPILER |
148 | /* | ||
149 | * This is executed for the disassembler only. Output goes | ||
150 | * to the disassembled ASL output file. | ||
151 | */ | ||
152 | acpi_os_printf | ||
153 | ("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n", | ||
154 | walk_state->opcode, | ||
155 | (u32)(walk_state->aml_offset + | ||
156 | sizeof(struct acpi_table_header))); | ||
157 | |||
158 | /* Dump the context surrounding the invalid opcode */ | ||
159 | |||
160 | acpi_ut_dump_buffer(((u8 *)walk_state->parser_state. | ||
161 | aml - 16), 48, DB_BYTE_DISPLAY, | ||
162 | walk_state->aml_offset + | ||
163 | sizeof(struct acpi_table_header) - | ||
164 | 16); | ||
165 | acpi_os_printf(" */\n"); | ||
166 | #endif | ||
167 | } | ||
168 | |||
169 | /* Increment past one-byte or two-byte opcode */ | ||
146 | 170 | ||
147 | walk_state->parser_state.aml++; | 171 | walk_state->parser_state.aml++; |
172 | if (walk_state->opcode > 0xFF) { /* Can only happen if first byte is 0x5B */ | ||
173 | walk_state->parser_state.aml++; | ||
174 | } | ||
175 | |||
148 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | 176 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); |
149 | 177 | ||
150 | default: | 178 | default: |
@@ -519,11 +547,18 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state, | |||
519 | if ((op_info->class == | 547 | if ((op_info->class == |
520 | AML_CLASS_EXECUTE) && (!arg)) { | 548 | AML_CLASS_EXECUTE) && (!arg)) { |
521 | ACPI_WARNING((AE_INFO, | 549 | ACPI_WARNING((AE_INFO, |
522 | "Detected an unsupported executable opcode " | 550 | "Unsupported module-level executable opcode " |
523 | "at module-level: [0x%.4X] at table offset 0x%.4X", | 551 | "0x%.2X at table offset 0x%.4X", |
524 | op->common.aml_opcode, | 552 | op->common. |
525 | (u32)((aml_op_start - walk_state->parser_state.aml_start) | 553 | aml_opcode, |
526 | + sizeof(struct acpi_table_header)))); | 554 | (u32) |
555 | (ACPI_PTR_DIFF | ||
556 | (aml_op_start, | ||
557 | walk_state-> | ||
558 | parser_state. | ||
559 | aml_start) + | ||
560 | sizeof(struct | ||
561 | acpi_table_header)))); | ||
527 | } | 562 | } |
528 | } | 563 | } |
529 | break; | 564 | break; |
@@ -843,8 +878,6 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state, | |||
843 | *op = NULL; | 878 | *op = NULL; |
844 | } | 879 | } |
845 | 880 | ||
846 | ACPI_PREEMPTION_POINT(); | ||
847 | |||
848 | return_ACPI_STATUS(AE_OK); | 881 | return_ACPI_STATUS(AE_OK); |
849 | } | 882 | } |
850 | 883 | ||
diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c index ed1d457bd5ca..1793d934aa30 100644 --- a/drivers/acpi/acpica/psopcode.c +++ b/drivers/acpi/acpica/psopcode.c | |||
@@ -59,7 +59,7 @@ static const u8 acpi_gbl_argument_count[] = | |||
59 | * | 59 | * |
60 | * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands> | 60 | * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands> |
61 | * The name is a simple ascii string, the operand specifier is an | 61 | * The name is a simple ascii string, the operand specifier is an |
62 | * ascii string with one letter per operand. The letter specifies | 62 | * ascii string with one letter per operand. The letter specifies |
63 | * the operand type. | 63 | * the operand type. |
64 | * | 64 | * |
65 | ******************************************************************************/ | 65 | ******************************************************************************/ |
@@ -183,7 +183,7 @@ static const u8 acpi_gbl_argument_count[] = | |||
183 | ******************************************************************************/ | 183 | ******************************************************************************/ |
184 | 184 | ||
185 | /* | 185 | /* |
186 | * Master Opcode information table. A summary of everything we know about each | 186 | * Master Opcode information table. A summary of everything we know about each |
187 | * opcode, all in one place. | 187 | * opcode, all in one place. |
188 | */ | 188 | */ |
189 | const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { | 189 | const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { |
@@ -392,10 +392,12 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { | |||
392 | AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), | 392 | AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), |
393 | /* 38 */ ACPI_OP("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, | 393 | /* 38 */ ACPI_OP("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, |
394 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | 394 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, |
395 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), | 395 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | |
396 | AML_CONSTANT), | ||
396 | /* 39 */ ACPI_OP("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, | 397 | /* 39 */ ACPI_OP("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, |
397 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | 398 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, |
398 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), | 399 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | |
400 | AML_CONSTANT), | ||
399 | /* 3A */ ACPI_OP("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, | 401 | /* 3A */ ACPI_OP("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, |
400 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, | 402 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, |
401 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), | 403 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), |
@@ -495,7 +497,8 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { | |||
495 | AML_NSNODE | AML_NAMED | AML_DEFER), | 497 | AML_NSNODE | AML_NAMED | AML_DEFER), |
496 | /* 59 */ ACPI_OP("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, | 498 | /* 59 */ ACPI_OP("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, |
497 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, | 499 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, |
498 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), | 500 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
501 | AML_FIELD), | ||
499 | /* 5A */ ACPI_OP("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, | 502 | /* 5A */ ACPI_OP("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, |
500 | ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, | 503 | ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, |
501 | AML_TYPE_NAMED_NO_OBJ, | 504 | AML_TYPE_NAMED_NO_OBJ, |
@@ -519,12 +522,13 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { | |||
519 | /* 5E */ ACPI_OP("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, | 522 | /* 5E */ ACPI_OP("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, |
520 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, | 523 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, |
521 | AML_TYPE_NAMED_FIELD, | 524 | AML_TYPE_NAMED_FIELD, |
522 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), | 525 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
526 | AML_FIELD), | ||
523 | /* 5F */ ACPI_OP("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, | 527 | /* 5F */ ACPI_OP("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, |
524 | ACPI_TYPE_LOCAL_BANK_FIELD, AML_CLASS_NAMED_OBJECT, | 528 | ACPI_TYPE_LOCAL_BANK_FIELD, |
525 | AML_TYPE_NAMED_FIELD, | 529 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, |
526 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD | | 530 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
527 | AML_DEFER), | 531 | AML_FIELD | AML_DEFER), |
528 | 532 | ||
529 | /* Internal opcodes that map to invalid AML opcodes */ | 533 | /* Internal opcodes that map to invalid AML opcodes */ |
530 | 534 | ||
@@ -632,7 +636,8 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { | |||
632 | /* 7D */ ACPI_OP("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, | 636 | /* 7D */ ACPI_OP("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, |
633 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, | 637 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, |
634 | AML_TYPE_NAMED_NO_OBJ, | 638 | AML_TYPE_NAMED_NO_OBJ, |
635 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), | 639 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
640 | AML_NSNODE), | ||
636 | 641 | ||
637 | /* ACPI 3.0 opcodes */ | 642 | /* ACPI 3.0 opcodes */ |
638 | 643 | ||
@@ -695,7 +700,7 @@ static const u8 acpi_gbl_short_op_index[256] = { | |||
695 | 700 | ||
696 | /* | 701 | /* |
697 | * This table is indexed by the second opcode of the extended opcode | 702 | * This table is indexed by the second opcode of the extended opcode |
698 | * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info) | 703 | * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info) |
699 | */ | 704 | */ |
700 | static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = { | 705 | static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = { |
701 | /* 0 1 2 3 4 5 6 7 */ | 706 | /* 0 1 2 3 4 5 6 7 */ |
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c index 01985703bb98..2494caf47755 100644 --- a/drivers/acpi/acpica/psparse.c +++ b/drivers/acpi/acpica/psparse.c | |||
@@ -43,9 +43,9 @@ | |||
43 | 43 | ||
44 | /* | 44 | /* |
45 | * Parse the AML and build an operation tree as most interpreters, | 45 | * Parse the AML and build an operation tree as most interpreters, |
46 | * like Perl, do. Parsing is done by hand rather than with a YACC | 46 | * like Perl, do. Parsing is done by hand rather than with a YACC |
47 | * generated parser to tightly constrain stack and dynamic memory | 47 | * generated parser to tightly constrain stack and dynamic memory |
48 | * usage. At the same time, parsing is kept flexible and the code | 48 | * usage. At the same time, parsing is kept flexible and the code |
49 | * fairly compact by parsing based on a list of AML opcode | 49 | * fairly compact by parsing based on a list of AML opcode |
50 | * templates in aml_op_info[] | 50 | * templates in aml_op_info[] |
51 | */ | 51 | */ |
@@ -379,7 +379,7 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, | |||
379 | case AE_CTRL_FALSE: | 379 | case AE_CTRL_FALSE: |
380 | /* | 380 | /* |
381 | * Either an IF/WHILE Predicate was false or we encountered a BREAK | 381 | * Either an IF/WHILE Predicate was false or we encountered a BREAK |
382 | * opcode. In both cases, we do not execute the rest of the | 382 | * opcode. In both cases, we do not execute the rest of the |
383 | * package; We simply close out the parent (finishing the walk of | 383 | * package; We simply close out the parent (finishing the walk of |
384 | * this branch of the tree) and continue execution at the parent | 384 | * this branch of the tree) and continue execution at the parent |
385 | * level. | 385 | * level. |
@@ -459,8 +459,9 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) | |||
459 | 459 | ||
460 | /* Executing a control method - additional cleanup */ | 460 | /* Executing a control method - additional cleanup */ |
461 | 461 | ||
462 | acpi_ds_terminate_control_method( | 462 | acpi_ds_terminate_control_method(walk_state-> |
463 | walk_state->method_desc, walk_state); | 463 | method_desc, |
464 | walk_state); | ||
464 | } | 465 | } |
465 | 466 | ||
466 | acpi_ds_delete_walk_state(walk_state); | 467 | acpi_ds_delete_walk_state(walk_state); |
@@ -487,7 +488,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) | |||
487 | acpi_gbl_current_walk_list = thread; | 488 | acpi_gbl_current_walk_list = thread; |
488 | 489 | ||
489 | /* | 490 | /* |
490 | * Execute the walk loop as long as there is a valid Walk State. This | 491 | * Execute the walk loop as long as there is a valid Walk State. This |
491 | * handles nested control method invocations without recursion. | 492 | * handles nested control method invocations without recursion. |
492 | */ | 493 | */ |
493 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "State=%p\n", walk_state)); | 494 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "State=%p\n", walk_state)); |
diff --git a/drivers/acpi/acpica/psutils.c b/drivers/acpi/acpica/psutils.c index 8736ad5f04d3..4137dcb352d1 100644 --- a/drivers/acpi/acpica/psutils.c +++ b/drivers/acpi/acpica/psutils.c | |||
@@ -108,7 +108,7 @@ void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode) | |||
108 | * RETURN: Pointer to the new Op, null on failure | 108 | * RETURN: Pointer to the new Op, null on failure |
109 | * | 109 | * |
110 | * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on | 110 | * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on |
111 | * opcode. A cache of opcodes is available for the pure | 111 | * opcode. A cache of opcodes is available for the pure |
112 | * GENERIC_OP, since this is by far the most commonly used. | 112 | * GENERIC_OP, since this is by far the most commonly used. |
113 | * | 113 | * |
114 | ******************************************************************************/ | 114 | ******************************************************************************/ |
@@ -164,7 +164,7 @@ union acpi_parse_object *acpi_ps_alloc_op(u16 opcode) | |||
164 | * | 164 | * |
165 | * RETURN: None. | 165 | * RETURN: None. |
166 | * | 166 | * |
167 | * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list | 167 | * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list |
168 | * or actually free it. | 168 | * or actually free it. |
169 | * | 169 | * |
170 | ******************************************************************************/ | 170 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c index de12469d1c9c..147feb6aa2a0 100644 --- a/drivers/acpi/acpica/rscalc.c +++ b/drivers/acpi/acpica/rscalc.c | |||
@@ -457,6 +457,15 @@ acpi_rs_get_list_length(u8 * aml_buffer, | |||
457 | * Get the number of vendor data bytes | 457 | * Get the number of vendor data bytes |
458 | */ | 458 | */ |
459 | extra_struct_bytes = resource_length; | 459 | extra_struct_bytes = resource_length; |
460 | |||
461 | /* | ||
462 | * There is already one byte included in the minimum | ||
463 | * descriptor size. If there are extra struct bytes, | ||
464 | * subtract one from the count. | ||
465 | */ | ||
466 | if (extra_struct_bytes) { | ||
467 | extra_struct_bytes--; | ||
468 | } | ||
460 | break; | 469 | break; |
461 | 470 | ||
462 | case ACPI_RESOURCE_NAME_END_TAG: | 471 | case ACPI_RESOURCE_NAME_END_TAG: |
@@ -601,7 +610,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
601 | /* | 610 | /* |
602 | * Calculate the size of the return buffer. | 611 | * Calculate the size of the return buffer. |
603 | * The base size is the number of elements * the sizes of the | 612 | * The base size is the number of elements * the sizes of the |
604 | * structures. Additional space for the strings is added below. | 613 | * structures. Additional space for the strings is added below. |
605 | * The minus one is to subtract the size of the u8 Source[1] | 614 | * The minus one is to subtract the size of the u8 Source[1] |
606 | * member because it is added below. | 615 | * member because it is added below. |
607 | * | 616 | * |
@@ -664,8 +673,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
664 | (*sub_object_list)->string. | 673 | (*sub_object_list)->string. |
665 | length + 1); | 674 | length + 1); |
666 | } else { | 675 | } else { |
667 | temp_size_needed += | 676 | temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node); |
668 | acpi_ns_get_pathname_length((*sub_object_list)->reference.node); | ||
669 | } | 677 | } |
670 | } else { | 678 | } else { |
671 | /* | 679 | /* |
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c index 46b5324b22d6..8b64db9a3fd2 100644 --- a/drivers/acpi/acpica/rslist.c +++ b/drivers/acpi/acpica/rslist.c | |||
@@ -109,7 +109,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml, | |||
109 | ACPI_ERROR((AE_INFO, | 109 | ACPI_ERROR((AE_INFO, |
110 | "Invalid/unsupported resource descriptor: Type 0x%2.2X", | 110 | "Invalid/unsupported resource descriptor: Type 0x%2.2X", |
111 | resource_index)); | 111 | resource_index)); |
112 | return (AE_AML_INVALID_RESOURCE_TYPE); | 112 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); |
113 | } | 113 | } |
114 | 114 | ||
115 | /* Convert the AML byte stream resource to a local resource struct */ | 115 | /* Convert the AML byte stream resource to a local resource struct */ |
@@ -200,7 +200,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, | |||
200 | ACPI_ERROR((AE_INFO, | 200 | ACPI_ERROR((AE_INFO, |
201 | "Invalid/unsupported resource descriptor: Type 0x%2.2X", | 201 | "Invalid/unsupported resource descriptor: Type 0x%2.2X", |
202 | resource->type)); | 202 | resource->type)); |
203 | return (AE_AML_INVALID_RESOURCE_TYPE); | 203 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); |
204 | } | 204 | } |
205 | 205 | ||
206 | status = acpi_rs_convert_resource_to_aml(resource, | 206 | status = acpi_rs_convert_resource_to_aml(resource, |
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c index 57deae166577..77d1db29a725 100644 --- a/drivers/acpi/acpica/tbfind.c +++ b/drivers/acpi/acpica/tbfind.c | |||
@@ -77,7 +77,7 @@ acpi_tb_find_table(char *signature, | |||
77 | /* Normalize the input strings */ | 77 | /* Normalize the input strings */ |
78 | 78 | ||
79 | ACPI_MEMSET(&header, 0, sizeof(struct acpi_table_header)); | 79 | ACPI_MEMSET(&header, 0, sizeof(struct acpi_table_header)); |
80 | ACPI_STRNCPY(header.signature, signature, ACPI_NAME_SIZE); | 80 | ACPI_MOVE_NAME(header.signature, signature); |
81 | ACPI_STRNCPY(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); | 81 | ACPI_STRNCPY(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); |
82 | ACPI_STRNCPY(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE); | 82 | ACPI_STRNCPY(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE); |
83 | 83 | ||
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c index 70f9d787c82c..f540ae462925 100644 --- a/drivers/acpi/acpica/tbinstal.c +++ b/drivers/acpi/acpica/tbinstal.c | |||
@@ -526,6 +526,8 @@ void acpi_tb_terminate(void) | |||
526 | 526 | ||
527 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); | 527 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); |
528 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | 528 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
529 | |||
530 | return_VOID; | ||
529 | } | 531 | } |
530 | 532 | ||
531 | /******************************************************************************* | 533 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index b6cea30da638..285e24b97382 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c | |||
@@ -354,7 +354,7 @@ u8 acpi_tb_checksum(u8 *buffer, u32 length) | |||
354 | sum = (u8) (sum + *(buffer++)); | 354 | sum = (u8) (sum + *(buffer++)); |
355 | } | 355 | } |
356 | 356 | ||
357 | return sum; | 357 | return (sum); |
358 | } | 358 | } |
359 | 359 | ||
360 | /******************************************************************************* | 360 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c index 21101262e47a..f5632780421d 100644 --- a/drivers/acpi/acpica/tbxface.c +++ b/drivers/acpi/acpica/tbxface.c | |||
@@ -236,7 +236,7 @@ acpi_get_table_header(char *signature, | |||
236 | sizeof(struct | 236 | sizeof(struct |
237 | acpi_table_header)); | 237 | acpi_table_header)); |
238 | if (!header) { | 238 | if (!header) { |
239 | return AE_NO_MEMORY; | 239 | return (AE_NO_MEMORY); |
240 | } | 240 | } |
241 | ACPI_MEMCPY(out_table_header, header, | 241 | ACPI_MEMCPY(out_table_header, header, |
242 | sizeof(struct acpi_table_header)); | 242 | sizeof(struct acpi_table_header)); |
@@ -244,7 +244,7 @@ acpi_get_table_header(char *signature, | |||
244 | sizeof(struct | 244 | sizeof(struct |
245 | acpi_table_header)); | 245 | acpi_table_header)); |
246 | } else { | 246 | } else { |
247 | return AE_NOT_FOUND; | 247 | return (AE_NOT_FOUND); |
248 | } | 248 | } |
249 | } else { | 249 | } else { |
250 | ACPI_MEMCPY(out_table_header, | 250 | ACPI_MEMCPY(out_table_header, |
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c index f87cc63e69a1..a5e1e4e47098 100644 --- a/drivers/acpi/acpica/tbxfload.c +++ b/drivers/acpi/acpica/tbxfload.c | |||
@@ -211,7 +211,7 @@ static acpi_status acpi_tb_load_namespace(void) | |||
211 | * DESCRIPTION: Dynamically load an ACPI table from the caller's buffer. Must | 211 | * DESCRIPTION: Dynamically load an ACPI table from the caller's buffer. Must |
212 | * be a valid ACPI table with a valid ACPI table header. | 212 | * be a valid ACPI table with a valid ACPI table header. |
213 | * Note1: Mainly intended to support hotplug addition of SSDTs. | 213 | * Note1: Mainly intended to support hotplug addition of SSDTs. |
214 | * Note2: Does not copy the incoming table. User is reponsible | 214 | * Note2: Does not copy the incoming table. User is responsible |
215 | * to ensure that the table is not deleted or unmapped. | 215 | * to ensure that the table is not deleted or unmapped. |
216 | * | 216 | * |
217 | ******************************************************************************/ | 217 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c index 74e720800037..28f330230f99 100644 --- a/drivers/acpi/acpica/tbxfroot.c +++ b/drivers/acpi/acpica/tbxfroot.c | |||
@@ -67,7 +67,6 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp); | |||
67 | 67 | ||
68 | static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) | 68 | static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) |
69 | { | 69 | { |
70 | ACPI_FUNCTION_ENTRY(); | ||
71 | 70 | ||
72 | /* | 71 | /* |
73 | * The signature and checksum must both be correct | 72 | * The signature and checksum must both be correct |
@@ -108,7 +107,7 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) | |||
108 | * RETURN: Status, RSDP physical address | 107 | * RETURN: Status, RSDP physical address |
109 | * | 108 | * |
110 | * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor | 109 | * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor |
111 | * pointer structure. If it is found, set *RSDP to point to it. | 110 | * pointer structure. If it is found, set *RSDP to point to it. |
112 | * | 111 | * |
113 | * NOTE1: The RSDP must be either in the first 1K of the Extended | 112 | * NOTE1: The RSDP must be either in the first 1K of the Extended |
114 | * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) | 113 | * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) |
diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c new file mode 100644 index 000000000000..e1d40ed26390 --- /dev/null +++ b/drivers/acpi/acpica/utcache.c | |||
@@ -0,0 +1,323 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: utcache - local cache allocation routines | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | |||
47 | #define _COMPONENT ACPI_UTILITIES | ||
48 | ACPI_MODULE_NAME("utcache") | ||
49 | |||
50 | #ifdef ACPI_USE_LOCAL_CACHE | ||
51 | /******************************************************************************* | ||
52 | * | ||
53 | * FUNCTION: acpi_os_create_cache | ||
54 | * | ||
55 | * PARAMETERS: cache_name - Ascii name for the cache | ||
56 | * object_size - Size of each cached object | ||
57 | * max_depth - Maximum depth of the cache (in objects) | ||
58 | * return_cache - Where the new cache object is returned | ||
59 | * | ||
60 | * RETURN: Status | ||
61 | * | ||
62 | * DESCRIPTION: Create a cache object | ||
63 | * | ||
64 | ******************************************************************************/ | ||
65 | acpi_status | ||
66 | acpi_os_create_cache(char *cache_name, | ||
67 | u16 object_size, | ||
68 | u16 max_depth, struct acpi_memory_list ** return_cache) | ||
69 | { | ||
70 | struct acpi_memory_list *cache; | ||
71 | |||
72 | ACPI_FUNCTION_ENTRY(); | ||
73 | |||
74 | if (!cache_name || !return_cache || (object_size < 16)) { | ||
75 | return (AE_BAD_PARAMETER); | ||
76 | } | ||
77 | |||
78 | /* Create the cache object */ | ||
79 | |||
80 | cache = acpi_os_allocate(sizeof(struct acpi_memory_list)); | ||
81 | if (!cache) { | ||
82 | return (AE_NO_MEMORY); | ||
83 | } | ||
84 | |||
85 | /* Populate the cache object and return it */ | ||
86 | |||
87 | ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list)); | ||
88 | cache->link_offset = 8; | ||
89 | cache->list_name = cache_name; | ||
90 | cache->object_size = object_size; | ||
91 | cache->max_depth = max_depth; | ||
92 | |||
93 | *return_cache = cache; | ||
94 | return (AE_OK); | ||
95 | } | ||
96 | |||
97 | /******************************************************************************* | ||
98 | * | ||
99 | * FUNCTION: acpi_os_purge_cache | ||
100 | * | ||
101 | * PARAMETERS: cache - Handle to cache object | ||
102 | * | ||
103 | * RETURN: Status | ||
104 | * | ||
105 | * DESCRIPTION: Free all objects within the requested cache. | ||
106 | * | ||
107 | ******************************************************************************/ | ||
108 | |||
109 | acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache) | ||
110 | { | ||
111 | char *next; | ||
112 | acpi_status status; | ||
113 | |||
114 | ACPI_FUNCTION_ENTRY(); | ||
115 | |||
116 | if (!cache) { | ||
117 | return (AE_BAD_PARAMETER); | ||
118 | } | ||
119 | |||
120 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | ||
121 | if (ACPI_FAILURE(status)) { | ||
122 | return (status); | ||
123 | } | ||
124 | |||
125 | /* Walk the list of objects in this cache */ | ||
126 | |||
127 | while (cache->list_head) { | ||
128 | |||
129 | /* Delete and unlink one cached state object */ | ||
130 | |||
131 | next = *(ACPI_CAST_INDIRECT_PTR(char, | ||
132 | &(((char *)cache-> | ||
133 | list_head)[cache-> | ||
134 | link_offset]))); | ||
135 | ACPI_FREE(cache->list_head); | ||
136 | |||
137 | cache->list_head = next; | ||
138 | cache->current_depth--; | ||
139 | } | ||
140 | |||
141 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
142 | return (AE_OK); | ||
143 | } | ||
144 | |||
145 | /******************************************************************************* | ||
146 | * | ||
147 | * FUNCTION: acpi_os_delete_cache | ||
148 | * | ||
149 | * PARAMETERS: cache - Handle to cache object | ||
150 | * | ||
151 | * RETURN: Status | ||
152 | * | ||
153 | * DESCRIPTION: Free all objects within the requested cache and delete the | ||
154 | * cache object. | ||
155 | * | ||
156 | ******************************************************************************/ | ||
157 | |||
158 | acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache) | ||
159 | { | ||
160 | acpi_status status; | ||
161 | |||
162 | ACPI_FUNCTION_ENTRY(); | ||
163 | |||
164 | /* Purge all objects in the cache */ | ||
165 | |||
166 | status = acpi_os_purge_cache(cache); | ||
167 | if (ACPI_FAILURE(status)) { | ||
168 | return (status); | ||
169 | } | ||
170 | |||
171 | /* Now we can delete the cache object */ | ||
172 | |||
173 | acpi_os_free(cache); | ||
174 | return (AE_OK); | ||
175 | } | ||
176 | |||
177 | /******************************************************************************* | ||
178 | * | ||
179 | * FUNCTION: acpi_os_release_object | ||
180 | * | ||
181 | * PARAMETERS: cache - Handle to cache object | ||
182 | * object - The object to be released | ||
183 | * | ||
184 | * RETURN: None | ||
185 | * | ||
186 | * DESCRIPTION: Release an object to the specified cache. If cache is full, | ||
187 | * the object is deleted. | ||
188 | * | ||
189 | ******************************************************************************/ | ||
190 | |||
191 | acpi_status | ||
192 | acpi_os_release_object(struct acpi_memory_list * cache, void *object) | ||
193 | { | ||
194 | acpi_status status; | ||
195 | |||
196 | ACPI_FUNCTION_ENTRY(); | ||
197 | |||
198 | if (!cache || !object) { | ||
199 | return (AE_BAD_PARAMETER); | ||
200 | } | ||
201 | |||
202 | /* If cache is full, just free this object */ | ||
203 | |||
204 | if (cache->current_depth >= cache->max_depth) { | ||
205 | ACPI_FREE(object); | ||
206 | ACPI_MEM_TRACKING(cache->total_freed++); | ||
207 | } | ||
208 | |||
209 | /* Otherwise put this object back into the cache */ | ||
210 | |||
211 | else { | ||
212 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | ||
213 | if (ACPI_FAILURE(status)) { | ||
214 | return (status); | ||
215 | } | ||
216 | |||
217 | /* Mark the object as cached */ | ||
218 | |||
219 | ACPI_MEMSET(object, 0xCA, cache->object_size); | ||
220 | ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED); | ||
221 | |||
222 | /* Put the object at the head of the cache list */ | ||
223 | |||
224 | *(ACPI_CAST_INDIRECT_PTR(char, | ||
225 | &(((char *)object)[cache-> | ||
226 | link_offset]))) = | ||
227 | cache->list_head; | ||
228 | cache->list_head = object; | ||
229 | cache->current_depth++; | ||
230 | |||
231 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
232 | } | ||
233 | |||
234 | return (AE_OK); | ||
235 | } | ||
236 | |||
237 | /******************************************************************************* | ||
238 | * | ||
239 | * FUNCTION: acpi_os_acquire_object | ||
240 | * | ||
241 | * PARAMETERS: cache - Handle to cache object | ||
242 | * | ||
243 | * RETURN: the acquired object. NULL on error | ||
244 | * | ||
245 | * DESCRIPTION: Get an object from the specified cache. If cache is empty, | ||
246 | * the object is allocated. | ||
247 | * | ||
248 | ******************************************************************************/ | ||
249 | |||
250 | void *acpi_os_acquire_object(struct acpi_memory_list *cache) | ||
251 | { | ||
252 | acpi_status status; | ||
253 | void *object; | ||
254 | |||
255 | ACPI_FUNCTION_NAME(os_acquire_object); | ||
256 | |||
257 | if (!cache) { | ||
258 | return (NULL); | ||
259 | } | ||
260 | |||
261 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | ||
262 | if (ACPI_FAILURE(status)) { | ||
263 | return (NULL); | ||
264 | } | ||
265 | |||
266 | ACPI_MEM_TRACKING(cache->requests++); | ||
267 | |||
268 | /* Check the cache first */ | ||
269 | |||
270 | if (cache->list_head) { | ||
271 | |||
272 | /* There is an object available, use it */ | ||
273 | |||
274 | object = cache->list_head; | ||
275 | cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char, | ||
276 | &(((char *) | ||
277 | object)[cache-> | ||
278 | link_offset]))); | ||
279 | |||
280 | cache->current_depth--; | ||
281 | |||
282 | ACPI_MEM_TRACKING(cache->hits++); | ||
283 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
284 | "Object %p from %s cache\n", object, | ||
285 | cache->list_name)); | ||
286 | |||
287 | status = acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
288 | if (ACPI_FAILURE(status)) { | ||
289 | return (NULL); | ||
290 | } | ||
291 | |||
292 | /* Clear (zero) the previously used Object */ | ||
293 | |||
294 | ACPI_MEMSET(object, 0, cache->object_size); | ||
295 | } else { | ||
296 | /* The cache is empty, create a new object */ | ||
297 | |||
298 | ACPI_MEM_TRACKING(cache->total_allocated++); | ||
299 | |||
300 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | ||
301 | if ((cache->total_allocated - cache->total_freed) > | ||
302 | cache->max_occupied) { | ||
303 | cache->max_occupied = | ||
304 | cache->total_allocated - cache->total_freed; | ||
305 | } | ||
306 | #endif | ||
307 | |||
308 | /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */ | ||
309 | |||
310 | status = acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
311 | if (ACPI_FAILURE(status)) { | ||
312 | return (NULL); | ||
313 | } | ||
314 | |||
315 | object = ACPI_ALLOCATE_ZEROED(cache->object_size); | ||
316 | if (!object) { | ||
317 | return (NULL); | ||
318 | } | ||
319 | } | ||
320 | |||
321 | return (object); | ||
322 | } | ||
323 | #endif /* ACPI_USE_LOCAL_CACHE */ | ||
diff --git a/drivers/acpi/acpica/utclib.c b/drivers/acpi/acpica/utclib.c new file mode 100644 index 000000000000..19ea4755aa73 --- /dev/null +++ b/drivers/acpi/acpica/utclib.c | |||
@@ -0,0 +1,749 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: cmclib - Local implementation of C library functions | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | |||
47 | /* | ||
48 | * These implementations of standard C Library routines can optionally be | ||
49 | * used if a C library is not available. In general, they are less efficient | ||
50 | * than an inline or assembly implementation | ||
51 | */ | ||
52 | |||
53 | #define _COMPONENT ACPI_UTILITIES | ||
54 | ACPI_MODULE_NAME("cmclib") | ||
55 | |||
56 | #ifndef ACPI_USE_SYSTEM_CLIBRARY | ||
57 | #define NEGATIVE 1 | ||
58 | #define POSITIVE 0 | ||
59 | /******************************************************************************* | ||
60 | * | ||
61 | * FUNCTION: acpi_ut_memcmp (memcmp) | ||
62 | * | ||
63 | * PARAMETERS: buffer1 - First Buffer | ||
64 | * buffer2 - Second Buffer | ||
65 | * count - Maximum # of bytes to compare | ||
66 | * | ||
67 | * RETURN: Index where Buffers mismatched, or 0 if Buffers matched | ||
68 | * | ||
69 | * DESCRIPTION: Compare two Buffers, with a maximum length | ||
70 | * | ||
71 | ******************************************************************************/ | ||
72 | int acpi_ut_memcmp(const char *buffer1, const char *buffer2, acpi_size count) | ||
73 | { | ||
74 | |||
75 | return ((count == ACPI_SIZE_MAX) ? 0 : ((unsigned char)*buffer1 - | ||
76 | (unsigned char)*buffer2)); | ||
77 | } | ||
78 | |||
79 | /******************************************************************************* | ||
80 | * | ||
81 | * FUNCTION: acpi_ut_memcpy (memcpy) | ||
82 | * | ||
83 | * PARAMETERS: dest - Target of the copy | ||
84 | * src - Source buffer to copy | ||
85 | * count - Number of bytes to copy | ||
86 | * | ||
87 | * RETURN: Dest | ||
88 | * | ||
89 | * DESCRIPTION: Copy arbitrary bytes of memory | ||
90 | * | ||
91 | ******************************************************************************/ | ||
92 | |||
93 | void *acpi_ut_memcpy(void *dest, const void *src, acpi_size count) | ||
94 | { | ||
95 | char *new = (char *)dest; | ||
96 | char *old = (char *)src; | ||
97 | |||
98 | while (count) { | ||
99 | *new = *old; | ||
100 | new++; | ||
101 | old++; | ||
102 | count--; | ||
103 | } | ||
104 | |||
105 | return (dest); | ||
106 | } | ||
107 | |||
108 | /******************************************************************************* | ||
109 | * | ||
110 | * FUNCTION: acpi_ut_memset (memset) | ||
111 | * | ||
112 | * PARAMETERS: dest - Buffer to set | ||
113 | * value - Value to set each byte of memory | ||
114 | * count - Number of bytes to set | ||
115 | * | ||
116 | * RETURN: Dest | ||
117 | * | ||
118 | * DESCRIPTION: Initialize a buffer to a known value. | ||
119 | * | ||
120 | ******************************************************************************/ | ||
121 | |||
122 | void *acpi_ut_memset(void *dest, u8 value, acpi_size count) | ||
123 | { | ||
124 | char *new = (char *)dest; | ||
125 | |||
126 | while (count) { | ||
127 | *new = (char)value; | ||
128 | new++; | ||
129 | count--; | ||
130 | } | ||
131 | |||
132 | return (dest); | ||
133 | } | ||
134 | |||
135 | /******************************************************************************* | ||
136 | * | ||
137 | * FUNCTION: acpi_ut_strlen (strlen) | ||
138 | * | ||
139 | * PARAMETERS: string - Null terminated string | ||
140 | * | ||
141 | * RETURN: Length | ||
142 | * | ||
143 | * DESCRIPTION: Returns the length of the input string | ||
144 | * | ||
145 | ******************************************************************************/ | ||
146 | |||
147 | acpi_size acpi_ut_strlen(const char *string) | ||
148 | { | ||
149 | u32 length = 0; | ||
150 | |||
151 | /* Count the string until a null is encountered */ | ||
152 | |||
153 | while (*string) { | ||
154 | length++; | ||
155 | string++; | ||
156 | } | ||
157 | |||
158 | return (length); | ||
159 | } | ||
160 | |||
161 | /******************************************************************************* | ||
162 | * | ||
163 | * FUNCTION: acpi_ut_strcpy (strcpy) | ||
164 | * | ||
165 | * PARAMETERS: dst_string - Target of the copy | ||
166 | * src_string - The source string to copy | ||
167 | * | ||
168 | * RETURN: dst_string | ||
169 | * | ||
170 | * DESCRIPTION: Copy a null terminated string | ||
171 | * | ||
172 | ******************************************************************************/ | ||
173 | |||
174 | char *acpi_ut_strcpy(char *dst_string, const char *src_string) | ||
175 | { | ||
176 | char *string = dst_string; | ||
177 | |||
178 | /* Move bytes brute force */ | ||
179 | |||
180 | while (*src_string) { | ||
181 | *string = *src_string; | ||
182 | |||
183 | string++; | ||
184 | src_string++; | ||
185 | } | ||
186 | |||
187 | /* Null terminate */ | ||
188 | |||
189 | *string = 0; | ||
190 | return (dst_string); | ||
191 | } | ||
192 | |||
193 | /******************************************************************************* | ||
194 | * | ||
195 | * FUNCTION: acpi_ut_strncpy (strncpy) | ||
196 | * | ||
197 | * PARAMETERS: dst_string - Target of the copy | ||
198 | * src_string - The source string to copy | ||
199 | * count - Maximum # of bytes to copy | ||
200 | * | ||
201 | * RETURN: dst_string | ||
202 | * | ||
203 | * DESCRIPTION: Copy a null terminated string, with a maximum length | ||
204 | * | ||
205 | ******************************************************************************/ | ||
206 | |||
207 | char *acpi_ut_strncpy(char *dst_string, const char *src_string, acpi_size count) | ||
208 | { | ||
209 | char *string = dst_string; | ||
210 | |||
211 | /* Copy the string */ | ||
212 | |||
213 | for (string = dst_string; | ||
214 | count && (count--, (*string++ = *src_string++));) {; | ||
215 | } | ||
216 | |||
217 | /* Pad with nulls if necessary */ | ||
218 | |||
219 | while (count--) { | ||
220 | *string = 0; | ||
221 | string++; | ||
222 | } | ||
223 | |||
224 | /* Return original pointer */ | ||
225 | |||
226 | return (dst_string); | ||
227 | } | ||
228 | |||
229 | /******************************************************************************* | ||
230 | * | ||
231 | * FUNCTION: acpi_ut_strcmp (strcmp) | ||
232 | * | ||
233 | * PARAMETERS: string1 - First string | ||
234 | * string2 - Second string | ||
235 | * | ||
236 | * RETURN: Index where strings mismatched, or 0 if strings matched | ||
237 | * | ||
238 | * DESCRIPTION: Compare two null terminated strings | ||
239 | * | ||
240 | ******************************************************************************/ | ||
241 | |||
242 | int acpi_ut_strcmp(const char *string1, const char *string2) | ||
243 | { | ||
244 | |||
245 | for (; (*string1 == *string2); string2++) { | ||
246 | if (!*string1++) { | ||
247 | return (0); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | return ((unsigned char)*string1 - (unsigned char)*string2); | ||
252 | } | ||
253 | |||
254 | #ifdef ACPI_FUTURE_IMPLEMENTATION | ||
255 | /* Not used at this time */ | ||
256 | /******************************************************************************* | ||
257 | * | ||
258 | * FUNCTION: acpi_ut_strchr (strchr) | ||
259 | * | ||
260 | * PARAMETERS: string - Search string | ||
261 | * ch - character to search for | ||
262 | * | ||
263 | * RETURN: Ptr to char or NULL if not found | ||
264 | * | ||
265 | * DESCRIPTION: Search a string for a character | ||
266 | * | ||
267 | ******************************************************************************/ | ||
268 | |||
269 | char *acpi_ut_strchr(const char *string, int ch) | ||
270 | { | ||
271 | |||
272 | for (; (*string); string++) { | ||
273 | if ((*string) == (char)ch) { | ||
274 | return ((char *)string); | ||
275 | } | ||
276 | } | ||
277 | |||
278 | return (NULL); | ||
279 | } | ||
280 | #endif | ||
281 | |||
282 | /******************************************************************************* | ||
283 | * | ||
284 | * FUNCTION: acpi_ut_strncmp (strncmp) | ||
285 | * | ||
286 | * PARAMETERS: string1 - First string | ||
287 | * string2 - Second string | ||
288 | * count - Maximum # of bytes to compare | ||
289 | * | ||
290 | * RETURN: Index where strings mismatched, or 0 if strings matched | ||
291 | * | ||
292 | * DESCRIPTION: Compare two null terminated strings, with a maximum length | ||
293 | * | ||
294 | ******************************************************************************/ | ||
295 | |||
296 | int acpi_ut_strncmp(const char *string1, const char *string2, acpi_size count) | ||
297 | { | ||
298 | |||
299 | for (; count-- && (*string1 == *string2); string2++) { | ||
300 | if (!*string1++) { | ||
301 | return (0); | ||
302 | } | ||
303 | } | ||
304 | |||
305 | return ((count == ACPI_SIZE_MAX) ? 0 : ((unsigned char)*string1 - | ||
306 | (unsigned char)*string2)); | ||
307 | } | ||
308 | |||
309 | /******************************************************************************* | ||
310 | * | ||
311 | * FUNCTION: acpi_ut_strcat (Strcat) | ||
312 | * | ||
313 | * PARAMETERS: dst_string - Target of the copy | ||
314 | * src_string - The source string to copy | ||
315 | * | ||
316 | * RETURN: dst_string | ||
317 | * | ||
318 | * DESCRIPTION: Append a null terminated string to a null terminated string | ||
319 | * | ||
320 | ******************************************************************************/ | ||
321 | |||
322 | char *acpi_ut_strcat(char *dst_string, const char *src_string) | ||
323 | { | ||
324 | char *string; | ||
325 | |||
326 | /* Find end of the destination string */ | ||
327 | |||
328 | for (string = dst_string; *string++;) {; | ||
329 | } | ||
330 | |||
331 | /* Concatenate the string */ | ||
332 | |||
333 | for (--string; (*string++ = *src_string++);) {; | ||
334 | } | ||
335 | |||
336 | return (dst_string); | ||
337 | } | ||
338 | |||
339 | /******************************************************************************* | ||
340 | * | ||
341 | * FUNCTION: acpi_ut_strncat (strncat) | ||
342 | * | ||
343 | * PARAMETERS: dst_string - Target of the copy | ||
344 | * src_string - The source string to copy | ||
345 | * count - Maximum # of bytes to copy | ||
346 | * | ||
347 | * RETURN: dst_string | ||
348 | * | ||
349 | * DESCRIPTION: Append a null terminated string to a null terminated string, | ||
350 | * with a maximum count. | ||
351 | * | ||
352 | ******************************************************************************/ | ||
353 | |||
354 | char *acpi_ut_strncat(char *dst_string, const char *src_string, acpi_size count) | ||
355 | { | ||
356 | char *string; | ||
357 | |||
358 | if (count) { | ||
359 | |||
360 | /* Find end of the destination string */ | ||
361 | |||
362 | for (string = dst_string; *string++;) {; | ||
363 | } | ||
364 | |||
365 | /* Concatenate the string */ | ||
366 | |||
367 | for (--string; (*string++ = *src_string++) && --count;) {; | ||
368 | } | ||
369 | |||
370 | /* Null terminate if necessary */ | ||
371 | |||
372 | if (!count) { | ||
373 | *string = 0; | ||
374 | } | ||
375 | } | ||
376 | |||
377 | return (dst_string); | ||
378 | } | ||
379 | |||
380 | /******************************************************************************* | ||
381 | * | ||
382 | * FUNCTION: acpi_ut_strstr (strstr) | ||
383 | * | ||
384 | * PARAMETERS: string1 - Target string | ||
385 | * string2 - Substring to search for | ||
386 | * | ||
387 | * RETURN: Where substring match starts, Null if no match found | ||
388 | * | ||
389 | * DESCRIPTION: Checks if String2 occurs in String1. This is not really a | ||
390 | * full implementation of strstr, only sufficient for command | ||
391 | * matching | ||
392 | * | ||
393 | ******************************************************************************/ | ||
394 | |||
395 | char *acpi_ut_strstr(char *string1, char *string2) | ||
396 | { | ||
397 | char *string; | ||
398 | |||
399 | if (acpi_ut_strlen(string2) > acpi_ut_strlen(string1)) { | ||
400 | return (NULL); | ||
401 | } | ||
402 | |||
403 | /* Walk entire string, comparing the letters */ | ||
404 | |||
405 | for (string = string1; *string2;) { | ||
406 | if (*string2 != *string) { | ||
407 | return (NULL); | ||
408 | } | ||
409 | |||
410 | string2++; | ||
411 | string++; | ||
412 | } | ||
413 | |||
414 | return (string1); | ||
415 | } | ||
416 | |||
417 | /******************************************************************************* | ||
418 | * | ||
419 | * FUNCTION: acpi_ut_strtoul (strtoul) | ||
420 | * | ||
421 | * PARAMETERS: string - Null terminated string | ||
422 | * terminater - Where a pointer to the terminating byte is | ||
423 | * returned | ||
424 | * base - Radix of the string | ||
425 | * | ||
426 | * RETURN: Converted value | ||
427 | * | ||
428 | * DESCRIPTION: Convert a string into a 32-bit unsigned value. | ||
429 | * Note: use acpi_ut_strtoul64 for 64-bit integers. | ||
430 | * | ||
431 | ******************************************************************************/ | ||
432 | |||
433 | u32 acpi_ut_strtoul(const char *string, char **terminator, u32 base) | ||
434 | { | ||
435 | u32 converted = 0; | ||
436 | u32 index; | ||
437 | u32 sign; | ||
438 | const char *string_start; | ||
439 | u32 return_value = 0; | ||
440 | acpi_status status = AE_OK; | ||
441 | |||
442 | /* | ||
443 | * Save the value of the pointer to the buffer's first | ||
444 | * character, save the current errno value, and then | ||
445 | * skip over any white space in the buffer: | ||
446 | */ | ||
447 | string_start = string; | ||
448 | while (ACPI_IS_SPACE(*string) || *string == '\t') { | ||
449 | ++string; | ||
450 | } | ||
451 | |||
452 | /* | ||
453 | * The buffer may contain an optional plus or minus sign. | ||
454 | * If it does, then skip over it but remember what is was: | ||
455 | */ | ||
456 | if (*string == '-') { | ||
457 | sign = NEGATIVE; | ||
458 | ++string; | ||
459 | } else if (*string == '+') { | ||
460 | ++string; | ||
461 | sign = POSITIVE; | ||
462 | } else { | ||
463 | sign = POSITIVE; | ||
464 | } | ||
465 | |||
466 | /* | ||
467 | * If the input parameter Base is zero, then we need to | ||
468 | * determine if it is octal, decimal, or hexadecimal: | ||
469 | */ | ||
470 | if (base == 0) { | ||
471 | if (*string == '0') { | ||
472 | if (acpi_ut_to_lower(*(++string)) == 'x') { | ||
473 | base = 16; | ||
474 | ++string; | ||
475 | } else { | ||
476 | base = 8; | ||
477 | } | ||
478 | } else { | ||
479 | base = 10; | ||
480 | } | ||
481 | } else if (base < 2 || base > 36) { | ||
482 | /* | ||
483 | * The specified Base parameter is not in the domain of | ||
484 | * this function: | ||
485 | */ | ||
486 | goto done; | ||
487 | } | ||
488 | |||
489 | /* | ||
490 | * For octal and hexadecimal bases, skip over the leading | ||
491 | * 0 or 0x, if they are present. | ||
492 | */ | ||
493 | if (base == 8 && *string == '0') { | ||
494 | string++; | ||
495 | } | ||
496 | |||
497 | if (base == 16 && | ||
498 | *string == '0' && acpi_ut_to_lower(*(++string)) == 'x') { | ||
499 | string++; | ||
500 | } | ||
501 | |||
502 | /* | ||
503 | * Main loop: convert the string to an unsigned long: | ||
504 | */ | ||
505 | while (*string) { | ||
506 | if (ACPI_IS_DIGIT(*string)) { | ||
507 | index = (u32)((u8)*string - '0'); | ||
508 | } else { | ||
509 | index = (u32)acpi_ut_to_upper(*string); | ||
510 | if (ACPI_IS_UPPER(index)) { | ||
511 | index = index - 'A' + 10; | ||
512 | } else { | ||
513 | goto done; | ||
514 | } | ||
515 | } | ||
516 | |||
517 | if (index >= base) { | ||
518 | goto done; | ||
519 | } | ||
520 | |||
521 | /* | ||
522 | * Check to see if value is out of range: | ||
523 | */ | ||
524 | |||
525 | if (return_value > ((ACPI_UINT32_MAX - (u32)index) / (u32)base)) { | ||
526 | status = AE_ERROR; | ||
527 | return_value = 0; /* reset */ | ||
528 | } else { | ||
529 | return_value *= base; | ||
530 | return_value += index; | ||
531 | converted = 1; | ||
532 | } | ||
533 | |||
534 | ++string; | ||
535 | } | ||
536 | |||
537 | done: | ||
538 | /* | ||
539 | * If appropriate, update the caller's pointer to the next | ||
540 | * unconverted character in the buffer. | ||
541 | */ | ||
542 | if (terminator) { | ||
543 | if (converted == 0 && return_value == 0 && string != NULL) { | ||
544 | *terminator = (char *)string_start; | ||
545 | } else { | ||
546 | *terminator = (char *)string; | ||
547 | } | ||
548 | } | ||
549 | |||
550 | if (status == AE_ERROR) { | ||
551 | return_value = ACPI_UINT32_MAX; | ||
552 | } | ||
553 | |||
554 | /* | ||
555 | * If a minus sign was present, then "the conversion is negated": | ||
556 | */ | ||
557 | if (sign == NEGATIVE) { | ||
558 | return_value = (ACPI_UINT32_MAX - return_value) + 1; | ||
559 | } | ||
560 | |||
561 | return (return_value); | ||
562 | } | ||
563 | |||
564 | /******************************************************************************* | ||
565 | * | ||
566 | * FUNCTION: acpi_ut_to_upper (TOUPPER) | ||
567 | * | ||
568 | * PARAMETERS: c - Character to convert | ||
569 | * | ||
570 | * RETURN: Converted character as an int | ||
571 | * | ||
572 | * DESCRIPTION: Convert character to uppercase | ||
573 | * | ||
574 | ******************************************************************************/ | ||
575 | |||
576 | int acpi_ut_to_upper(int c) | ||
577 | { | ||
578 | |||
579 | return (ACPI_IS_LOWER(c) ? ((c) - 0x20) : (c)); | ||
580 | } | ||
581 | |||
582 | /******************************************************************************* | ||
583 | * | ||
584 | * FUNCTION: acpi_ut_to_lower (TOLOWER) | ||
585 | * | ||
586 | * PARAMETERS: c - Character to convert | ||
587 | * | ||
588 | * RETURN: Converted character as an int | ||
589 | * | ||
590 | * DESCRIPTION: Convert character to lowercase | ||
591 | * | ||
592 | ******************************************************************************/ | ||
593 | |||
594 | int acpi_ut_to_lower(int c) | ||
595 | { | ||
596 | |||
597 | return (ACPI_IS_UPPER(c) ? ((c) + 0x20) : (c)); | ||
598 | } | ||
599 | |||
600 | /******************************************************************************* | ||
601 | * | ||
602 | * FUNCTION: is* functions | ||
603 | * | ||
604 | * DESCRIPTION: is* functions use the ctype table below | ||
605 | * | ||
606 | ******************************************************************************/ | ||
607 | |||
608 | const u8 _acpi_ctype[257] = { | ||
609 | _ACPI_CN, /* 0x00 0 NUL */ | ||
610 | _ACPI_CN, /* 0x01 1 SOH */ | ||
611 | _ACPI_CN, /* 0x02 2 STX */ | ||
612 | _ACPI_CN, /* 0x03 3 ETX */ | ||
613 | _ACPI_CN, /* 0x04 4 EOT */ | ||
614 | _ACPI_CN, /* 0x05 5 ENQ */ | ||
615 | _ACPI_CN, /* 0x06 6 ACK */ | ||
616 | _ACPI_CN, /* 0x07 7 BEL */ | ||
617 | _ACPI_CN, /* 0x08 8 BS */ | ||
618 | _ACPI_CN | _ACPI_SP, /* 0x09 9 TAB */ | ||
619 | _ACPI_CN | _ACPI_SP, /* 0x0A 10 LF */ | ||
620 | _ACPI_CN | _ACPI_SP, /* 0x0B 11 VT */ | ||
621 | _ACPI_CN | _ACPI_SP, /* 0x0C 12 FF */ | ||
622 | _ACPI_CN | _ACPI_SP, /* 0x0D 13 CR */ | ||
623 | _ACPI_CN, /* 0x0E 14 SO */ | ||
624 | _ACPI_CN, /* 0x0F 15 SI */ | ||
625 | _ACPI_CN, /* 0x10 16 DLE */ | ||
626 | _ACPI_CN, /* 0x11 17 DC1 */ | ||
627 | _ACPI_CN, /* 0x12 18 DC2 */ | ||
628 | _ACPI_CN, /* 0x13 19 DC3 */ | ||
629 | _ACPI_CN, /* 0x14 20 DC4 */ | ||
630 | _ACPI_CN, /* 0x15 21 NAK */ | ||
631 | _ACPI_CN, /* 0x16 22 SYN */ | ||
632 | _ACPI_CN, /* 0x17 23 ETB */ | ||
633 | _ACPI_CN, /* 0x18 24 CAN */ | ||
634 | _ACPI_CN, /* 0x19 25 EM */ | ||
635 | _ACPI_CN, /* 0x1A 26 SUB */ | ||
636 | _ACPI_CN, /* 0x1B 27 ESC */ | ||
637 | _ACPI_CN, /* 0x1C 28 FS */ | ||
638 | _ACPI_CN, /* 0x1D 29 GS */ | ||
639 | _ACPI_CN, /* 0x1E 30 RS */ | ||
640 | _ACPI_CN, /* 0x1F 31 US */ | ||
641 | _ACPI_XS | _ACPI_SP, /* 0x20 32 ' ' */ | ||
642 | _ACPI_PU, /* 0x21 33 '!' */ | ||
643 | _ACPI_PU, /* 0x22 34 '"' */ | ||
644 | _ACPI_PU, /* 0x23 35 '#' */ | ||
645 | _ACPI_PU, /* 0x24 36 '$' */ | ||
646 | _ACPI_PU, /* 0x25 37 '%' */ | ||
647 | _ACPI_PU, /* 0x26 38 '&' */ | ||
648 | _ACPI_PU, /* 0x27 39 ''' */ | ||
649 | _ACPI_PU, /* 0x28 40 '(' */ | ||
650 | _ACPI_PU, /* 0x29 41 ')' */ | ||
651 | _ACPI_PU, /* 0x2A 42 '*' */ | ||
652 | _ACPI_PU, /* 0x2B 43 '+' */ | ||
653 | _ACPI_PU, /* 0x2C 44 ',' */ | ||
654 | _ACPI_PU, /* 0x2D 45 '-' */ | ||
655 | _ACPI_PU, /* 0x2E 46 '.' */ | ||
656 | _ACPI_PU, /* 0x2F 47 '/' */ | ||
657 | _ACPI_XD | _ACPI_DI, /* 0x30 48 '0' */ | ||
658 | _ACPI_XD | _ACPI_DI, /* 0x31 49 '1' */ | ||
659 | _ACPI_XD | _ACPI_DI, /* 0x32 50 '2' */ | ||
660 | _ACPI_XD | _ACPI_DI, /* 0x33 51 '3' */ | ||
661 | _ACPI_XD | _ACPI_DI, /* 0x34 52 '4' */ | ||
662 | _ACPI_XD | _ACPI_DI, /* 0x35 53 '5' */ | ||
663 | _ACPI_XD | _ACPI_DI, /* 0x36 54 '6' */ | ||
664 | _ACPI_XD | _ACPI_DI, /* 0x37 55 '7' */ | ||
665 | _ACPI_XD | _ACPI_DI, /* 0x38 56 '8' */ | ||
666 | _ACPI_XD | _ACPI_DI, /* 0x39 57 '9' */ | ||
667 | _ACPI_PU, /* 0x3A 58 ':' */ | ||
668 | _ACPI_PU, /* 0x3B 59 ';' */ | ||
669 | _ACPI_PU, /* 0x3C 60 '<' */ | ||
670 | _ACPI_PU, /* 0x3D 61 '=' */ | ||
671 | _ACPI_PU, /* 0x3E 62 '>' */ | ||
672 | _ACPI_PU, /* 0x3F 63 '?' */ | ||
673 | _ACPI_PU, /* 0x40 64 '@' */ | ||
674 | _ACPI_XD | _ACPI_UP, /* 0x41 65 'A' */ | ||
675 | _ACPI_XD | _ACPI_UP, /* 0x42 66 'B' */ | ||
676 | _ACPI_XD | _ACPI_UP, /* 0x43 67 'C' */ | ||
677 | _ACPI_XD | _ACPI_UP, /* 0x44 68 'D' */ | ||
678 | _ACPI_XD | _ACPI_UP, /* 0x45 69 'E' */ | ||
679 | _ACPI_XD | _ACPI_UP, /* 0x46 70 'F' */ | ||
680 | _ACPI_UP, /* 0x47 71 'G' */ | ||
681 | _ACPI_UP, /* 0x48 72 'H' */ | ||
682 | _ACPI_UP, /* 0x49 73 'I' */ | ||
683 | _ACPI_UP, /* 0x4A 74 'J' */ | ||
684 | _ACPI_UP, /* 0x4B 75 'K' */ | ||
685 | _ACPI_UP, /* 0x4C 76 'L' */ | ||
686 | _ACPI_UP, /* 0x4D 77 'M' */ | ||
687 | _ACPI_UP, /* 0x4E 78 'N' */ | ||
688 | _ACPI_UP, /* 0x4F 79 'O' */ | ||
689 | _ACPI_UP, /* 0x50 80 'P' */ | ||
690 | _ACPI_UP, /* 0x51 81 'Q' */ | ||
691 | _ACPI_UP, /* 0x52 82 'R' */ | ||
692 | _ACPI_UP, /* 0x53 83 'S' */ | ||
693 | _ACPI_UP, /* 0x54 84 'T' */ | ||
694 | _ACPI_UP, /* 0x55 85 'U' */ | ||
695 | _ACPI_UP, /* 0x56 86 'V' */ | ||
696 | _ACPI_UP, /* 0x57 87 'W' */ | ||
697 | _ACPI_UP, /* 0x58 88 'X' */ | ||
698 | _ACPI_UP, /* 0x59 89 'Y' */ | ||
699 | _ACPI_UP, /* 0x5A 90 'Z' */ | ||
700 | _ACPI_PU, /* 0x5B 91 '[' */ | ||
701 | _ACPI_PU, /* 0x5C 92 '\' */ | ||
702 | _ACPI_PU, /* 0x5D 93 ']' */ | ||
703 | _ACPI_PU, /* 0x5E 94 '^' */ | ||
704 | _ACPI_PU, /* 0x5F 95 '_' */ | ||
705 | _ACPI_PU, /* 0x60 96 '`' */ | ||
706 | _ACPI_XD | _ACPI_LO, /* 0x61 97 'a' */ | ||
707 | _ACPI_XD | _ACPI_LO, /* 0x62 98 'b' */ | ||
708 | _ACPI_XD | _ACPI_LO, /* 0x63 99 'c' */ | ||
709 | _ACPI_XD | _ACPI_LO, /* 0x64 100 'd' */ | ||
710 | _ACPI_XD | _ACPI_LO, /* 0x65 101 'e' */ | ||
711 | _ACPI_XD | _ACPI_LO, /* 0x66 102 'f' */ | ||
712 | _ACPI_LO, /* 0x67 103 'g' */ | ||
713 | _ACPI_LO, /* 0x68 104 'h' */ | ||
714 | _ACPI_LO, /* 0x69 105 'i' */ | ||
715 | _ACPI_LO, /* 0x6A 106 'j' */ | ||
716 | _ACPI_LO, /* 0x6B 107 'k' */ | ||
717 | _ACPI_LO, /* 0x6C 108 'l' */ | ||
718 | _ACPI_LO, /* 0x6D 109 'm' */ | ||
719 | _ACPI_LO, /* 0x6E 110 'n' */ | ||
720 | _ACPI_LO, /* 0x6F 111 'o' */ | ||
721 | _ACPI_LO, /* 0x70 112 'p' */ | ||
722 | _ACPI_LO, /* 0x71 113 'q' */ | ||
723 | _ACPI_LO, /* 0x72 114 'r' */ | ||
724 | _ACPI_LO, /* 0x73 115 's' */ | ||
725 | _ACPI_LO, /* 0x74 116 't' */ | ||
726 | _ACPI_LO, /* 0x75 117 'u' */ | ||
727 | _ACPI_LO, /* 0x76 118 'v' */ | ||
728 | _ACPI_LO, /* 0x77 119 'w' */ | ||
729 | _ACPI_LO, /* 0x78 120 'x' */ | ||
730 | _ACPI_LO, /* 0x79 121 'y' */ | ||
731 | _ACPI_LO, /* 0x7A 122 'z' */ | ||
732 | _ACPI_PU, /* 0x7B 123 '{' */ | ||
733 | _ACPI_PU, /* 0x7C 124 '|' */ | ||
734 | _ACPI_PU, /* 0x7D 125 '}' */ | ||
735 | _ACPI_PU, /* 0x7E 126 '~' */ | ||
736 | _ACPI_CN, /* 0x7F 127 DEL */ | ||
737 | |||
738 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 to 0x8F */ | ||
739 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 to 0x9F */ | ||
740 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xA0 to 0xAF */ | ||
741 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xB0 to 0xBF */ | ||
742 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xC0 to 0xCF */ | ||
743 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xD0 to 0xDF */ | ||
744 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xE0 to 0xEF */ | ||
745 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xF0 to 0xFF */ | ||
746 | 0 /* 0x100 */ | ||
747 | }; | ||
748 | |||
749 | #endif /* ACPI_USE_SYSTEM_CLIBRARY */ | ||
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index e810894149ae..5d95166245ae 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c | |||
@@ -47,8 +47,9 @@ | |||
47 | 47 | ||
48 | #define _COMPONENT ACPI_UTILITIES | 48 | #define _COMPONENT ACPI_UTILITIES |
49 | ACPI_MODULE_NAME("utdebug") | 49 | ACPI_MODULE_NAME("utdebug") |
50 | |||
50 | #ifdef ACPI_DEBUG_OUTPUT | 51 | #ifdef ACPI_DEBUG_OUTPUT |
51 | static acpi_thread_id acpi_gbl_prev_thread_id; | 52 | static acpi_thread_id acpi_gbl_prev_thread_id = (acpi_thread_id) 0xFFFFFFFF; |
52 | static char *acpi_gbl_fn_entry_str = "----Entry"; | 53 | static char *acpi_gbl_fn_entry_str = "----Entry"; |
53 | static char *acpi_gbl_fn_exit_str = "----Exit-"; | 54 | static char *acpi_gbl_fn_exit_str = "----Exit-"; |
54 | 55 | ||
@@ -109,7 +110,7 @@ void acpi_ut_track_stack_ptr(void) | |||
109 | * RETURN: Updated pointer to the function name | 110 | * RETURN: Updated pointer to the function name |
110 | * | 111 | * |
111 | * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. | 112 | * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. |
112 | * This allows compiler macros such as __func__ to be used | 113 | * This allows compiler macros such as __FUNCTION__ to be used |
113 | * with no change to the debug output. | 114 | * with no change to the debug output. |
114 | * | 115 | * |
115 | ******************************************************************************/ | 116 | ******************************************************************************/ |
@@ -222,7 +223,7 @@ ACPI_EXPORT_SYMBOL(acpi_debug_print) | |||
222 | * | 223 | * |
223 | * RETURN: None | 224 | * RETURN: None |
224 | * | 225 | * |
225 | * DESCRIPTION: Print message with no headers. Has same interface as | 226 | * DESCRIPTION: Print message with no headers. Has same interface as |
226 | * debug_print so that the same macros can be used. | 227 | * debug_print so that the same macros can be used. |
227 | * | 228 | * |
228 | ******************************************************************************/ | 229 | ******************************************************************************/ |
@@ -258,7 +259,7 @@ ACPI_EXPORT_SYMBOL(acpi_debug_print_raw) | |||
258 | * | 259 | * |
259 | * RETURN: None | 260 | * RETURN: None |
260 | * | 261 | * |
261 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is | 262 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
262 | * set in debug_level | 263 | * set in debug_level |
263 | * | 264 | * |
264 | ******************************************************************************/ | 265 | ******************************************************************************/ |
@@ -290,7 +291,7 @@ ACPI_EXPORT_SYMBOL(acpi_ut_trace) | |||
290 | * | 291 | * |
291 | * RETURN: None | 292 | * RETURN: None |
292 | * | 293 | * |
293 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is | 294 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
294 | * set in debug_level | 295 | * set in debug_level |
295 | * | 296 | * |
296 | ******************************************************************************/ | 297 | ******************************************************************************/ |
@@ -299,6 +300,7 @@ acpi_ut_trace_ptr(u32 line_number, | |||
299 | const char *function_name, | 300 | const char *function_name, |
300 | const char *module_name, u32 component_id, void *pointer) | 301 | const char *module_name, u32 component_id, void *pointer) |
301 | { | 302 | { |
303 | |||
302 | acpi_gbl_nesting_level++; | 304 | acpi_gbl_nesting_level++; |
303 | acpi_ut_track_stack_ptr(); | 305 | acpi_ut_track_stack_ptr(); |
304 | 306 | ||
@@ -319,7 +321,7 @@ acpi_ut_trace_ptr(u32 line_number, | |||
319 | * | 321 | * |
320 | * RETURN: None | 322 | * RETURN: None |
321 | * | 323 | * |
322 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is | 324 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
323 | * set in debug_level | 325 | * set in debug_level |
324 | * | 326 | * |
325 | ******************************************************************************/ | 327 | ******************************************************************************/ |
@@ -350,7 +352,7 @@ acpi_ut_trace_str(u32 line_number, | |||
350 | * | 352 | * |
351 | * RETURN: None | 353 | * RETURN: None |
352 | * | 354 | * |
353 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is | 355 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
354 | * set in debug_level | 356 | * set in debug_level |
355 | * | 357 | * |
356 | ******************************************************************************/ | 358 | ******************************************************************************/ |
@@ -380,7 +382,7 @@ acpi_ut_trace_u32(u32 line_number, | |||
380 | * | 382 | * |
381 | * RETURN: None | 383 | * RETURN: None |
382 | * | 384 | * |
383 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is | 385 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
384 | * set in debug_level | 386 | * set in debug_level |
385 | * | 387 | * |
386 | ******************************************************************************/ | 388 | ******************************************************************************/ |
@@ -412,7 +414,7 @@ ACPI_EXPORT_SYMBOL(acpi_ut_exit) | |||
412 | * | 414 | * |
413 | * RETURN: None | 415 | * RETURN: None |
414 | * | 416 | * |
415 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is | 417 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
416 | * set in debug_level. Prints exit status also. | 418 | * set in debug_level. Prints exit status also. |
417 | * | 419 | * |
418 | ******************************************************************************/ | 420 | ******************************************************************************/ |
@@ -453,7 +455,7 @@ ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) | |||
453 | * | 455 | * |
454 | * RETURN: None | 456 | * RETURN: None |
455 | * | 457 | * |
456 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is | 458 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
457 | * set in debug_level. Prints exit value also. | 459 | * set in debug_level. Prints exit value also. |
458 | * | 460 | * |
459 | ******************************************************************************/ | 461 | ******************************************************************************/ |
@@ -485,7 +487,7 @@ ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) | |||
485 | * | 487 | * |
486 | * RETURN: None | 488 | * RETURN: None |
487 | * | 489 | * |
488 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is | 490 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
489 | * set in debug_level. Prints exit value also. | 491 | * set in debug_level. Prints exit value also. |
490 | * | 492 | * |
491 | ******************************************************************************/ | 493 | ******************************************************************************/ |
@@ -511,7 +513,7 @@ acpi_ut_ptr_exit(u32 line_number, | |||
511 | * PARAMETERS: buffer - Buffer to dump | 513 | * PARAMETERS: buffer - Buffer to dump |
512 | * count - Amount to dump, in bytes | 514 | * count - Amount to dump, in bytes |
513 | * display - BYTE, WORD, DWORD, or QWORD display | 515 | * display - BYTE, WORD, DWORD, or QWORD display |
514 | * component_ID - Caller's component ID | 516 | * offset - Beginning buffer offset (display only) |
515 | * | 517 | * |
516 | * RETURN: None | 518 | * RETURN: None |
517 | * | 519 | * |
@@ -519,7 +521,7 @@ acpi_ut_ptr_exit(u32 line_number, | |||
519 | * | 521 | * |
520 | ******************************************************************************/ | 522 | ******************************************************************************/ |
521 | 523 | ||
522 | void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display) | 524 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) |
523 | { | 525 | { |
524 | u32 i = 0; | 526 | u32 i = 0; |
525 | u32 j; | 527 | u32 j; |
@@ -541,7 +543,7 @@ void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display) | |||
541 | 543 | ||
542 | /* Print current offset */ | 544 | /* Print current offset */ |
543 | 545 | ||
544 | acpi_os_printf("%6.4X: ", i); | 546 | acpi_os_printf("%6.4X: ", (base_offset + i)); |
545 | 547 | ||
546 | /* Print 16 hex chars */ | 548 | /* Print 16 hex chars */ |
547 | 549 | ||
@@ -623,7 +625,7 @@ void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display) | |||
623 | 625 | ||
624 | /******************************************************************************* | 626 | /******************************************************************************* |
625 | * | 627 | * |
626 | * FUNCTION: acpi_ut_dump_buffer | 628 | * FUNCTION: acpi_ut_debug_dump_buffer |
627 | * | 629 | * |
628 | * PARAMETERS: buffer - Buffer to dump | 630 | * PARAMETERS: buffer - Buffer to dump |
629 | * count - Amount to dump, in bytes | 631 | * count - Amount to dump, in bytes |
@@ -636,7 +638,8 @@ void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display) | |||
636 | * | 638 | * |
637 | ******************************************************************************/ | 639 | ******************************************************************************/ |
638 | 640 | ||
639 | void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id) | 641 | void |
642 | acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id) | ||
640 | { | 643 | { |
641 | 644 | ||
642 | /* Only dump the buffer if tracing is enabled */ | 645 | /* Only dump the buffer if tracing is enabled */ |
@@ -646,5 +649,5 @@ void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id) | |||
646 | return; | 649 | return; |
647 | } | 650 | } |
648 | 651 | ||
649 | acpi_ut_dump_buffer2(buffer, count, display); | 652 | acpi_ut_dump_buffer(buffer, count, display, 0); |
650 | } | 653 | } |
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c index 5d84e1954575..774c3aefbf5d 100644 --- a/drivers/acpi/acpica/utids.c +++ b/drivers/acpi/acpica/utids.c | |||
@@ -67,10 +67,10 @@ ACPI_MODULE_NAME("utids") | |||
67 | ******************************************************************************/ | 67 | ******************************************************************************/ |
68 | acpi_status | 68 | acpi_status |
69 | acpi_ut_execute_HID(struct acpi_namespace_node *device_node, | 69 | acpi_ut_execute_HID(struct acpi_namespace_node *device_node, |
70 | struct acpica_device_id **return_id) | 70 | struct acpi_pnp_device_id **return_id) |
71 | { | 71 | { |
72 | union acpi_operand_object *obj_desc; | 72 | union acpi_operand_object *obj_desc; |
73 | struct acpica_device_id *hid; | 73 | struct acpi_pnp_device_id *hid; |
74 | u32 length; | 74 | u32 length; |
75 | acpi_status status; | 75 | acpi_status status; |
76 | 76 | ||
@@ -94,16 +94,17 @@ acpi_ut_execute_HID(struct acpi_namespace_node *device_node, | |||
94 | /* Allocate a buffer for the HID */ | 94 | /* Allocate a buffer for the HID */ |
95 | 95 | ||
96 | hid = | 96 | hid = |
97 | ACPI_ALLOCATE_ZEROED(sizeof(struct acpica_device_id) + | 97 | ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + |
98 | (acpi_size) length); | 98 | (acpi_size) length); |
99 | if (!hid) { | 99 | if (!hid) { |
100 | status = AE_NO_MEMORY; | 100 | status = AE_NO_MEMORY; |
101 | goto cleanup; | 101 | goto cleanup; |
102 | } | 102 | } |
103 | 103 | ||
104 | /* Area for the string starts after DEVICE_ID struct */ | 104 | /* Area for the string starts after PNP_DEVICE_ID struct */ |
105 | 105 | ||
106 | hid->string = ACPI_ADD_PTR(char, hid, sizeof(struct acpica_device_id)); | 106 | hid->string = |
107 | ACPI_ADD_PTR(char, hid, sizeof(struct acpi_pnp_device_id)); | ||
107 | 108 | ||
108 | /* Convert EISAID to a string or simply copy existing string */ | 109 | /* Convert EISAID to a string or simply copy existing string */ |
109 | 110 | ||
@@ -126,6 +127,73 @@ cleanup: | |||
126 | 127 | ||
127 | /******************************************************************************* | 128 | /******************************************************************************* |
128 | * | 129 | * |
130 | * FUNCTION: acpi_ut_execute_SUB | ||
131 | * | ||
132 | * PARAMETERS: device_node - Node for the device | ||
133 | * return_id - Where the _SUB is returned | ||
134 | * | ||
135 | * RETURN: Status | ||
136 | * | ||
137 | * DESCRIPTION: Executes the _SUB control method that returns the subsystem | ||
138 | * ID of the device. The _SUB value is always a string containing | ||
139 | * either a valid PNP or ACPI ID. | ||
140 | * | ||
141 | * NOTE: Internal function, no parameter validation | ||
142 | * | ||
143 | ******************************************************************************/ | ||
144 | |||
145 | acpi_status | ||
146 | acpi_ut_execute_SUB(struct acpi_namespace_node *device_node, | ||
147 | struct acpi_pnp_device_id **return_id) | ||
148 | { | ||
149 | union acpi_operand_object *obj_desc; | ||
150 | struct acpi_pnp_device_id *sub; | ||
151 | u32 length; | ||
152 | acpi_status status; | ||
153 | |||
154 | ACPI_FUNCTION_TRACE(ut_execute_SUB); | ||
155 | |||
156 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__SUB, | ||
157 | ACPI_BTYPE_STRING, &obj_desc); | ||
158 | if (ACPI_FAILURE(status)) { | ||
159 | return_ACPI_STATUS(status); | ||
160 | } | ||
161 | |||
162 | /* Get the size of the String to be returned, includes null terminator */ | ||
163 | |||
164 | length = obj_desc->string.length + 1; | ||
165 | |||
166 | /* Allocate a buffer for the SUB */ | ||
167 | |||
168 | sub = | ||
169 | ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + | ||
170 | (acpi_size) length); | ||
171 | if (!sub) { | ||
172 | status = AE_NO_MEMORY; | ||
173 | goto cleanup; | ||
174 | } | ||
175 | |||
176 | /* Area for the string starts after PNP_DEVICE_ID struct */ | ||
177 | |||
178 | sub->string = | ||
179 | ACPI_ADD_PTR(char, sub, sizeof(struct acpi_pnp_device_id)); | ||
180 | |||
181 | /* Simply copy existing string */ | ||
182 | |||
183 | ACPI_STRCPY(sub->string, obj_desc->string.pointer); | ||
184 | sub->length = length; | ||
185 | *return_id = sub; | ||
186 | |||
187 | cleanup: | ||
188 | |||
189 | /* On exit, we must delete the return object */ | ||
190 | |||
191 | acpi_ut_remove_reference(obj_desc); | ||
192 | return_ACPI_STATUS(status); | ||
193 | } | ||
194 | |||
195 | /******************************************************************************* | ||
196 | * | ||
129 | * FUNCTION: acpi_ut_execute_UID | 197 | * FUNCTION: acpi_ut_execute_UID |
130 | * | 198 | * |
131 | * PARAMETERS: device_node - Node for the device | 199 | * PARAMETERS: device_node - Node for the device |
@@ -144,10 +212,10 @@ cleanup: | |||
144 | 212 | ||
145 | acpi_status | 213 | acpi_status |
146 | acpi_ut_execute_UID(struct acpi_namespace_node *device_node, | 214 | acpi_ut_execute_UID(struct acpi_namespace_node *device_node, |
147 | struct acpica_device_id **return_id) | 215 | struct acpi_pnp_device_id **return_id) |
148 | { | 216 | { |
149 | union acpi_operand_object *obj_desc; | 217 | union acpi_operand_object *obj_desc; |
150 | struct acpica_device_id *uid; | 218 | struct acpi_pnp_device_id *uid; |
151 | u32 length; | 219 | u32 length; |
152 | acpi_status status; | 220 | acpi_status status; |
153 | 221 | ||
@@ -171,16 +239,17 @@ acpi_ut_execute_UID(struct acpi_namespace_node *device_node, | |||
171 | /* Allocate a buffer for the UID */ | 239 | /* Allocate a buffer for the UID */ |
172 | 240 | ||
173 | uid = | 241 | uid = |
174 | ACPI_ALLOCATE_ZEROED(sizeof(struct acpica_device_id) + | 242 | ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + |
175 | (acpi_size) length); | 243 | (acpi_size) length); |
176 | if (!uid) { | 244 | if (!uid) { |
177 | status = AE_NO_MEMORY; | 245 | status = AE_NO_MEMORY; |
178 | goto cleanup; | 246 | goto cleanup; |
179 | } | 247 | } |
180 | 248 | ||
181 | /* Area for the string starts after DEVICE_ID struct */ | 249 | /* Area for the string starts after PNP_DEVICE_ID struct */ |
182 | 250 | ||
183 | uid->string = ACPI_ADD_PTR(char, uid, sizeof(struct acpica_device_id)); | 251 | uid->string = |
252 | ACPI_ADD_PTR(char, uid, sizeof(struct acpi_pnp_device_id)); | ||
184 | 253 | ||
185 | /* Convert an Integer to string, or just copy an existing string */ | 254 | /* Convert an Integer to string, or just copy an existing string */ |
186 | 255 | ||
@@ -226,11 +295,11 @@ cleanup: | |||
226 | 295 | ||
227 | acpi_status | 296 | acpi_status |
228 | acpi_ut_execute_CID(struct acpi_namespace_node *device_node, | 297 | acpi_ut_execute_CID(struct acpi_namespace_node *device_node, |
229 | struct acpica_device_id_list **return_cid_list) | 298 | struct acpi_pnp_device_id_list **return_cid_list) |
230 | { | 299 | { |
231 | union acpi_operand_object **cid_objects; | 300 | union acpi_operand_object **cid_objects; |
232 | union acpi_operand_object *obj_desc; | 301 | union acpi_operand_object *obj_desc; |
233 | struct acpica_device_id_list *cid_list; | 302 | struct acpi_pnp_device_id_list *cid_list; |
234 | char *next_id_string; | 303 | char *next_id_string; |
235 | u32 string_area_size; | 304 | u32 string_area_size; |
236 | u32 length; | 305 | u32 length; |
@@ -288,11 +357,12 @@ acpi_ut_execute_CID(struct acpi_namespace_node *device_node, | |||
288 | /* | 357 | /* |
289 | * Now that we know the length of the CIDs, allocate return buffer: | 358 | * Now that we know the length of the CIDs, allocate return buffer: |
290 | * 1) Size of the base structure + | 359 | * 1) Size of the base structure + |
291 | * 2) Size of the CID DEVICE_ID array + | 360 | * 2) Size of the CID PNP_DEVICE_ID array + |
292 | * 3) Size of the actual CID strings | 361 | * 3) Size of the actual CID strings |
293 | */ | 362 | */ |
294 | cid_list_size = sizeof(struct acpica_device_id_list) + | 363 | cid_list_size = sizeof(struct acpi_pnp_device_id_list) + |
295 | ((count - 1) * sizeof(struct acpica_device_id)) + string_area_size; | 364 | ((count - 1) * sizeof(struct acpi_pnp_device_id)) + |
365 | string_area_size; | ||
296 | 366 | ||
297 | cid_list = ACPI_ALLOCATE_ZEROED(cid_list_size); | 367 | cid_list = ACPI_ALLOCATE_ZEROED(cid_list_size); |
298 | if (!cid_list) { | 368 | if (!cid_list) { |
@@ -300,10 +370,10 @@ acpi_ut_execute_CID(struct acpi_namespace_node *device_node, | |||
300 | goto cleanup; | 370 | goto cleanup; |
301 | } | 371 | } |
302 | 372 | ||
303 | /* Area for CID strings starts after the CID DEVICE_ID array */ | 373 | /* Area for CID strings starts after the CID PNP_DEVICE_ID array */ |
304 | 374 | ||
305 | next_id_string = ACPI_CAST_PTR(char, cid_list->ids) + | 375 | next_id_string = ACPI_CAST_PTR(char, cid_list->ids) + |
306 | ((acpi_size) count * sizeof(struct acpica_device_id)); | 376 | ((acpi_size) count * sizeof(struct acpi_pnp_device_id)); |
307 | 377 | ||
308 | /* Copy/convert the CIDs to the return buffer */ | 378 | /* Copy/convert the CIDs to the return buffer */ |
309 | 379 | ||
diff --git a/drivers/acpi/acpica/utmath.c b/drivers/acpi/acpica/utmath.c index d88a8aaab2a6..49563674833a 100644 --- a/drivers/acpi/acpica/utmath.c +++ b/drivers/acpi/acpica/utmath.c | |||
@@ -81,7 +81,7 @@ typedef union uint64_overlay { | |||
81 | * RETURN: Status (Checks for divide-by-zero) | 81 | * RETURN: Status (Checks for divide-by-zero) |
82 | * | 82 | * |
83 | * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits) | 83 | * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits) |
84 | * divide and modulo. The result is a 64-bit quotient and a | 84 | * divide and modulo. The result is a 64-bit quotient and a |
85 | * 32-bit remainder. | 85 | * 32-bit remainder. |
86 | * | 86 | * |
87 | ******************************************************************************/ | 87 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c index 33c6cf7ff467..9286a69eb9aa 100644 --- a/drivers/acpi/acpica/utmisc.c +++ b/drivers/acpi/acpica/utmisc.c | |||
@@ -41,8 +41,6 @@ | |||
41 | * POSSIBILITY OF SUCH DAMAGES. | 41 | * POSSIBILITY OF SUCH DAMAGES. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #include <linux/module.h> | ||
45 | |||
46 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
47 | #include "accommon.h" | 45 | #include "accommon.h" |
48 | #include "acnamesp.h" | 46 | #include "acnamesp.h" |
@@ -201,8 +199,8 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) | |||
201 | */ | 199 | */ |
202 | acpi_gbl_owner_id_mask[j] |= (1 << k); | 200 | acpi_gbl_owner_id_mask[j] |= (1 << k); |
203 | 201 | ||
204 | acpi_gbl_last_owner_id_index = (u8) j; | 202 | acpi_gbl_last_owner_id_index = (u8)j; |
205 | acpi_gbl_next_owner_id_offset = (u8) (k + 1); | 203 | acpi_gbl_next_owner_id_offset = (u8)(k + 1); |
206 | 204 | ||
207 | /* | 205 | /* |
208 | * Construct encoded ID from the index and bit position | 206 | * Construct encoded ID from the index and bit position |
@@ -252,7 +250,7 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) | |||
252 | * control method or unloading a table. Either way, we would | 250 | * control method or unloading a table. Either way, we would |
253 | * ignore any error anyway. | 251 | * ignore any error anyway. |
254 | * | 252 | * |
255 | * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 | 253 | * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 |
256 | * | 254 | * |
257 | ******************************************************************************/ | 255 | ******************************************************************************/ |
258 | 256 | ||
@@ -339,6 +337,73 @@ void acpi_ut_strupr(char *src_string) | |||
339 | return; | 337 | return; |
340 | } | 338 | } |
341 | 339 | ||
340 | #ifdef ACPI_ASL_COMPILER | ||
341 | /******************************************************************************* | ||
342 | * | ||
343 | * FUNCTION: acpi_ut_strlwr (strlwr) | ||
344 | * | ||
345 | * PARAMETERS: src_string - The source string to convert | ||
346 | * | ||
347 | * RETURN: None | ||
348 | * | ||
349 | * DESCRIPTION: Convert string to lowercase | ||
350 | * | ||
351 | * NOTE: This is not a POSIX function, so it appears here, not in utclib.c | ||
352 | * | ||
353 | ******************************************************************************/ | ||
354 | |||
355 | void acpi_ut_strlwr(char *src_string) | ||
356 | { | ||
357 | char *string; | ||
358 | |||
359 | ACPI_FUNCTION_ENTRY(); | ||
360 | |||
361 | if (!src_string) { | ||
362 | return; | ||
363 | } | ||
364 | |||
365 | /* Walk entire string, lowercasing the letters */ | ||
366 | |||
367 | for (string = src_string; *string; string++) { | ||
368 | *string = (char)ACPI_TOLOWER(*string); | ||
369 | } | ||
370 | |||
371 | return; | ||
372 | } | ||
373 | |||
374 | /****************************************************************************** | ||
375 | * | ||
376 | * FUNCTION: acpi_ut_stricmp | ||
377 | * | ||
378 | * PARAMETERS: string1 - first string to compare | ||
379 | * string2 - second string to compare | ||
380 | * | ||
381 | * RETURN: int that signifies string relationship. Zero means strings | ||
382 | * are equal. | ||
383 | * | ||
384 | * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare | ||
385 | * strings with no case sensitivity) | ||
386 | * | ||
387 | ******************************************************************************/ | ||
388 | |||
389 | int acpi_ut_stricmp(char *string1, char *string2) | ||
390 | { | ||
391 | int c1; | ||
392 | int c2; | ||
393 | |||
394 | do { | ||
395 | c1 = tolower((int)*string1); | ||
396 | c2 = tolower((int)*string2); | ||
397 | |||
398 | string1++; | ||
399 | string2++; | ||
400 | } | ||
401 | while ((c1 == c2) && (c1)); | ||
402 | |||
403 | return (c1 - c2); | ||
404 | } | ||
405 | #endif | ||
406 | |||
342 | /******************************************************************************* | 407 | /******************************************************************************* |
343 | * | 408 | * |
344 | * FUNCTION: acpi_ut_print_string | 409 | * FUNCTION: acpi_ut_print_string |
@@ -469,8 +534,8 @@ u32 acpi_ut_dword_byte_swap(u32 value) | |||
469 | * RETURN: None | 534 | * RETURN: None |
470 | * | 535 | * |
471 | * DESCRIPTION: Set the global integer bit width based upon the revision | 536 | * DESCRIPTION: Set the global integer bit width based upon the revision |
472 | * of the DSDT. For Revision 1 and 0, Integers are 32 bits. | 537 | * of the DSDT. For Revision 1 and 0, Integers are 32 bits. |
473 | * For Revision 2 and above, Integers are 64 bits. Yes, this | 538 | * For Revision 2 and above, Integers are 64 bits. Yes, this |
474 | * makes a difference. | 539 | * makes a difference. |
475 | * | 540 | * |
476 | ******************************************************************************/ | 541 | ******************************************************************************/ |
@@ -606,7 +671,7 @@ u8 acpi_ut_valid_acpi_char(char character, u32 position) | |||
606 | * | 671 | * |
607 | * RETURN: TRUE if the name is valid, FALSE otherwise | 672 | * RETURN: TRUE if the name is valid, FALSE otherwise |
608 | * | 673 | * |
609 | * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: | 674 | * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: |
610 | * 1) Upper case alpha | 675 | * 1) Upper case alpha |
611 | * 2) numeric | 676 | * 2) numeric |
612 | * 3) underscore | 677 | * 3) underscore |
@@ -638,29 +703,59 @@ u8 acpi_ut_valid_acpi_name(u32 name) | |||
638 | * RETURN: Repaired version of the name | 703 | * RETURN: Repaired version of the name |
639 | * | 704 | * |
640 | * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and | 705 | * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and |
641 | * return the new name. | 706 | * return the new name. NOTE: the Name parameter must reside in |
707 | * read/write memory, cannot be a const. | ||
708 | * | ||
709 | * An ACPI Name must consist of valid ACPI characters. We will repair the name | ||
710 | * if necessary because we don't want to abort because of this, but we want | ||
711 | * all namespace names to be printable. A warning message is appropriate. | ||
712 | * | ||
713 | * This issue came up because there are in fact machines that exhibit | ||
714 | * this problem, and we want to be able to enable ACPI support for them, | ||
715 | * even though there are a few bad names. | ||
642 | * | 716 | * |
643 | ******************************************************************************/ | 717 | ******************************************************************************/ |
644 | 718 | ||
645 | acpi_name acpi_ut_repair_name(char *name) | 719 | void acpi_ut_repair_name(char *name) |
646 | { | 720 | { |
647 | u32 i; | 721 | u32 i; |
648 | char new_name[ACPI_NAME_SIZE]; | 722 | u8 found_bad_char = FALSE; |
723 | u32 original_name; | ||
724 | |||
725 | ACPI_FUNCTION_NAME(ut_repair_name); | ||
726 | |||
727 | ACPI_MOVE_NAME(&original_name, name); | ||
728 | |||
729 | /* Check each character in the name */ | ||
649 | 730 | ||
650 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | 731 | for (i = 0; i < ACPI_NAME_SIZE; i++) { |
651 | new_name[i] = name[i]; | 732 | if (acpi_ut_valid_acpi_char(name[i], i)) { |
733 | continue; | ||
734 | } | ||
652 | 735 | ||
653 | /* | 736 | /* |
654 | * Replace a bad character with something printable, yet technically | 737 | * Replace a bad character with something printable, yet technically |
655 | * still invalid. This prevents any collisions with existing "good" | 738 | * still invalid. This prevents any collisions with existing "good" |
656 | * names in the namespace. | 739 | * names in the namespace. |
657 | */ | 740 | */ |
658 | if (!acpi_ut_valid_acpi_char(name[i], i)) { | 741 | name[i] = '*'; |
659 | new_name[i] = '*'; | 742 | found_bad_char = TRUE; |
660 | } | ||
661 | } | 743 | } |
662 | 744 | ||
663 | return (*(u32 *) new_name); | 745 | if (found_bad_char) { |
746 | |||
747 | /* Report warning only if in strict mode or debug mode */ | ||
748 | |||
749 | if (!acpi_gbl_enable_interpreter_slack) { | ||
750 | ACPI_WARNING((AE_INFO, | ||
751 | "Found bad character(s) in name, repaired: [%4.4s]\n", | ||
752 | name)); | ||
753 | } else { | ||
754 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
755 | "Found bad character(s) in name, repaired: [%4.4s]\n", | ||
756 | name)); | ||
757 | } | ||
758 | } | ||
664 | } | 759 | } |
665 | 760 | ||
666 | /******************************************************************************* | 761 | /******************************************************************************* |
@@ -681,7 +776,7 @@ acpi_name acpi_ut_repair_name(char *name) | |||
681 | * | 776 | * |
682 | ******************************************************************************/ | 777 | ******************************************************************************/ |
683 | 778 | ||
684 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer) | 779 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) |
685 | { | 780 | { |
686 | u32 this_digit = 0; | 781 | u32 this_digit = 0; |
687 | u64 return_value = 0; | 782 | u64 return_value = 0; |
@@ -754,14 +849,14 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer) | |||
754 | 849 | ||
755 | /* Convert ASCII 0-9 to Decimal value */ | 850 | /* Convert ASCII 0-9 to Decimal value */ |
756 | 851 | ||
757 | this_digit = ((u8) * string) - '0'; | 852 | this_digit = ((u8)*string) - '0'; |
758 | } else if (base == 10) { | 853 | } else if (base == 10) { |
759 | 854 | ||
760 | /* Digit is out of range; possible in to_integer case only */ | 855 | /* Digit is out of range; possible in to_integer case only */ |
761 | 856 | ||
762 | term = 1; | 857 | term = 1; |
763 | } else { | 858 | } else { |
764 | this_digit = (u8) ACPI_TOUPPER(*string); | 859 | this_digit = (u8)ACPI_TOUPPER(*string); |
765 | if (ACPI_IS_XDIGIT((char)this_digit)) { | 860 | if (ACPI_IS_XDIGIT((char)this_digit)) { |
766 | 861 | ||
767 | /* Convert ASCII Hex char to value */ | 862 | /* Convert ASCII Hex char to value */ |
@@ -788,8 +883,9 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer) | |||
788 | 883 | ||
789 | valid_digits++; | 884 | valid_digits++; |
790 | 885 | ||
791 | if (sign_of0x && ((valid_digits > 16) | 886 | if (sign_of0x |
792 | || ((valid_digits > 8) && mode32))) { | 887 | && ((valid_digits > 16) |
888 | || ((valid_digits > 8) && mode32))) { | ||
793 | /* | 889 | /* |
794 | * This is to_integer operation case. | 890 | * This is to_integer operation case. |
795 | * No any restrictions for string-to-integer conversion, | 891 | * No any restrictions for string-to-integer conversion, |
@@ -800,7 +896,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer) | |||
800 | 896 | ||
801 | /* Divide the digit into the correct position */ | 897 | /* Divide the digit into the correct position */ |
802 | 898 | ||
803 | (void)acpi_ut_short_divide((dividend - (u64) this_digit), | 899 | (void)acpi_ut_short_divide((dividend - (u64)this_digit), |
804 | base, "ient, NULL); | 900 | base, "ient, NULL); |
805 | 901 | ||
806 | if (return_value > quotient) { | 902 | if (return_value > quotient) { |
@@ -890,7 +986,7 @@ acpi_ut_create_update_state_and_push(union acpi_operand_object *object, | |||
890 | ******************************************************************************/ | 986 | ******************************************************************************/ |
891 | 987 | ||
892 | acpi_status | 988 | acpi_status |
893 | acpi_ut_walk_package_tree(union acpi_operand_object * source_object, | 989 | acpi_ut_walk_package_tree(union acpi_operand_object *source_object, |
894 | void *target_object, | 990 | void *target_object, |
895 | acpi_pkg_callback walk_callback, void *context) | 991 | acpi_pkg_callback walk_callback, void *context) |
896 | { | 992 | { |
@@ -917,10 +1013,10 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object, | |||
917 | 1013 | ||
918 | /* | 1014 | /* |
919 | * Check for: | 1015 | * Check for: |
920 | * 1) An uninitialized package element. It is completely | 1016 | * 1) An uninitialized package element. It is completely |
921 | * legal to declare a package and leave it uninitialized | 1017 | * legal to declare a package and leave it uninitialized |
922 | * 2) Not an internal object - can be a namespace node instead | 1018 | * 2) Not an internal object - can be a namespace node instead |
923 | * 3) Any type other than a package. Packages are handled in else | 1019 | * 3) Any type other than a package. Packages are handled in else |
924 | * case below. | 1020 | * case below. |
925 | */ | 1021 | */ |
926 | if ((!this_source_obj) || | 1022 | if ((!this_source_obj) || |
@@ -939,7 +1035,7 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object, | |||
939 | state->pkg.source_object->package.count) { | 1035 | state->pkg.source_object->package.count) { |
940 | /* | 1036 | /* |
941 | * We've handled all of the objects at this level, This means | 1037 | * We've handled all of the objects at this level, This means |
942 | * that we have just completed a package. That package may | 1038 | * that we have just completed a package. That package may |
943 | * have contained one or more packages itself. | 1039 | * have contained one or more packages itself. |
944 | * | 1040 | * |
945 | * Delete this state and pop the previous state (package). | 1041 | * Delete this state and pop the previous state (package). |
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c index 296baa676bc5..5ccf57c0d87e 100644 --- a/drivers/acpi/acpica/utmutex.c +++ b/drivers/acpi/acpica/utmutex.c | |||
@@ -193,6 +193,8 @@ static void acpi_ut_delete_mutex(acpi_mutex_handle mutex_id) | |||
193 | 193 | ||
194 | acpi_gbl_mutex_info[mutex_id].mutex = NULL; | 194 | acpi_gbl_mutex_info[mutex_id].mutex = NULL; |
195 | acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; | 195 | acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; |
196 | |||
197 | return_VOID; | ||
196 | } | 198 | } |
197 | 199 | ||
198 | /******************************************************************************* | 200 | /******************************************************************************* |
@@ -226,9 +228,9 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) | |||
226 | /* | 228 | /* |
227 | * Mutex debug code, for internal debugging only. | 229 | * Mutex debug code, for internal debugging only. |
228 | * | 230 | * |
229 | * Deadlock prevention. Check if this thread owns any mutexes of value | 231 | * Deadlock prevention. Check if this thread owns any mutexes of value |
230 | * greater than or equal to this one. If so, the thread has violated | 232 | * greater than or equal to this one. If so, the thread has violated |
231 | * the mutex ordering rule. This indicates a coding error somewhere in | 233 | * the mutex ordering rule. This indicates a coding error somewhere in |
232 | * the ACPI subsystem code. | 234 | * the ACPI subsystem code. |
233 | */ | 235 | */ |
234 | for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) { | 236 | for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) { |
@@ -319,9 +321,9 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) | |||
319 | /* | 321 | /* |
320 | * Mutex debug code, for internal debugging only. | 322 | * Mutex debug code, for internal debugging only. |
321 | * | 323 | * |
322 | * Deadlock prevention. Check if this thread owns any mutexes of value | 324 | * Deadlock prevention. Check if this thread owns any mutexes of value |
323 | * greater than this one. If so, the thread has violated the mutex | 325 | * greater than this one. If so, the thread has violated the mutex |
324 | * ordering rule. This indicates a coding error somewhere in | 326 | * ordering rule. This indicates a coding error somewhere in |
325 | * the ACPI subsystem code. | 327 | * the ACPI subsystem code. |
326 | */ | 328 | */ |
327 | for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) { | 329 | for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) { |
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c index 655f0799a391..5c52ca78f6fa 100644 --- a/drivers/acpi/acpica/utobject.c +++ b/drivers/acpi/acpica/utobject.c | |||
@@ -77,7 +77,7 @@ acpi_ut_get_element_length(u8 object_type, | |||
77 | * | 77 | * |
78 | * NOTE: We always allocate the worst-case object descriptor because | 78 | * NOTE: We always allocate the worst-case object descriptor because |
79 | * these objects are cached, and we want them to be | 79 | * these objects are cached, and we want them to be |
80 | * one-size-satisifies-any-request. This in itself may not be | 80 | * one-size-satisifies-any-request. This in itself may not be |
81 | * the most memory efficient, but the efficiency of the object | 81 | * the most memory efficient, but the efficiency of the object |
82 | * cache should more than make up for this! | 82 | * cache should more than make up for this! |
83 | * | 83 | * |
@@ -370,9 +370,9 @@ u8 acpi_ut_valid_internal_object(void *object) | |||
370 | * line_number - Caller's line number (for error output) | 370 | * line_number - Caller's line number (for error output) |
371 | * component_id - Caller's component ID (for error output) | 371 | * component_id - Caller's component ID (for error output) |
372 | * | 372 | * |
373 | * RETURN: Pointer to newly allocated object descriptor. Null on error | 373 | * RETURN: Pointer to newly allocated object descriptor. Null on error |
374 | * | 374 | * |
375 | * DESCRIPTION: Allocate a new object descriptor. Gracefully handle | 375 | * DESCRIPTION: Allocate a new object descriptor. Gracefully handle |
376 | * error conditions. | 376 | * error conditions. |
377 | * | 377 | * |
378 | ******************************************************************************/ | 378 | ******************************************************************************/ |
@@ -554,7 +554,7 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, | |||
554 | 554 | ||
555 | /* | 555 | /* |
556 | * Account for the space required by the object rounded up to the next | 556 | * Account for the space required by the object rounded up to the next |
557 | * multiple of the machine word size. This keeps each object aligned | 557 | * multiple of the machine word size. This keeps each object aligned |
558 | * on a machine word boundary. (preventing alignment faults on some | 558 | * on a machine word boundary. (preventing alignment faults on some |
559 | * machines.) | 559 | * machines.) |
560 | */ | 560 | */ |
diff --git a/drivers/acpi/acpica/utstate.c b/drivers/acpi/acpica/utstate.c index a1c988260073..cee0473ba813 100644 --- a/drivers/acpi/acpica/utstate.c +++ b/drivers/acpi/acpica/utstate.c | |||
@@ -147,7 +147,7 @@ union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state | |||
147 | * | 147 | * |
148 | * RETURN: The new state object. NULL on failure. | 148 | * RETURN: The new state object. NULL on failure. |
149 | * | 149 | * |
150 | * DESCRIPTION: Create a generic state object. Attempt to obtain one from | 150 | * DESCRIPTION: Create a generic state object. Attempt to obtain one from |
151 | * the global state cache; If none available, create a new one. | 151 | * the global state cache; If none available, create a new one. |
152 | * | 152 | * |
153 | ******************************************************************************/ | 153 | ******************************************************************************/ |
diff --git a/drivers/acpi/acpica/uttrack.c b/drivers/acpi/acpica/uttrack.c new file mode 100644 index 000000000000..a424a9e3fea4 --- /dev/null +++ b/drivers/acpi/acpica/uttrack.c | |||
@@ -0,0 +1,692 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: uttrack - Memory allocation tracking routines (debug only) | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | /* | ||
45 | * These procedures are used for tracking memory leaks in the subsystem, and | ||
46 | * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set. | ||
47 | * | ||
48 | * Each memory allocation is tracked via a doubly linked list. Each | ||
49 | * element contains the caller's component, module name, function name, and | ||
50 | * line number. acpi_ut_allocate and acpi_ut_allocate_zeroed call | ||
51 | * acpi_ut_track_allocation to add an element to the list; deletion | ||
52 | * occurs in the body of acpi_ut_free. | ||
53 | */ | ||
54 | |||
55 | #include <acpi/acpi.h> | ||
56 | #include "accommon.h" | ||
57 | |||
58 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | ||
59 | |||
60 | #define _COMPONENT ACPI_UTILITIES | ||
61 | ACPI_MODULE_NAME("uttrack") | ||
62 | |||
63 | /* Local prototypes */ | ||
64 | static struct acpi_debug_mem_block *acpi_ut_find_allocation(struct | ||
65 | acpi_debug_mem_block | ||
66 | *allocation); | ||
67 | |||
68 | static acpi_status | ||
69 | acpi_ut_track_allocation(struct acpi_debug_mem_block *address, | ||
70 | acpi_size size, | ||
71 | u8 alloc_type, | ||
72 | u32 component, const char *module, u32 line); | ||
73 | |||
74 | static acpi_status | ||
75 | acpi_ut_remove_allocation(struct acpi_debug_mem_block *address, | ||
76 | u32 component, const char *module, u32 line); | ||
77 | |||
78 | /******************************************************************************* | ||
79 | * | ||
80 | * FUNCTION: acpi_ut_create_list | ||
81 | * | ||
82 | * PARAMETERS: cache_name - Ascii name for the cache | ||
83 | * object_size - Size of each cached object | ||
84 | * return_cache - Where the new cache object is returned | ||
85 | * | ||
86 | * RETURN: Status | ||
87 | * | ||
88 | * DESCRIPTION: Create a local memory list for tracking purposed | ||
89 | * | ||
90 | ******************************************************************************/ | ||
91 | |||
92 | acpi_status | ||
93 | acpi_ut_create_list(char *list_name, | ||
94 | u16 object_size, struct acpi_memory_list **return_cache) | ||
95 | { | ||
96 | struct acpi_memory_list *cache; | ||
97 | |||
98 | cache = acpi_os_allocate(sizeof(struct acpi_memory_list)); | ||
99 | if (!cache) { | ||
100 | return (AE_NO_MEMORY); | ||
101 | } | ||
102 | |||
103 | ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list)); | ||
104 | |||
105 | cache->list_name = list_name; | ||
106 | cache->object_size = object_size; | ||
107 | |||
108 | *return_cache = cache; | ||
109 | return (AE_OK); | ||
110 | } | ||
111 | |||
112 | /******************************************************************************* | ||
113 | * | ||
114 | * FUNCTION: acpi_ut_allocate_and_track | ||
115 | * | ||
116 | * PARAMETERS: size - Size of the allocation | ||
117 | * component - Component type of caller | ||
118 | * module - Source file name of caller | ||
119 | * line - Line number of caller | ||
120 | * | ||
121 | * RETURN: Address of the allocated memory on success, NULL on failure. | ||
122 | * | ||
123 | * DESCRIPTION: The subsystem's equivalent of malloc. | ||
124 | * | ||
125 | ******************************************************************************/ | ||
126 | |||
127 | void *acpi_ut_allocate_and_track(acpi_size size, | ||
128 | u32 component, const char *module, u32 line) | ||
129 | { | ||
130 | struct acpi_debug_mem_block *allocation; | ||
131 | acpi_status status; | ||
132 | |||
133 | allocation = | ||
134 | acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header), | ||
135 | component, module, line); | ||
136 | if (!allocation) { | ||
137 | return (NULL); | ||
138 | } | ||
139 | |||
140 | status = acpi_ut_track_allocation(allocation, size, | ||
141 | ACPI_MEM_MALLOC, component, module, | ||
142 | line); | ||
143 | if (ACPI_FAILURE(status)) { | ||
144 | acpi_os_free(allocation); | ||
145 | return (NULL); | ||
146 | } | ||
147 | |||
148 | acpi_gbl_global_list->total_allocated++; | ||
149 | acpi_gbl_global_list->total_size += (u32)size; | ||
150 | acpi_gbl_global_list->current_total_size += (u32)size; | ||
151 | if (acpi_gbl_global_list->current_total_size > | ||
152 | acpi_gbl_global_list->max_occupied) { | ||
153 | acpi_gbl_global_list->max_occupied = | ||
154 | acpi_gbl_global_list->current_total_size; | ||
155 | } | ||
156 | |||
157 | return ((void *)&allocation->user_space); | ||
158 | } | ||
159 | |||
160 | /******************************************************************************* | ||
161 | * | ||
162 | * FUNCTION: acpi_ut_allocate_zeroed_and_track | ||
163 | * | ||
164 | * PARAMETERS: size - Size of the allocation | ||
165 | * component - Component type of caller | ||
166 | * module - Source file name of caller | ||
167 | * line - Line number of caller | ||
168 | * | ||
169 | * RETURN: Address of the allocated memory on success, NULL on failure. | ||
170 | * | ||
171 | * DESCRIPTION: Subsystem equivalent of calloc. | ||
172 | * | ||
173 | ******************************************************************************/ | ||
174 | |||
175 | void *acpi_ut_allocate_zeroed_and_track(acpi_size size, | ||
176 | u32 component, | ||
177 | const char *module, u32 line) | ||
178 | { | ||
179 | struct acpi_debug_mem_block *allocation; | ||
180 | acpi_status status; | ||
181 | |||
182 | allocation = | ||
183 | acpi_ut_allocate_zeroed(size + sizeof(struct acpi_debug_mem_header), | ||
184 | component, module, line); | ||
185 | if (!allocation) { | ||
186 | |||
187 | /* Report allocation error */ | ||
188 | |||
189 | ACPI_ERROR((module, line, | ||
190 | "Could not allocate size %u", (u32)size)); | ||
191 | return (NULL); | ||
192 | } | ||
193 | |||
194 | status = acpi_ut_track_allocation(allocation, size, | ||
195 | ACPI_MEM_CALLOC, component, module, | ||
196 | line); | ||
197 | if (ACPI_FAILURE(status)) { | ||
198 | acpi_os_free(allocation); | ||
199 | return (NULL); | ||
200 | } | ||
201 | |||
202 | acpi_gbl_global_list->total_allocated++; | ||
203 | acpi_gbl_global_list->total_size += (u32)size; | ||
204 | acpi_gbl_global_list->current_total_size += (u32)size; | ||
205 | if (acpi_gbl_global_list->current_total_size > | ||
206 | acpi_gbl_global_list->max_occupied) { | ||
207 | acpi_gbl_global_list->max_occupied = | ||
208 | acpi_gbl_global_list->current_total_size; | ||
209 | } | ||
210 | |||
211 | return ((void *)&allocation->user_space); | ||
212 | } | ||
213 | |||
214 | /******************************************************************************* | ||
215 | * | ||
216 | * FUNCTION: acpi_ut_free_and_track | ||
217 | * | ||
218 | * PARAMETERS: allocation - Address of the memory to deallocate | ||
219 | * component - Component type of caller | ||
220 | * module - Source file name of caller | ||
221 | * line - Line number of caller | ||
222 | * | ||
223 | * RETURN: None | ||
224 | * | ||
225 | * DESCRIPTION: Frees the memory at Allocation | ||
226 | * | ||
227 | ******************************************************************************/ | ||
228 | |||
229 | void | ||
230 | acpi_ut_free_and_track(void *allocation, | ||
231 | u32 component, const char *module, u32 line) | ||
232 | { | ||
233 | struct acpi_debug_mem_block *debug_block; | ||
234 | acpi_status status; | ||
235 | |||
236 | ACPI_FUNCTION_TRACE_PTR(ut_free, allocation); | ||
237 | |||
238 | if (NULL == allocation) { | ||
239 | ACPI_ERROR((module, line, "Attempt to delete a NULL address")); | ||
240 | |||
241 | return_VOID; | ||
242 | } | ||
243 | |||
244 | debug_block = ACPI_CAST_PTR(struct acpi_debug_mem_block, | ||
245 | (((char *)allocation) - | ||
246 | sizeof(struct acpi_debug_mem_header))); | ||
247 | |||
248 | acpi_gbl_global_list->total_freed++; | ||
249 | acpi_gbl_global_list->current_total_size -= debug_block->size; | ||
250 | |||
251 | status = acpi_ut_remove_allocation(debug_block, | ||
252 | component, module, line); | ||
253 | if (ACPI_FAILURE(status)) { | ||
254 | ACPI_EXCEPTION((AE_INFO, status, "Could not free memory")); | ||
255 | } | ||
256 | |||
257 | acpi_os_free(debug_block); | ||
258 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); | ||
259 | return_VOID; | ||
260 | } | ||
261 | |||
262 | /******************************************************************************* | ||
263 | * | ||
264 | * FUNCTION: acpi_ut_find_allocation | ||
265 | * | ||
266 | * PARAMETERS: allocation - Address of allocated memory | ||
267 | * | ||
268 | * RETURN: Three cases: | ||
269 | * 1) List is empty, NULL is returned. | ||
270 | * 2) Element was found. Returns Allocation parameter. | ||
271 | * 3) Element was not found. Returns position where it should be | ||
272 | * inserted into the list. | ||
273 | * | ||
274 | * DESCRIPTION: Searches for an element in the global allocation tracking list. | ||
275 | * If the element is not found, returns the location within the | ||
276 | * list where the element should be inserted. | ||
277 | * | ||
278 | * Note: The list is ordered by larger-to-smaller addresses. | ||
279 | * | ||
280 | * This global list is used to detect memory leaks in ACPICA as | ||
281 | * well as other issues such as an attempt to release the same | ||
282 | * internal object more than once. Although expensive as far | ||
283 | * as cpu time, this list is much more helpful for finding these | ||
284 | * types of issues than using memory leak detectors outside of | ||
285 | * the ACPICA code. | ||
286 | * | ||
287 | ******************************************************************************/ | ||
288 | |||
289 | static struct acpi_debug_mem_block *acpi_ut_find_allocation(struct | ||
290 | acpi_debug_mem_block | ||
291 | *allocation) | ||
292 | { | ||
293 | struct acpi_debug_mem_block *element; | ||
294 | |||
295 | element = acpi_gbl_global_list->list_head; | ||
296 | if (!element) { | ||
297 | return (NULL); | ||
298 | } | ||
299 | |||
300 | /* | ||
301 | * Search for the address. | ||
302 | * | ||
303 | * Note: List is ordered by larger-to-smaller addresses, on the | ||
304 | * assumption that a new allocation usually has a larger address | ||
305 | * than previous allocations. | ||
306 | */ | ||
307 | while (element > allocation) { | ||
308 | |||
309 | /* Check for end-of-list */ | ||
310 | |||
311 | if (!element->next) { | ||
312 | return (element); | ||
313 | } | ||
314 | |||
315 | element = element->next; | ||
316 | } | ||
317 | |||
318 | if (element == allocation) { | ||
319 | return (element); | ||
320 | } | ||
321 | |||
322 | return (element->previous); | ||
323 | } | ||
324 | |||
325 | /******************************************************************************* | ||
326 | * | ||
327 | * FUNCTION: acpi_ut_track_allocation | ||
328 | * | ||
329 | * PARAMETERS: allocation - Address of allocated memory | ||
330 | * size - Size of the allocation | ||
331 | * alloc_type - MEM_MALLOC or MEM_CALLOC | ||
332 | * component - Component type of caller | ||
333 | * module - Source file name of caller | ||
334 | * line - Line number of caller | ||
335 | * | ||
336 | * RETURN: Status | ||
337 | * | ||
338 | * DESCRIPTION: Inserts an element into the global allocation tracking list. | ||
339 | * | ||
340 | ******************************************************************************/ | ||
341 | |||
342 | static acpi_status | ||
343 | acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation, | ||
344 | acpi_size size, | ||
345 | u8 alloc_type, | ||
346 | u32 component, const char *module, u32 line) | ||
347 | { | ||
348 | struct acpi_memory_list *mem_list; | ||
349 | struct acpi_debug_mem_block *element; | ||
350 | acpi_status status = AE_OK; | ||
351 | |||
352 | ACPI_FUNCTION_TRACE_PTR(ut_track_allocation, allocation); | ||
353 | |||
354 | if (acpi_gbl_disable_mem_tracking) { | ||
355 | return_ACPI_STATUS(AE_OK); | ||
356 | } | ||
357 | |||
358 | mem_list = acpi_gbl_global_list; | ||
359 | status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY); | ||
360 | if (ACPI_FAILURE(status)) { | ||
361 | return_ACPI_STATUS(status); | ||
362 | } | ||
363 | |||
364 | /* | ||
365 | * Search the global list for this address to make sure it is not | ||
366 | * already present. This will catch several kinds of problems. | ||
367 | */ | ||
368 | element = acpi_ut_find_allocation(allocation); | ||
369 | if (element == allocation) { | ||
370 | ACPI_ERROR((AE_INFO, | ||
371 | "UtTrackAllocation: Allocation (%p) already present in global list!", | ||
372 | allocation)); | ||
373 | goto unlock_and_exit; | ||
374 | } | ||
375 | |||
376 | /* Fill in the instance data */ | ||
377 | |||
378 | allocation->size = (u32)size; | ||
379 | allocation->alloc_type = alloc_type; | ||
380 | allocation->component = component; | ||
381 | allocation->line = line; | ||
382 | |||
383 | ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME); | ||
384 | allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0; | ||
385 | |||
386 | if (!element) { | ||
387 | |||
388 | /* Insert at list head */ | ||
389 | |||
390 | if (mem_list->list_head) { | ||
391 | ((struct acpi_debug_mem_block *)(mem_list->list_head))-> | ||
392 | previous = allocation; | ||
393 | } | ||
394 | |||
395 | allocation->next = mem_list->list_head; | ||
396 | allocation->previous = NULL; | ||
397 | |||
398 | mem_list->list_head = allocation; | ||
399 | } else { | ||
400 | /* Insert after element */ | ||
401 | |||
402 | allocation->next = element->next; | ||
403 | allocation->previous = element; | ||
404 | |||
405 | if (element->next) { | ||
406 | (element->next)->previous = allocation; | ||
407 | } | ||
408 | |||
409 | element->next = allocation; | ||
410 | } | ||
411 | |||
412 | unlock_and_exit: | ||
413 | status = acpi_ut_release_mutex(ACPI_MTX_MEMORY); | ||
414 | return_ACPI_STATUS(status); | ||
415 | } | ||
416 | |||
417 | /******************************************************************************* | ||
418 | * | ||
419 | * FUNCTION: acpi_ut_remove_allocation | ||
420 | * | ||
421 | * PARAMETERS: allocation - Address of allocated memory | ||
422 | * component - Component type of caller | ||
423 | * module - Source file name of caller | ||
424 | * line - Line number of caller | ||
425 | * | ||
426 | * RETURN: Status | ||
427 | * | ||
428 | * DESCRIPTION: Deletes an element from the global allocation tracking list. | ||
429 | * | ||
430 | ******************************************************************************/ | ||
431 | |||
432 | static acpi_status | ||
433 | acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation, | ||
434 | u32 component, const char *module, u32 line) | ||
435 | { | ||
436 | struct acpi_memory_list *mem_list; | ||
437 | acpi_status status; | ||
438 | |||
439 | ACPI_FUNCTION_TRACE(ut_remove_allocation); | ||
440 | |||
441 | if (acpi_gbl_disable_mem_tracking) { | ||
442 | return_ACPI_STATUS(AE_OK); | ||
443 | } | ||
444 | |||
445 | mem_list = acpi_gbl_global_list; | ||
446 | if (NULL == mem_list->list_head) { | ||
447 | |||
448 | /* No allocations! */ | ||
449 | |||
450 | ACPI_ERROR((module, line, | ||
451 | "Empty allocation list, nothing to free!")); | ||
452 | |||
453 | return_ACPI_STATUS(AE_OK); | ||
454 | } | ||
455 | |||
456 | status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY); | ||
457 | if (ACPI_FAILURE(status)) { | ||
458 | return_ACPI_STATUS(status); | ||
459 | } | ||
460 | |||
461 | /* Unlink */ | ||
462 | |||
463 | if (allocation->previous) { | ||
464 | (allocation->previous)->next = allocation->next; | ||
465 | } else { | ||
466 | mem_list->list_head = allocation->next; | ||
467 | } | ||
468 | |||
469 | if (allocation->next) { | ||
470 | (allocation->next)->previous = allocation->previous; | ||
471 | } | ||
472 | |||
473 | /* Mark the segment as deleted */ | ||
474 | |||
475 | ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size); | ||
476 | |||
477 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", | ||
478 | allocation->size)); | ||
479 | |||
480 | status = acpi_ut_release_mutex(ACPI_MTX_MEMORY); | ||
481 | return_ACPI_STATUS(status); | ||
482 | } | ||
483 | |||
484 | /******************************************************************************* | ||
485 | * | ||
486 | * FUNCTION: acpi_ut_dump_allocation_info | ||
487 | * | ||
488 | * PARAMETERS: None | ||
489 | * | ||
490 | * RETURN: None | ||
491 | * | ||
492 | * DESCRIPTION: Print some info about the outstanding allocations. | ||
493 | * | ||
494 | ******************************************************************************/ | ||
495 | |||
496 | void acpi_ut_dump_allocation_info(void) | ||
497 | { | ||
498 | /* | ||
499 | struct acpi_memory_list *mem_list; | ||
500 | */ | ||
501 | |||
502 | ACPI_FUNCTION_TRACE(ut_dump_allocation_info); | ||
503 | |||
504 | /* | ||
505 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, | ||
506 | ("%30s: %4d (%3d Kb)\n", "Current allocations", | ||
507 | mem_list->current_count, | ||
508 | ROUND_UP_TO_1K (mem_list->current_size))); | ||
509 | |||
510 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, | ||
511 | ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", | ||
512 | mem_list->max_concurrent_count, | ||
513 | ROUND_UP_TO_1K (mem_list->max_concurrent_size))); | ||
514 | |||
515 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, | ||
516 | ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", | ||
517 | running_object_count, | ||
518 | ROUND_UP_TO_1K (running_object_size))); | ||
519 | |||
520 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, | ||
521 | ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", | ||
522 | running_alloc_count, | ||
523 | ROUND_UP_TO_1K (running_alloc_size))); | ||
524 | |||
525 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, | ||
526 | ("%30s: %4d (%3d Kb)\n", "Current Nodes", | ||
527 | acpi_gbl_current_node_count, | ||
528 | ROUND_UP_TO_1K (acpi_gbl_current_node_size))); | ||
529 | |||
530 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, | ||
531 | ("%30s: %4d (%3d Kb)\n", "Max Nodes", | ||
532 | acpi_gbl_max_concurrent_node_count, | ||
533 | ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count * | ||
534 | sizeof (struct acpi_namespace_node))))); | ||
535 | */ | ||
536 | return_VOID; | ||
537 | } | ||
538 | |||
539 | /******************************************************************************* | ||
540 | * | ||
541 | * FUNCTION: acpi_ut_dump_allocations | ||
542 | * | ||
543 | * PARAMETERS: component - Component(s) to dump info for. | ||
544 | * module - Module to dump info for. NULL means all. | ||
545 | * | ||
546 | * RETURN: None | ||
547 | * | ||
548 | * DESCRIPTION: Print a list of all outstanding allocations. | ||
549 | * | ||
550 | ******************************************************************************/ | ||
551 | |||
552 | void acpi_ut_dump_allocations(u32 component, const char *module) | ||
553 | { | ||
554 | struct acpi_debug_mem_block *element; | ||
555 | union acpi_descriptor *descriptor; | ||
556 | u32 num_outstanding = 0; | ||
557 | u8 descriptor_type; | ||
558 | |||
559 | ACPI_FUNCTION_TRACE(ut_dump_allocations); | ||
560 | |||
561 | if (acpi_gbl_disable_mem_tracking) { | ||
562 | return_VOID; | ||
563 | } | ||
564 | |||
565 | /* | ||
566 | * Walk the allocation list. | ||
567 | */ | ||
568 | if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) { | ||
569 | return_VOID; | ||
570 | } | ||
571 | |||
572 | element = acpi_gbl_global_list->list_head; | ||
573 | while (element) { | ||
574 | if ((element->component & component) && | ||
575 | ((module == NULL) | ||
576 | || (0 == ACPI_STRCMP(module, element->module)))) { | ||
577 | descriptor = | ||
578 | ACPI_CAST_PTR(union acpi_descriptor, | ||
579 | &element->user_space); | ||
580 | |||
581 | if (element->size < | ||
582 | sizeof(struct acpi_common_descriptor)) { | ||
583 | acpi_os_printf("%p Length 0x%04X %9.9s-%u " | ||
584 | "[Not a Descriptor - too small]\n", | ||
585 | descriptor, element->size, | ||
586 | element->module, element->line); | ||
587 | } else { | ||
588 | /* Ignore allocated objects that are in a cache */ | ||
589 | |||
590 | if (ACPI_GET_DESCRIPTOR_TYPE(descriptor) != | ||
591 | ACPI_DESC_TYPE_CACHED) { | ||
592 | acpi_os_printf | ||
593 | ("%p Length 0x%04X %9.9s-%u [%s] ", | ||
594 | descriptor, element->size, | ||
595 | element->module, element->line, | ||
596 | acpi_ut_get_descriptor_name | ||
597 | (descriptor)); | ||
598 | |||
599 | /* Validate the descriptor type using Type field and length */ | ||
600 | |||
601 | descriptor_type = 0; /* Not a valid descriptor type */ | ||
602 | |||
603 | switch (ACPI_GET_DESCRIPTOR_TYPE | ||
604 | (descriptor)) { | ||
605 | case ACPI_DESC_TYPE_OPERAND: | ||
606 | if (element->size == | ||
607 | sizeof(union | ||
608 | acpi_operand_object)) | ||
609 | { | ||
610 | descriptor_type = | ||
611 | ACPI_DESC_TYPE_OPERAND; | ||
612 | } | ||
613 | break; | ||
614 | |||
615 | case ACPI_DESC_TYPE_PARSER: | ||
616 | if (element->size == | ||
617 | sizeof(union | ||
618 | acpi_parse_object)) { | ||
619 | descriptor_type = | ||
620 | ACPI_DESC_TYPE_PARSER; | ||
621 | } | ||
622 | break; | ||
623 | |||
624 | case ACPI_DESC_TYPE_NAMED: | ||
625 | if (element->size == | ||
626 | sizeof(struct | ||
627 | acpi_namespace_node)) | ||
628 | { | ||
629 | descriptor_type = | ||
630 | ACPI_DESC_TYPE_NAMED; | ||
631 | } | ||
632 | break; | ||
633 | |||
634 | default: | ||
635 | break; | ||
636 | } | ||
637 | |||
638 | /* Display additional info for the major descriptor types */ | ||
639 | |||
640 | switch (descriptor_type) { | ||
641 | case ACPI_DESC_TYPE_OPERAND: | ||
642 | acpi_os_printf | ||
643 | ("%12.12s RefCount 0x%04X\n", | ||
644 | acpi_ut_get_type_name | ||
645 | (descriptor->object.common. | ||
646 | type), | ||
647 | descriptor->object.common. | ||
648 | reference_count); | ||
649 | break; | ||
650 | |||
651 | case ACPI_DESC_TYPE_PARSER: | ||
652 | acpi_os_printf | ||
653 | ("AmlOpcode 0x%04hX\n", | ||
654 | descriptor->op.asl. | ||
655 | aml_opcode); | ||
656 | break; | ||
657 | |||
658 | case ACPI_DESC_TYPE_NAMED: | ||
659 | acpi_os_printf("%4.4s\n", | ||
660 | acpi_ut_get_node_name | ||
661 | (&descriptor-> | ||
662 | node)); | ||
663 | break; | ||
664 | |||
665 | default: | ||
666 | acpi_os_printf("\n"); | ||
667 | break; | ||
668 | } | ||
669 | } | ||
670 | } | ||
671 | |||
672 | num_outstanding++; | ||
673 | } | ||
674 | |||
675 | element = element->next; | ||
676 | } | ||
677 | |||
678 | (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY); | ||
679 | |||
680 | /* Print summary */ | ||
681 | |||
682 | if (!num_outstanding) { | ||
683 | ACPI_INFO((AE_INFO, "No outstanding allocations")); | ||
684 | } else { | ||
685 | ACPI_ERROR((AE_INFO, "%u(0x%X) Outstanding allocations", | ||
686 | num_outstanding, num_outstanding)); | ||
687 | } | ||
688 | |||
689 | return_VOID; | ||
690 | } | ||
691 | |||
692 | #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ | ||
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c index b09632b4f5b3..390db0ca5e2e 100644 --- a/drivers/acpi/acpica/utxface.c +++ b/drivers/acpi/acpica/utxface.c | |||
@@ -147,7 +147,7 @@ ACPI_EXPORT_SYMBOL(acpi_subsystem_status) | |||
147 | * RETURN: status - the status of the call | 147 | * RETURN: status - the status of the call |
148 | * | 148 | * |
149 | * DESCRIPTION: This function is called to get information about the current | 149 | * DESCRIPTION: This function is called to get information about the current |
150 | * state of the ACPI subsystem. It will return system information | 150 | * state of the ACPI subsystem. It will return system information |
151 | * in the out_buffer. | 151 | * in the out_buffer. |
152 | * | 152 | * |
153 | * If the function fails an appropriate status will be returned | 153 | * If the function fails an appropriate status will be returned |
@@ -238,7 +238,7 @@ acpi_install_initialization_handler(acpi_init_handler handler, u32 function) | |||
238 | } | 238 | } |
239 | 239 | ||
240 | acpi_gbl_init_handler = handler; | 240 | acpi_gbl_init_handler = handler; |
241 | return AE_OK; | 241 | return (AE_OK); |
242 | } | 242 | } |
243 | 243 | ||
244 | ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler) | 244 | ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler) |
@@ -263,6 +263,7 @@ acpi_status acpi_purge_cached_objects(void) | |||
263 | (void)acpi_os_purge_cache(acpi_gbl_operand_cache); | 263 | (void)acpi_os_purge_cache(acpi_gbl_operand_cache); |
264 | (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache); | 264 | (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache); |
265 | (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache); | 265 | (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache); |
266 | |||
266 | return_ACPI_STATUS(AE_OK); | 267 | return_ACPI_STATUS(AE_OK); |
267 | } | 268 | } |
268 | 269 | ||
diff --git a/drivers/acpi/acpica/utxferror.c b/drivers/acpi/acpica/utxferror.c index 6d63cc39b9ae..d4d3826140d8 100644 --- a/drivers/acpi/acpica/utxferror.c +++ b/drivers/acpi/acpica/utxferror.c | |||
@@ -408,7 +408,7 @@ acpi_ut_namespace_error(const char *module_name, | |||
408 | 408 | ||
409 | ACPI_MOVE_32_TO_32(&bad_name, | 409 | ACPI_MOVE_32_TO_32(&bad_name, |
410 | ACPI_CAST_PTR(u32, internal_name)); | 410 | ACPI_CAST_PTR(u32, internal_name)); |
411 | acpi_os_printf("[0x%4.4X] (NON-ASCII)", bad_name); | 411 | acpi_os_printf("[0x%.8X] (NON-ASCII)", bad_name); |
412 | } else { | 412 | } else { |
413 | /* Convert path to external format */ | 413 | /* Convert path to external format */ |
414 | 414 | ||
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index d59175efc428..1f0d457ecbcf 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -257,7 +257,15 @@ static int __acpi_bus_get_power(struct acpi_device *device, int *state) | |||
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | static int __acpi_bus_set_power(struct acpi_device *device, int state) | 260 | /** |
261 | * acpi_device_set_power - Set power state of an ACPI device. | ||
262 | * @device: Device to set the power state of. | ||
263 | * @state: New power state to set. | ||
264 | * | ||
265 | * Callers must ensure that the device is power manageable before using this | ||
266 | * function. | ||
267 | */ | ||
268 | int acpi_device_set_power(struct acpi_device *device, int state) | ||
261 | { | 269 | { |
262 | int result = 0; | 270 | int result = 0; |
263 | acpi_status status = AE_OK; | 271 | acpi_status status = AE_OK; |
@@ -298,6 +306,12 @@ static int __acpi_bus_set_power(struct acpi_device *device, int state) | |||
298 | * a lower-powered state. | 306 | * a lower-powered state. |
299 | */ | 307 | */ |
300 | if (state < device->power.state) { | 308 | if (state < device->power.state) { |
309 | if (device->power.state >= ACPI_STATE_D3_HOT && | ||
310 | state != ACPI_STATE_D0) { | ||
311 | printk(KERN_WARNING PREFIX | ||
312 | "Cannot transition to non-D0 state from D3\n"); | ||
313 | return -ENODEV; | ||
314 | } | ||
301 | if (device->power.flags.power_resources) { | 315 | if (device->power.flags.power_resources) { |
302 | result = acpi_power_transition(device, state); | 316 | result = acpi_power_transition(device, state); |
303 | if (result) | 317 | if (result) |
@@ -341,6 +355,7 @@ static int __acpi_bus_set_power(struct acpi_device *device, int state) | |||
341 | 355 | ||
342 | return result; | 356 | return result; |
343 | } | 357 | } |
358 | EXPORT_SYMBOL(acpi_device_set_power); | ||
344 | 359 | ||
345 | 360 | ||
346 | int acpi_bus_set_power(acpi_handle handle, int state) | 361 | int acpi_bus_set_power(acpi_handle handle, int state) |
@@ -359,7 +374,7 @@ int acpi_bus_set_power(acpi_handle handle, int state) | |||
359 | return -ENODEV; | 374 | return -ENODEV; |
360 | } | 375 | } |
361 | 376 | ||
362 | return __acpi_bus_set_power(device, state); | 377 | return acpi_device_set_power(device, state); |
363 | } | 378 | } |
364 | EXPORT_SYMBOL(acpi_bus_set_power); | 379 | EXPORT_SYMBOL(acpi_bus_set_power); |
365 | 380 | ||
@@ -402,7 +417,7 @@ int acpi_bus_update_power(acpi_handle handle, int *state_p) | |||
402 | if (result) | 417 | if (result) |
403 | return result; | 418 | return result; |
404 | 419 | ||
405 | result = __acpi_bus_set_power(device, state); | 420 | result = acpi_device_set_power(device, state); |
406 | if (!result && state_p) | 421 | if (!result && state_p) |
407 | *state_p = state; | 422 | *state_p = state; |
408 | 423 | ||
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c new file mode 100644 index 000000000000..f09dc987cf17 --- /dev/null +++ b/drivers/acpi/device_pm.c | |||
@@ -0,0 +1,668 @@ | |||
1 | /* | ||
2 | * drivers/acpi/device_pm.c - ACPI device power management routines. | ||
3 | * | ||
4 | * Copyright (C) 2012, Intel Corp. | ||
5 | * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
6 | * | ||
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as published | ||
11 | * by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License along | ||
19 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
21 | * | ||
22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
23 | */ | ||
24 | |||
25 | #include <linux/device.h> | ||
26 | #include <linux/export.h> | ||
27 | #include <linux/mutex.h> | ||
28 | #include <linux/pm_qos.h> | ||
29 | #include <linux/pm_runtime.h> | ||
30 | |||
31 | #include <acpi/acpi.h> | ||
32 | #include <acpi/acpi_bus.h> | ||
33 | |||
34 | static DEFINE_MUTEX(acpi_pm_notifier_lock); | ||
35 | |||
36 | /** | ||
37 | * acpi_add_pm_notifier - Register PM notifier for given ACPI device. | ||
38 | * @adev: ACPI device to add the notifier for. | ||
39 | * @context: Context information to pass to the notifier routine. | ||
40 | * | ||
41 | * NOTE: @adev need not be a run-wake or wakeup device to be a valid source of | ||
42 | * PM wakeup events. For example, wakeup events may be generated for bridges | ||
43 | * if one of the devices below the bridge is signaling wakeup, even if the | ||
44 | * bridge itself doesn't have a wakeup GPE associated with it. | ||
45 | */ | ||
46 | acpi_status acpi_add_pm_notifier(struct acpi_device *adev, | ||
47 | acpi_notify_handler handler, void *context) | ||
48 | { | ||
49 | acpi_status status = AE_ALREADY_EXISTS; | ||
50 | |||
51 | mutex_lock(&acpi_pm_notifier_lock); | ||
52 | |||
53 | if (adev->wakeup.flags.notifier_present) | ||
54 | goto out; | ||
55 | |||
56 | status = acpi_install_notify_handler(adev->handle, | ||
57 | ACPI_SYSTEM_NOTIFY, | ||
58 | handler, context); | ||
59 | if (ACPI_FAILURE(status)) | ||
60 | goto out; | ||
61 | |||
62 | adev->wakeup.flags.notifier_present = true; | ||
63 | |||
64 | out: | ||
65 | mutex_unlock(&acpi_pm_notifier_lock); | ||
66 | return status; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * acpi_remove_pm_notifier - Unregister PM notifier from given ACPI device. | ||
71 | * @adev: ACPI device to remove the notifier from. | ||
72 | */ | ||
73 | acpi_status acpi_remove_pm_notifier(struct acpi_device *adev, | ||
74 | acpi_notify_handler handler) | ||
75 | { | ||
76 | acpi_status status = AE_BAD_PARAMETER; | ||
77 | |||
78 | mutex_lock(&acpi_pm_notifier_lock); | ||
79 | |||
80 | if (!adev->wakeup.flags.notifier_present) | ||
81 | goto out; | ||
82 | |||
83 | status = acpi_remove_notify_handler(adev->handle, | ||
84 | ACPI_SYSTEM_NOTIFY, | ||
85 | handler); | ||
86 | if (ACPI_FAILURE(status)) | ||
87 | goto out; | ||
88 | |||
89 | adev->wakeup.flags.notifier_present = false; | ||
90 | |||
91 | out: | ||
92 | mutex_unlock(&acpi_pm_notifier_lock); | ||
93 | return status; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * acpi_device_power_state - Get preferred power state of ACPI device. | ||
98 | * @dev: Device whose preferred target power state to return. | ||
99 | * @adev: ACPI device node corresponding to @dev. | ||
100 | * @target_state: System state to match the resultant device state. | ||
101 | * @d_max_in: Deepest low-power state to take into consideration. | ||
102 | * @d_min_p: Location to store the upper limit of the allowed states range. | ||
103 | * Return value: Preferred power state of the device on success, -ENODEV | ||
104 | * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure | ||
105 | * | ||
106 | * Find the lowest power (highest number) ACPI device power state that the | ||
107 | * device can be in while the system is in the state represented by | ||
108 | * @target_state. If @d_min_p is set, the highest power (lowest number) device | ||
109 | * power state that @dev can be in for the given system sleep state is stored | ||
110 | * at the location pointed to by it. | ||
111 | * | ||
112 | * Callers must ensure that @dev and @adev are valid pointers and that @adev | ||
113 | * actually corresponds to @dev before using this function. | ||
114 | */ | ||
115 | int acpi_device_power_state(struct device *dev, struct acpi_device *adev, | ||
116 | u32 target_state, int d_max_in, int *d_min_p) | ||
117 | { | ||
118 | char acpi_method[] = "_SxD"; | ||
119 | unsigned long long d_min, d_max; | ||
120 | bool wakeup = false; | ||
121 | |||
122 | if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3) | ||
123 | return -EINVAL; | ||
124 | |||
125 | if (d_max_in > ACPI_STATE_D3_HOT) { | ||
126 | enum pm_qos_flags_status stat; | ||
127 | |||
128 | stat = dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF); | ||
129 | if (stat == PM_QOS_FLAGS_ALL) | ||
130 | d_max_in = ACPI_STATE_D3_HOT; | ||
131 | } | ||
132 | |||
133 | acpi_method[2] = '0' + target_state; | ||
134 | /* | ||
135 | * If the sleep state is S0, the lowest limit from ACPI is D3, | ||
136 | * but if the device has _S0W, we will use the value from _S0W | ||
137 | * as the lowest limit from ACPI. Finally, we will constrain | ||
138 | * the lowest limit with the specified one. | ||
139 | */ | ||
140 | d_min = ACPI_STATE_D0; | ||
141 | d_max = ACPI_STATE_D3; | ||
142 | |||
143 | /* | ||
144 | * If present, _SxD methods return the minimum D-state (highest power | ||
145 | * state) we can use for the corresponding S-states. Otherwise, the | ||
146 | * minimum D-state is D0 (ACPI 3.x). | ||
147 | * | ||
148 | * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer | ||
149 | * provided -- that's our fault recovery, we ignore retval. | ||
150 | */ | ||
151 | if (target_state > ACPI_STATE_S0) { | ||
152 | acpi_evaluate_integer(adev->handle, acpi_method, NULL, &d_min); | ||
153 | wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid | ||
154 | && adev->wakeup.sleep_state >= target_state; | ||
155 | } else if (dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) != | ||
156 | PM_QOS_FLAGS_NONE) { | ||
157 | wakeup = adev->wakeup.flags.valid; | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * If _PRW says we can wake up the system from the target sleep state, | ||
162 | * the D-state returned by _SxD is sufficient for that (we assume a | ||
163 | * wakeup-aware driver if wake is set). Still, if _SxW exists | ||
164 | * (ACPI 3.x), it should return the maximum (lowest power) D-state that | ||
165 | * can wake the system. _S0W may be valid, too. | ||
166 | */ | ||
167 | if (wakeup) { | ||
168 | acpi_status status; | ||
169 | |||
170 | acpi_method[3] = 'W'; | ||
171 | status = acpi_evaluate_integer(adev->handle, acpi_method, NULL, | ||
172 | &d_max); | ||
173 | if (ACPI_FAILURE(status)) { | ||
174 | if (target_state != ACPI_STATE_S0 || | ||
175 | status != AE_NOT_FOUND) | ||
176 | d_max = d_min; | ||
177 | } else if (d_max < d_min) { | ||
178 | /* Warn the user of the broken DSDT */ | ||
179 | printk(KERN_WARNING "ACPI: Wrong value from %s\n", | ||
180 | acpi_method); | ||
181 | /* Sanitize it */ | ||
182 | d_min = d_max; | ||
183 | } | ||
184 | } | ||
185 | |||
186 | if (d_max_in < d_min) | ||
187 | return -EINVAL; | ||
188 | if (d_min_p) | ||
189 | *d_min_p = d_min; | ||
190 | /* constrain d_max with specified lowest limit (max number) */ | ||
191 | if (d_max > d_max_in) { | ||
192 | for (d_max = d_max_in; d_max > d_min; d_max--) { | ||
193 | if (adev->power.states[d_max].flags.valid) | ||
194 | break; | ||
195 | } | ||
196 | } | ||
197 | return d_max; | ||
198 | } | ||
199 | EXPORT_SYMBOL_GPL(acpi_device_power_state); | ||
200 | |||
201 | /** | ||
202 | * acpi_pm_device_sleep_state - Get preferred power state of ACPI device. | ||
203 | * @dev: Device whose preferred target power state to return. | ||
204 | * @d_min_p: Location to store the upper limit of the allowed states range. | ||
205 | * @d_max_in: Deepest low-power state to take into consideration. | ||
206 | * Return value: Preferred power state of the device on success, -ENODEV | ||
207 | * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure | ||
208 | * | ||
209 | * The caller must ensure that @dev is valid before using this function. | ||
210 | */ | ||
211 | int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) | ||
212 | { | ||
213 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | ||
214 | struct acpi_device *adev; | ||
215 | |||
216 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { | ||
217 | dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); | ||
218 | return -ENODEV; | ||
219 | } | ||
220 | |||
221 | return acpi_device_power_state(dev, adev, acpi_target_system_state(), | ||
222 | d_max_in, d_min_p); | ||
223 | } | ||
224 | EXPORT_SYMBOL(acpi_pm_device_sleep_state); | ||
225 | |||
226 | #ifdef CONFIG_PM_RUNTIME | ||
227 | /** | ||
228 | * acpi_wakeup_device - Wakeup notification handler for ACPI devices. | ||
229 | * @handle: ACPI handle of the device the notification is for. | ||
230 | * @event: Type of the signaled event. | ||
231 | * @context: Device corresponding to @handle. | ||
232 | */ | ||
233 | static void acpi_wakeup_device(acpi_handle handle, u32 event, void *context) | ||
234 | { | ||
235 | struct device *dev = context; | ||
236 | |||
237 | if (event == ACPI_NOTIFY_DEVICE_WAKE && dev) { | ||
238 | pm_wakeup_event(dev, 0); | ||
239 | pm_runtime_resume(dev); | ||
240 | } | ||
241 | } | ||
242 | |||
243 | /** | ||
244 | * __acpi_device_run_wake - Enable/disable runtime remote wakeup for device. | ||
245 | * @adev: ACPI device to enable/disable the remote wakeup for. | ||
246 | * @enable: Whether to enable or disable the wakeup functionality. | ||
247 | * | ||
248 | * Enable/disable the GPE associated with @adev so that it can generate | ||
249 | * wakeup signals for the device in response to external (remote) events and | ||
250 | * enable/disable device wakeup power. | ||
251 | * | ||
252 | * Callers must ensure that @adev is a valid ACPI device node before executing | ||
253 | * this function. | ||
254 | */ | ||
255 | int __acpi_device_run_wake(struct acpi_device *adev, bool enable) | ||
256 | { | ||
257 | struct acpi_device_wakeup *wakeup = &adev->wakeup; | ||
258 | |||
259 | if (enable) { | ||
260 | acpi_status res; | ||
261 | int error; | ||
262 | |||
263 | error = acpi_enable_wakeup_device_power(adev, ACPI_STATE_S0); | ||
264 | if (error) | ||
265 | return error; | ||
266 | |||
267 | res = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); | ||
268 | if (ACPI_FAILURE(res)) { | ||
269 | acpi_disable_wakeup_device_power(adev); | ||
270 | return -EIO; | ||
271 | } | ||
272 | } else { | ||
273 | acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); | ||
274 | acpi_disable_wakeup_device_power(adev); | ||
275 | } | ||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | /** | ||
280 | * acpi_pm_device_run_wake - Enable/disable remote wakeup for given device. | ||
281 | * @dev: Device to enable/disable the platform to wake up. | ||
282 | * @enable: Whether to enable or disable the wakeup functionality. | ||
283 | */ | ||
284 | int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) | ||
285 | { | ||
286 | struct acpi_device *adev; | ||
287 | acpi_handle handle; | ||
288 | |||
289 | if (!device_run_wake(phys_dev)) | ||
290 | return -EINVAL; | ||
291 | |||
292 | handle = DEVICE_ACPI_HANDLE(phys_dev); | ||
293 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { | ||
294 | dev_dbg(phys_dev, "ACPI handle without context in %s!\n", | ||
295 | __func__); | ||
296 | return -ENODEV; | ||
297 | } | ||
298 | |||
299 | return __acpi_device_run_wake(adev, enable); | ||
300 | } | ||
301 | EXPORT_SYMBOL(acpi_pm_device_run_wake); | ||
302 | #else | ||
303 | static inline void acpi_wakeup_device(acpi_handle handle, u32 event, | ||
304 | void *context) {} | ||
305 | #endif /* CONFIG_PM_RUNTIME */ | ||
306 | |||
307 | #ifdef CONFIG_PM_SLEEP | ||
308 | /** | ||
309 | * __acpi_device_sleep_wake - Enable or disable device to wake up the system. | ||
310 | * @dev: Device to enable/desible to wake up the system. | ||
311 | * @target_state: System state the device is supposed to wake up from. | ||
312 | * @enable: Whether to enable or disable @dev to wake up the system. | ||
313 | */ | ||
314 | int __acpi_device_sleep_wake(struct acpi_device *adev, u32 target_state, | ||
315 | bool enable) | ||
316 | { | ||
317 | return enable ? | ||
318 | acpi_enable_wakeup_device_power(adev, target_state) : | ||
319 | acpi_disable_wakeup_device_power(adev); | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * acpi_pm_device_sleep_wake - Enable or disable device to wake up the system. | ||
324 | * @dev: Device to enable/desible to wake up the system from sleep states. | ||
325 | * @enable: Whether to enable or disable @dev to wake up the system. | ||
326 | */ | ||
327 | int acpi_pm_device_sleep_wake(struct device *dev, bool enable) | ||
328 | { | ||
329 | acpi_handle handle; | ||
330 | struct acpi_device *adev; | ||
331 | int error; | ||
332 | |||
333 | if (!device_can_wakeup(dev)) | ||
334 | return -EINVAL; | ||
335 | |||
336 | handle = DEVICE_ACPI_HANDLE(dev); | ||
337 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { | ||
338 | dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); | ||
339 | return -ENODEV; | ||
340 | } | ||
341 | |||
342 | error = __acpi_device_sleep_wake(adev, acpi_target_system_state(), | ||
343 | enable); | ||
344 | if (!error) | ||
345 | dev_info(dev, "System wakeup %s by ACPI\n", | ||
346 | enable ? "enabled" : "disabled"); | ||
347 | |||
348 | return error; | ||
349 | } | ||
350 | #endif /* CONFIG_PM_SLEEP */ | ||
351 | |||
352 | /** | ||
353 | * acpi_dev_pm_get_node - Get ACPI device node for the given physical device. | ||
354 | * @dev: Device to get the ACPI node for. | ||
355 | */ | ||
356 | static struct acpi_device *acpi_dev_pm_get_node(struct device *dev) | ||
357 | { | ||
358 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | ||
359 | struct acpi_device *adev; | ||
360 | |||
361 | return handle && ACPI_SUCCESS(acpi_bus_get_device(handle, &adev)) ? | ||
362 | adev : NULL; | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * acpi_dev_pm_low_power - Put ACPI device into a low-power state. | ||
367 | * @dev: Device to put into a low-power state. | ||
368 | * @adev: ACPI device node corresponding to @dev. | ||
369 | * @system_state: System state to choose the device state for. | ||
370 | */ | ||
371 | static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev, | ||
372 | u32 system_state) | ||
373 | { | ||
374 | int power_state; | ||
375 | |||
376 | if (!acpi_device_power_manageable(adev)) | ||
377 | return 0; | ||
378 | |||
379 | power_state = acpi_device_power_state(dev, adev, system_state, | ||
380 | ACPI_STATE_D3, NULL); | ||
381 | if (power_state < ACPI_STATE_D0 || power_state > ACPI_STATE_D3) | ||
382 | return -EIO; | ||
383 | |||
384 | return acpi_device_set_power(adev, power_state); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * acpi_dev_pm_full_power - Put ACPI device into the full-power state. | ||
389 | * @adev: ACPI device node to put into the full-power state. | ||
390 | */ | ||
391 | static int acpi_dev_pm_full_power(struct acpi_device *adev) | ||
392 | { | ||
393 | return acpi_device_power_manageable(adev) ? | ||
394 | acpi_device_set_power(adev, ACPI_STATE_D0) : 0; | ||
395 | } | ||
396 | |||
397 | #ifdef CONFIG_PM_RUNTIME | ||
398 | /** | ||
399 | * acpi_dev_runtime_suspend - Put device into a low-power state using ACPI. | ||
400 | * @dev: Device to put into a low-power state. | ||
401 | * | ||
402 | * Put the given device into a runtime low-power state using the standard ACPI | ||
403 | * mechanism. Set up remote wakeup if desired, choose the state to put the | ||
404 | * device into (this checks if remote wakeup is expected to work too), and set | ||
405 | * the power state of the device. | ||
406 | */ | ||
407 | int acpi_dev_runtime_suspend(struct device *dev) | ||
408 | { | ||
409 | struct acpi_device *adev = acpi_dev_pm_get_node(dev); | ||
410 | bool remote_wakeup; | ||
411 | int error; | ||
412 | |||
413 | if (!adev) | ||
414 | return 0; | ||
415 | |||
416 | remote_wakeup = dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) > | ||
417 | PM_QOS_FLAGS_NONE; | ||
418 | error = __acpi_device_run_wake(adev, remote_wakeup); | ||
419 | if (remote_wakeup && error) | ||
420 | return -EAGAIN; | ||
421 | |||
422 | error = acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); | ||
423 | if (error) | ||
424 | __acpi_device_run_wake(adev, false); | ||
425 | |||
426 | return error; | ||
427 | } | ||
428 | EXPORT_SYMBOL_GPL(acpi_dev_runtime_suspend); | ||
429 | |||
430 | /** | ||
431 | * acpi_dev_runtime_resume - Put device into the full-power state using ACPI. | ||
432 | * @dev: Device to put into the full-power state. | ||
433 | * | ||
434 | * Put the given device into the full-power state using the standard ACPI | ||
435 | * mechanism at run time. Set the power state of the device to ACPI D0 and | ||
436 | * disable remote wakeup. | ||
437 | */ | ||
438 | int acpi_dev_runtime_resume(struct device *dev) | ||
439 | { | ||
440 | struct acpi_device *adev = acpi_dev_pm_get_node(dev); | ||
441 | int error; | ||
442 | |||
443 | if (!adev) | ||
444 | return 0; | ||
445 | |||
446 | error = acpi_dev_pm_full_power(adev); | ||
447 | __acpi_device_run_wake(adev, false); | ||
448 | return error; | ||
449 | } | ||
450 | EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume); | ||
451 | |||
452 | /** | ||
453 | * acpi_subsys_runtime_suspend - Suspend device using ACPI. | ||
454 | * @dev: Device to suspend. | ||
455 | * | ||
456 | * Carry out the generic runtime suspend procedure for @dev and use ACPI to put | ||
457 | * it into a runtime low-power state. | ||
458 | */ | ||
459 | int acpi_subsys_runtime_suspend(struct device *dev) | ||
460 | { | ||
461 | int ret = pm_generic_runtime_suspend(dev); | ||
462 | return ret ? ret : acpi_dev_runtime_suspend(dev); | ||
463 | } | ||
464 | EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend); | ||
465 | |||
466 | /** | ||
467 | * acpi_subsys_runtime_resume - Resume device using ACPI. | ||
468 | * @dev: Device to Resume. | ||
469 | * | ||
470 | * Use ACPI to put the given device into the full-power state and carry out the | ||
471 | * generic runtime resume procedure for it. | ||
472 | */ | ||
473 | int acpi_subsys_runtime_resume(struct device *dev) | ||
474 | { | ||
475 | int ret = acpi_dev_runtime_resume(dev); | ||
476 | return ret ? ret : pm_generic_runtime_resume(dev); | ||
477 | } | ||
478 | EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume); | ||
479 | #endif /* CONFIG_PM_RUNTIME */ | ||
480 | |||
481 | #ifdef CONFIG_PM_SLEEP | ||
482 | /** | ||
483 | * acpi_dev_suspend_late - Put device into a low-power state using ACPI. | ||
484 | * @dev: Device to put into a low-power state. | ||
485 | * | ||
486 | * Put the given device into a low-power state during system transition to a | ||
487 | * sleep state using the standard ACPI mechanism. Set up system wakeup if | ||
488 | * desired, choose the state to put the device into (this checks if system | ||
489 | * wakeup is expected to work too), and set the power state of the device. | ||
490 | */ | ||
491 | int acpi_dev_suspend_late(struct device *dev) | ||
492 | { | ||
493 | struct acpi_device *adev = acpi_dev_pm_get_node(dev); | ||
494 | u32 target_state; | ||
495 | bool wakeup; | ||
496 | int error; | ||
497 | |||
498 | if (!adev) | ||
499 | return 0; | ||
500 | |||
501 | target_state = acpi_target_system_state(); | ||
502 | wakeup = device_may_wakeup(dev); | ||
503 | error = __acpi_device_sleep_wake(adev, target_state, wakeup); | ||
504 | if (wakeup && error) | ||
505 | return error; | ||
506 | |||
507 | error = acpi_dev_pm_low_power(dev, adev, target_state); | ||
508 | if (error) | ||
509 | __acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false); | ||
510 | |||
511 | return error; | ||
512 | } | ||
513 | EXPORT_SYMBOL_GPL(acpi_dev_suspend_late); | ||
514 | |||
515 | /** | ||
516 | * acpi_dev_resume_early - Put device into the full-power state using ACPI. | ||
517 | * @dev: Device to put into the full-power state. | ||
518 | * | ||
519 | * Put the given device into the full-power state using the standard ACPI | ||
520 | * mechanism during system transition to the working state. Set the power | ||
521 | * state of the device to ACPI D0 and disable remote wakeup. | ||
522 | */ | ||
523 | int acpi_dev_resume_early(struct device *dev) | ||
524 | { | ||
525 | struct acpi_device *adev = acpi_dev_pm_get_node(dev); | ||
526 | int error; | ||
527 | |||
528 | if (!adev) | ||
529 | return 0; | ||
530 | |||
531 | error = acpi_dev_pm_full_power(adev); | ||
532 | __acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false); | ||
533 | return error; | ||
534 | } | ||
535 | EXPORT_SYMBOL_GPL(acpi_dev_resume_early); | ||
536 | |||
537 | /** | ||
538 | * acpi_subsys_prepare - Prepare device for system transition to a sleep state. | ||
539 | * @dev: Device to prepare. | ||
540 | */ | ||
541 | int acpi_subsys_prepare(struct device *dev) | ||
542 | { | ||
543 | /* | ||
544 | * Follow PCI and resume devices suspended at run time before running | ||
545 | * their system suspend callbacks. | ||
546 | */ | ||
547 | pm_runtime_resume(dev); | ||
548 | return pm_generic_prepare(dev); | ||
549 | } | ||
550 | EXPORT_SYMBOL_GPL(acpi_subsys_prepare); | ||
551 | |||
552 | /** | ||
553 | * acpi_subsys_suspend_late - Suspend device using ACPI. | ||
554 | * @dev: Device to suspend. | ||
555 | * | ||
556 | * Carry out the generic late suspend procedure for @dev and use ACPI to put | ||
557 | * it into a low-power state during system transition into a sleep state. | ||
558 | */ | ||
559 | int acpi_subsys_suspend_late(struct device *dev) | ||
560 | { | ||
561 | int ret = pm_generic_suspend_late(dev); | ||
562 | return ret ? ret : acpi_dev_suspend_late(dev); | ||
563 | } | ||
564 | EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late); | ||
565 | |||
566 | /** | ||
567 | * acpi_subsys_resume_early - Resume device using ACPI. | ||
568 | * @dev: Device to Resume. | ||
569 | * | ||
570 | * Use ACPI to put the given device into the full-power state and carry out the | ||
571 | * generic early resume procedure for it during system transition into the | ||
572 | * working state. | ||
573 | */ | ||
574 | int acpi_subsys_resume_early(struct device *dev) | ||
575 | { | ||
576 | int ret = acpi_dev_resume_early(dev); | ||
577 | return ret ? ret : pm_generic_resume_early(dev); | ||
578 | } | ||
579 | EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); | ||
580 | #endif /* CONFIG_PM_SLEEP */ | ||
581 | |||
582 | static struct dev_pm_domain acpi_general_pm_domain = { | ||
583 | .ops = { | ||
584 | #ifdef CONFIG_PM_RUNTIME | ||
585 | .runtime_suspend = acpi_subsys_runtime_suspend, | ||
586 | .runtime_resume = acpi_subsys_runtime_resume, | ||
587 | .runtime_idle = pm_generic_runtime_idle, | ||
588 | #endif | ||
589 | #ifdef CONFIG_PM_SLEEP | ||
590 | .prepare = acpi_subsys_prepare, | ||
591 | .suspend_late = acpi_subsys_suspend_late, | ||
592 | .resume_early = acpi_subsys_resume_early, | ||
593 | .poweroff_late = acpi_subsys_suspend_late, | ||
594 | .restore_early = acpi_subsys_resume_early, | ||
595 | #endif | ||
596 | }, | ||
597 | }; | ||
598 | |||
599 | /** | ||
600 | * acpi_dev_pm_attach - Prepare device for ACPI power management. | ||
601 | * @dev: Device to prepare. | ||
602 | * @power_on: Whether or not to power on the device. | ||
603 | * | ||
604 | * If @dev has a valid ACPI handle that has a valid struct acpi_device object | ||
605 | * attached to it, install a wakeup notification handler for the device and | ||
606 | * add it to the general ACPI PM domain. If @power_on is set, the device will | ||
607 | * be put into the ACPI D0 state before the function returns. | ||
608 | * | ||
609 | * This assumes that the @dev's bus type uses generic power management callbacks | ||
610 | * (or doesn't use any power management callbacks at all). | ||
611 | * | ||
612 | * Callers must ensure proper synchronization of this function with power | ||
613 | * management callbacks. | ||
614 | */ | ||
615 | int acpi_dev_pm_attach(struct device *dev, bool power_on) | ||
616 | { | ||
617 | struct acpi_device *adev = acpi_dev_pm_get_node(dev); | ||
618 | |||
619 | if (!adev) | ||
620 | return -ENODEV; | ||
621 | |||
622 | if (dev->pm_domain) | ||
623 | return -EEXIST; | ||
624 | |||
625 | acpi_add_pm_notifier(adev, acpi_wakeup_device, dev); | ||
626 | dev->pm_domain = &acpi_general_pm_domain; | ||
627 | if (power_on) { | ||
628 | acpi_dev_pm_full_power(adev); | ||
629 | __acpi_device_run_wake(adev, false); | ||
630 | } | ||
631 | return 0; | ||
632 | } | ||
633 | EXPORT_SYMBOL_GPL(acpi_dev_pm_attach); | ||
634 | |||
635 | /** | ||
636 | * acpi_dev_pm_detach - Remove ACPI power management from the device. | ||
637 | * @dev: Device to take care of. | ||
638 | * @power_off: Whether or not to try to remove power from the device. | ||
639 | * | ||
640 | * Remove the device from the general ACPI PM domain and remove its wakeup | ||
641 | * notifier. If @power_off is set, additionally remove power from the device if | ||
642 | * possible. | ||
643 | * | ||
644 | * Callers must ensure proper synchronization of this function with power | ||
645 | * management callbacks. | ||
646 | */ | ||
647 | void acpi_dev_pm_detach(struct device *dev, bool power_off) | ||
648 | { | ||
649 | struct acpi_device *adev = acpi_dev_pm_get_node(dev); | ||
650 | |||
651 | if (adev && dev->pm_domain == &acpi_general_pm_domain) { | ||
652 | dev->pm_domain = NULL; | ||
653 | acpi_remove_pm_notifier(adev, acpi_wakeup_device); | ||
654 | if (power_off) { | ||
655 | /* | ||
656 | * If the device's PM QoS resume latency limit or flags | ||
657 | * have been exposed to user space, they have to be | ||
658 | * hidden at this point, so that they don't affect the | ||
659 | * choice of the low-power state to put the device into. | ||
660 | */ | ||
661 | dev_pm_qos_hide_latency_limit(dev); | ||
662 | dev_pm_qos_hide_flags(dev); | ||
663 | __acpi_device_run_wake(adev, false); | ||
664 | acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); | ||
665 | } | ||
666 | } | ||
667 | } | ||
668 | EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); | ||
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 08373086cd7e..01551840d236 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -130,46 +130,59 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) | |||
130 | { | 130 | { |
131 | struct acpi_device *acpi_dev; | 131 | struct acpi_device *acpi_dev; |
132 | acpi_status status; | 132 | acpi_status status; |
133 | struct acpi_device_physical_node *physical_node; | 133 | struct acpi_device_physical_node *physical_node, *pn; |
134 | char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2]; | 134 | char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2]; |
135 | int retval = -EINVAL; | 135 | int retval = -EINVAL; |
136 | 136 | ||
137 | if (dev->archdata.acpi_handle) { | 137 | if (ACPI_HANDLE(dev)) { |
138 | dev_warn(dev, "Drivers changed 'acpi_handle'\n"); | 138 | if (handle) { |
139 | return -EINVAL; | 139 | dev_warn(dev, "ACPI handle is already set\n"); |
140 | return -EINVAL; | ||
141 | } else { | ||
142 | handle = ACPI_HANDLE(dev); | ||
143 | } | ||
140 | } | 144 | } |
145 | if (!handle) | ||
146 | return -EINVAL; | ||
141 | 147 | ||
142 | get_device(dev); | 148 | get_device(dev); |
143 | status = acpi_bus_get_device(handle, &acpi_dev); | 149 | status = acpi_bus_get_device(handle, &acpi_dev); |
144 | if (ACPI_FAILURE(status)) | 150 | if (ACPI_FAILURE(status)) |
145 | goto err; | 151 | goto err; |
146 | 152 | ||
147 | physical_node = kzalloc(sizeof(struct acpi_device_physical_node), | 153 | physical_node = kzalloc(sizeof(*physical_node), GFP_KERNEL); |
148 | GFP_KERNEL); | ||
149 | if (!physical_node) { | 154 | if (!physical_node) { |
150 | retval = -ENOMEM; | 155 | retval = -ENOMEM; |
151 | goto err; | 156 | goto err; |
152 | } | 157 | } |
153 | 158 | ||
154 | mutex_lock(&acpi_dev->physical_node_lock); | 159 | mutex_lock(&acpi_dev->physical_node_lock); |
160 | |||
161 | /* Sanity check. */ | ||
162 | list_for_each_entry(pn, &acpi_dev->physical_node_list, node) | ||
163 | if (pn->dev == dev) { | ||
164 | dev_warn(dev, "Already associated with ACPI node\n"); | ||
165 | goto err_free; | ||
166 | } | ||
167 | |||
155 | /* allocate physical node id according to physical_node_id_bitmap */ | 168 | /* allocate physical node id according to physical_node_id_bitmap */ |
156 | physical_node->node_id = | 169 | physical_node->node_id = |
157 | find_first_zero_bit(acpi_dev->physical_node_id_bitmap, | 170 | find_first_zero_bit(acpi_dev->physical_node_id_bitmap, |
158 | ACPI_MAX_PHYSICAL_NODE); | 171 | ACPI_MAX_PHYSICAL_NODE); |
159 | if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) { | 172 | if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) { |
160 | retval = -ENOSPC; | 173 | retval = -ENOSPC; |
161 | mutex_unlock(&acpi_dev->physical_node_lock); | 174 | goto err_free; |
162 | kfree(physical_node); | ||
163 | goto err; | ||
164 | } | 175 | } |
165 | 176 | ||
166 | set_bit(physical_node->node_id, acpi_dev->physical_node_id_bitmap); | 177 | set_bit(physical_node->node_id, acpi_dev->physical_node_id_bitmap); |
167 | physical_node->dev = dev; | 178 | physical_node->dev = dev; |
168 | list_add_tail(&physical_node->node, &acpi_dev->physical_node_list); | 179 | list_add_tail(&physical_node->node, &acpi_dev->physical_node_list); |
169 | acpi_dev->physical_node_count++; | 180 | acpi_dev->physical_node_count++; |
181 | |||
170 | mutex_unlock(&acpi_dev->physical_node_lock); | 182 | mutex_unlock(&acpi_dev->physical_node_lock); |
171 | 183 | ||
172 | dev->archdata.acpi_handle = handle; | 184 | if (!ACPI_HANDLE(dev)) |
185 | ACPI_HANDLE_SET(dev, acpi_dev->handle); | ||
173 | 186 | ||
174 | if (!physical_node->node_id) | 187 | if (!physical_node->node_id) |
175 | strcpy(physical_node_name, PHYSICAL_NODE_STRING); | 188 | strcpy(physical_node_name, PHYSICAL_NODE_STRING); |
@@ -187,8 +200,14 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) | |||
187 | return 0; | 200 | return 0; |
188 | 201 | ||
189 | err: | 202 | err: |
203 | ACPI_HANDLE_SET(dev, NULL); | ||
190 | put_device(dev); | 204 | put_device(dev); |
191 | return retval; | 205 | return retval; |
206 | |||
207 | err_free: | ||
208 | mutex_unlock(&acpi_dev->physical_node_lock); | ||
209 | kfree(physical_node); | ||
210 | goto err; | ||
192 | } | 211 | } |
193 | 212 | ||
194 | static int acpi_unbind_one(struct device *dev) | 213 | static int acpi_unbind_one(struct device *dev) |
@@ -198,11 +217,10 @@ static int acpi_unbind_one(struct device *dev) | |||
198 | acpi_status status; | 217 | acpi_status status; |
199 | struct list_head *node, *next; | 218 | struct list_head *node, *next; |
200 | 219 | ||
201 | if (!dev->archdata.acpi_handle) | 220 | if (!ACPI_HANDLE(dev)) |
202 | return 0; | 221 | return 0; |
203 | 222 | ||
204 | status = acpi_bus_get_device(dev->archdata.acpi_handle, | 223 | status = acpi_bus_get_device(ACPI_HANDLE(dev), &acpi_dev); |
205 | &acpi_dev); | ||
206 | if (ACPI_FAILURE(status)) | 224 | if (ACPI_FAILURE(status)) |
207 | goto err; | 225 | goto err; |
208 | 226 | ||
@@ -228,7 +246,7 @@ static int acpi_unbind_one(struct device *dev) | |||
228 | 246 | ||
229 | sysfs_remove_link(&acpi_dev->dev.kobj, physical_node_name); | 247 | sysfs_remove_link(&acpi_dev->dev.kobj, physical_node_name); |
230 | sysfs_remove_link(&dev->kobj, "firmware_node"); | 248 | sysfs_remove_link(&dev->kobj, "firmware_node"); |
231 | dev->archdata.acpi_handle = NULL; | 249 | ACPI_HANDLE_SET(dev, NULL); |
232 | /* acpi_bind_one increase refcnt by one */ | 250 | /* acpi_bind_one increase refcnt by one */ |
233 | put_device(dev); | 251 | put_device(dev); |
234 | kfree(entry); | 252 | kfree(entry); |
@@ -248,6 +266,10 @@ static int acpi_platform_notify(struct device *dev) | |||
248 | acpi_handle handle; | 266 | acpi_handle handle; |
249 | int ret = -EINVAL; | 267 | int ret = -EINVAL; |
250 | 268 | ||
269 | ret = acpi_bind_one(dev, NULL); | ||
270 | if (!ret) | ||
271 | goto out; | ||
272 | |||
251 | if (!dev->bus || !dev->parent) { | 273 | if (!dev->bus || !dev->parent) { |
252 | /* bridge devices genernally haven't bus or parent */ | 274 | /* bridge devices genernally haven't bus or parent */ |
253 | ret = acpi_find_bridge_device(dev, &handle); | 275 | ret = acpi_find_bridge_device(dev, &handle); |
@@ -261,16 +283,16 @@ static int acpi_platform_notify(struct device *dev) | |||
261 | } | 283 | } |
262 | if ((ret = type->find_device(dev, &handle)) != 0) | 284 | if ((ret = type->find_device(dev, &handle)) != 0) |
263 | DBG("Can't get handler for %s\n", dev_name(dev)); | 285 | DBG("Can't get handler for %s\n", dev_name(dev)); |
264 | end: | 286 | end: |
265 | if (!ret) | 287 | if (!ret) |
266 | acpi_bind_one(dev, handle); | 288 | acpi_bind_one(dev, handle); |
267 | 289 | ||
290 | out: | ||
268 | #if ACPI_GLUE_DEBUG | 291 | #if ACPI_GLUE_DEBUG |
269 | if (!ret) { | 292 | if (!ret) { |
270 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 293 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
271 | 294 | ||
272 | acpi_get_name(dev->archdata.acpi_handle, | 295 | acpi_get_name(dev->acpi_handle, ACPI_FULL_PATHNAME, &buffer); |
273 | ACPI_FULL_PATHNAME, &buffer); | ||
274 | DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer); | 296 | DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer); |
275 | kfree(buffer.pointer); | 297 | kfree(buffer.pointer); |
276 | } else | 298 | } else |
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 509dcaa17555..3c407cdc1ec1 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h | |||
@@ -93,4 +93,11 @@ static inline int suspend_nvs_save(void) { return 0; } | |||
93 | static inline void suspend_nvs_restore(void) {} | 93 | static inline void suspend_nvs_restore(void) {} |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | /*-------------------------------------------------------------------------- | ||
97 | Platform bus support | ||
98 | -------------------------------------------------------------------------- */ | ||
99 | struct platform_device; | ||
100 | |||
101 | struct platform_device *acpi_create_platform_device(struct acpi_device *adev); | ||
102 | |||
96 | #endif /* _ACPI_INTERNAL_H_ */ | 103 | #endif /* _ACPI_INTERNAL_H_ */ |
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index f2c3d74af23e..23a032490130 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c | |||
@@ -495,11 +495,6 @@ int acpi_pci_irq_enable(struct pci_dev *dev) | |||
495 | return 0; | 495 | return 0; |
496 | } | 496 | } |
497 | 497 | ||
498 | /* FIXME: implement x86/x86_64 version */ | ||
499 | void __attribute__ ((weak)) acpi_unregister_gsi(u32 i) | ||
500 | { | ||
501 | } | ||
502 | |||
503 | void acpi_pci_irq_disable(struct pci_dev *dev) | 498 | void acpi_pci_irq_disable(struct pci_dev *dev) |
504 | { | 499 | { |
505 | struct acpi_prt_entry *entry; | 500 | struct acpi_prt_entry *entry; |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index e8086c725305..f1a5da44591d 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -735,31 +735,18 @@ static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx) | |||
735 | static int acpi_idle_enter_c1(struct cpuidle_device *dev, | 735 | static int acpi_idle_enter_c1(struct cpuidle_device *dev, |
736 | struct cpuidle_driver *drv, int index) | 736 | struct cpuidle_driver *drv, int index) |
737 | { | 737 | { |
738 | ktime_t kt1, kt2; | ||
739 | s64 idle_time; | ||
740 | struct acpi_processor *pr; | 738 | struct acpi_processor *pr; |
741 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; | 739 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; |
742 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | 740 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); |
743 | 741 | ||
744 | pr = __this_cpu_read(processors); | 742 | pr = __this_cpu_read(processors); |
745 | dev->last_residency = 0; | ||
746 | 743 | ||
747 | if (unlikely(!pr)) | 744 | if (unlikely(!pr)) |
748 | return -EINVAL; | 745 | return -EINVAL; |
749 | 746 | ||
750 | local_irq_disable(); | ||
751 | |||
752 | |||
753 | lapic_timer_state_broadcast(pr, cx, 1); | 747 | lapic_timer_state_broadcast(pr, cx, 1); |
754 | kt1 = ktime_get_real(); | ||
755 | acpi_idle_do_entry(cx); | 748 | acpi_idle_do_entry(cx); |
756 | kt2 = ktime_get_real(); | ||
757 | idle_time = ktime_to_us(ktime_sub(kt2, kt1)); | ||
758 | |||
759 | /* Update device last_residency*/ | ||
760 | dev->last_residency = (int)idle_time; | ||
761 | 749 | ||
762 | local_irq_enable(); | ||
763 | lapic_timer_state_broadcast(pr, cx, 0); | 750 | lapic_timer_state_broadcast(pr, cx, 0); |
764 | 751 | ||
765 | return index; | 752 | return index; |
@@ -806,19 +793,12 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
806 | struct acpi_processor *pr; | 793 | struct acpi_processor *pr; |
807 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; | 794 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; |
808 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | 795 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); |
809 | ktime_t kt1, kt2; | ||
810 | s64 idle_time_ns; | ||
811 | s64 idle_time; | ||
812 | 796 | ||
813 | pr = __this_cpu_read(processors); | 797 | pr = __this_cpu_read(processors); |
814 | dev->last_residency = 0; | ||
815 | 798 | ||
816 | if (unlikely(!pr)) | 799 | if (unlikely(!pr)) |
817 | return -EINVAL; | 800 | return -EINVAL; |
818 | 801 | ||
819 | local_irq_disable(); | ||
820 | |||
821 | |||
822 | if (cx->entry_method != ACPI_CSTATE_FFH) { | 802 | if (cx->entry_method != ACPI_CSTATE_FFH) { |
823 | current_thread_info()->status &= ~TS_POLLING; | 803 | current_thread_info()->status &= ~TS_POLLING; |
824 | /* | 804 | /* |
@@ -829,7 +809,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
829 | 809 | ||
830 | if (unlikely(need_resched())) { | 810 | if (unlikely(need_resched())) { |
831 | current_thread_info()->status |= TS_POLLING; | 811 | current_thread_info()->status |= TS_POLLING; |
832 | local_irq_enable(); | ||
833 | return -EINVAL; | 812 | return -EINVAL; |
834 | } | 813 | } |
835 | } | 814 | } |
@@ -843,22 +822,12 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
843 | if (cx->type == ACPI_STATE_C3) | 822 | if (cx->type == ACPI_STATE_C3) |
844 | ACPI_FLUSH_CPU_CACHE(); | 823 | ACPI_FLUSH_CPU_CACHE(); |
845 | 824 | ||
846 | kt1 = ktime_get_real(); | ||
847 | /* Tell the scheduler that we are going deep-idle: */ | 825 | /* Tell the scheduler that we are going deep-idle: */ |
848 | sched_clock_idle_sleep_event(); | 826 | sched_clock_idle_sleep_event(); |
849 | acpi_idle_do_entry(cx); | 827 | acpi_idle_do_entry(cx); |
850 | kt2 = ktime_get_real(); | ||
851 | idle_time_ns = ktime_to_ns(ktime_sub(kt2, kt1)); | ||
852 | idle_time = idle_time_ns; | ||
853 | do_div(idle_time, NSEC_PER_USEC); | ||
854 | 828 | ||
855 | /* Update device last_residency*/ | 829 | sched_clock_idle_wakeup_event(0); |
856 | dev->last_residency = (int)idle_time; | ||
857 | 830 | ||
858 | /* Tell the scheduler how much we idled: */ | ||
859 | sched_clock_idle_wakeup_event(idle_time_ns); | ||
860 | |||
861 | local_irq_enable(); | ||
862 | if (cx->entry_method != ACPI_CSTATE_FFH) | 831 | if (cx->entry_method != ACPI_CSTATE_FFH) |
863 | current_thread_info()->status |= TS_POLLING; | 832 | current_thread_info()->status |= TS_POLLING; |
864 | 833 | ||
@@ -883,13 +852,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
883 | struct acpi_processor *pr; | 852 | struct acpi_processor *pr; |
884 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; | 853 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; |
885 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | 854 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); |
886 | ktime_t kt1, kt2; | ||
887 | s64 idle_time_ns; | ||
888 | s64 idle_time; | ||
889 | |||
890 | 855 | ||
891 | pr = __this_cpu_read(processors); | 856 | pr = __this_cpu_read(processors); |
892 | dev->last_residency = 0; | ||
893 | 857 | ||
894 | if (unlikely(!pr)) | 858 | if (unlikely(!pr)) |
895 | return -EINVAL; | 859 | return -EINVAL; |
@@ -899,16 +863,11 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
899 | return drv->states[drv->safe_state_index].enter(dev, | 863 | return drv->states[drv->safe_state_index].enter(dev, |
900 | drv, drv->safe_state_index); | 864 | drv, drv->safe_state_index); |
901 | } else { | 865 | } else { |
902 | local_irq_disable(); | ||
903 | acpi_safe_halt(); | 866 | acpi_safe_halt(); |
904 | local_irq_enable(); | ||
905 | return -EBUSY; | 867 | return -EBUSY; |
906 | } | 868 | } |
907 | } | 869 | } |
908 | 870 | ||
909 | local_irq_disable(); | ||
910 | |||
911 | |||
912 | if (cx->entry_method != ACPI_CSTATE_FFH) { | 871 | if (cx->entry_method != ACPI_CSTATE_FFH) { |
913 | current_thread_info()->status &= ~TS_POLLING; | 872 | current_thread_info()->status &= ~TS_POLLING; |
914 | /* | 873 | /* |
@@ -919,7 +878,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
919 | 878 | ||
920 | if (unlikely(need_resched())) { | 879 | if (unlikely(need_resched())) { |
921 | current_thread_info()->status |= TS_POLLING; | 880 | current_thread_info()->status |= TS_POLLING; |
922 | local_irq_enable(); | ||
923 | return -EINVAL; | 881 | return -EINVAL; |
924 | } | 882 | } |
925 | } | 883 | } |
@@ -934,7 +892,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
934 | */ | 892 | */ |
935 | lapic_timer_state_broadcast(pr, cx, 1); | 893 | lapic_timer_state_broadcast(pr, cx, 1); |
936 | 894 | ||
937 | kt1 = ktime_get_real(); | ||
938 | /* | 895 | /* |
939 | * disable bus master | 896 | * disable bus master |
940 | * bm_check implies we need ARB_DIS | 897 | * bm_check implies we need ARB_DIS |
@@ -965,18 +922,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
965 | c3_cpu_count--; | 922 | c3_cpu_count--; |
966 | raw_spin_unlock(&c3_lock); | 923 | raw_spin_unlock(&c3_lock); |
967 | } | 924 | } |
968 | kt2 = ktime_get_real(); | ||
969 | idle_time_ns = ktime_to_ns(ktime_sub(kt2, kt1)); | ||
970 | idle_time = idle_time_ns; | ||
971 | do_div(idle_time, NSEC_PER_USEC); | ||
972 | |||
973 | /* Update device last_residency*/ | ||
974 | dev->last_residency = (int)idle_time; | ||
975 | 925 | ||
976 | /* Tell the scheduler how much we idled: */ | 926 | sched_clock_idle_wakeup_event(0); |
977 | sched_clock_idle_wakeup_event(idle_time_ns); | ||
978 | 927 | ||
979 | local_irq_enable(); | ||
980 | if (cx->entry_method != ACPI_CSTATE_FFH) | 928 | if (cx->entry_method != ACPI_CSTATE_FFH) |
981 | current_thread_info()->status |= TS_POLLING; | 929 | current_thread_info()->status |= TS_POLLING; |
982 | 930 | ||
@@ -987,6 +935,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
987 | struct cpuidle_driver acpi_idle_driver = { | 935 | struct cpuidle_driver acpi_idle_driver = { |
988 | .name = "acpi_idle", | 936 | .name = "acpi_idle", |
989 | .owner = THIS_MODULE, | 937 | .owner = THIS_MODULE, |
938 | .en_core_tk_irqen = 1, | ||
990 | }; | 939 | }; |
991 | 940 | ||
992 | /** | 941 | /** |
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c new file mode 100644 index 000000000000..a3868f6c222a --- /dev/null +++ b/drivers/acpi/resource.c | |||
@@ -0,0 +1,526 @@ | |||
1 | /* | ||
2 | * drivers/acpi/resource.c - ACPI device resources interpretation. | ||
3 | * | ||
4 | * Copyright (C) 2012, Intel Corp. | ||
5 | * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
6 | * | ||
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as published | ||
11 | * by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License along | ||
19 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
21 | * | ||
22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
23 | */ | ||
24 | |||
25 | #include <linux/acpi.h> | ||
26 | #include <linux/device.h> | ||
27 | #include <linux/export.h> | ||
28 | #include <linux/ioport.h> | ||
29 | #include <linux/slab.h> | ||
30 | |||
31 | #ifdef CONFIG_X86 | ||
32 | #define valid_IRQ(i) (((i) != 0) && ((i) != 2)) | ||
33 | #else | ||
34 | #define valid_IRQ(i) (true) | ||
35 | #endif | ||
36 | |||
37 | static unsigned long acpi_dev_memresource_flags(u64 len, u8 write_protect, | ||
38 | bool window) | ||
39 | { | ||
40 | unsigned long flags = IORESOURCE_MEM; | ||
41 | |||
42 | if (len == 0) | ||
43 | flags |= IORESOURCE_DISABLED; | ||
44 | |||
45 | if (write_protect == ACPI_READ_WRITE_MEMORY) | ||
46 | flags |= IORESOURCE_MEM_WRITEABLE; | ||
47 | |||
48 | if (window) | ||
49 | flags |= IORESOURCE_WINDOW; | ||
50 | |||
51 | return flags; | ||
52 | } | ||
53 | |||
54 | static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len, | ||
55 | u8 write_protect) | ||
56 | { | ||
57 | res->start = start; | ||
58 | res->end = start + len - 1; | ||
59 | res->flags = acpi_dev_memresource_flags(len, write_protect, false); | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * acpi_dev_resource_memory - Extract ACPI memory resource information. | ||
64 | * @ares: Input ACPI resource object. | ||
65 | * @res: Output generic resource object. | ||
66 | * | ||
67 | * Check if the given ACPI resource object represents a memory resource and | ||
68 | * if that's the case, use the information in it to populate the generic | ||
69 | * resource object pointed to by @res. | ||
70 | */ | ||
71 | bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res) | ||
72 | { | ||
73 | struct acpi_resource_memory24 *memory24; | ||
74 | struct acpi_resource_memory32 *memory32; | ||
75 | struct acpi_resource_fixed_memory32 *fixed_memory32; | ||
76 | |||
77 | switch (ares->type) { | ||
78 | case ACPI_RESOURCE_TYPE_MEMORY24: | ||
79 | memory24 = &ares->data.memory24; | ||
80 | acpi_dev_get_memresource(res, memory24->minimum, | ||
81 | memory24->address_length, | ||
82 | memory24->write_protect); | ||
83 | break; | ||
84 | case ACPI_RESOURCE_TYPE_MEMORY32: | ||
85 | memory32 = &ares->data.memory32; | ||
86 | acpi_dev_get_memresource(res, memory32->minimum, | ||
87 | memory32->address_length, | ||
88 | memory32->write_protect); | ||
89 | break; | ||
90 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | ||
91 | fixed_memory32 = &ares->data.fixed_memory32; | ||
92 | acpi_dev_get_memresource(res, fixed_memory32->address, | ||
93 | fixed_memory32->address_length, | ||
94 | fixed_memory32->write_protect); | ||
95 | break; | ||
96 | default: | ||
97 | return false; | ||
98 | } | ||
99 | return true; | ||
100 | } | ||
101 | EXPORT_SYMBOL_GPL(acpi_dev_resource_memory); | ||
102 | |||
103 | static unsigned int acpi_dev_ioresource_flags(u64 start, u64 end, u8 io_decode, | ||
104 | bool window) | ||
105 | { | ||
106 | int flags = IORESOURCE_IO; | ||
107 | |||
108 | if (io_decode == ACPI_DECODE_16) | ||
109 | flags |= IORESOURCE_IO_16BIT_ADDR; | ||
110 | |||
111 | if (start > end || end >= 0x10003) | ||
112 | flags |= IORESOURCE_DISABLED; | ||
113 | |||
114 | if (window) | ||
115 | flags |= IORESOURCE_WINDOW; | ||
116 | |||
117 | return flags; | ||
118 | } | ||
119 | |||
120 | static void acpi_dev_get_ioresource(struct resource *res, u64 start, u64 len, | ||
121 | u8 io_decode) | ||
122 | { | ||
123 | u64 end = start + len - 1; | ||
124 | |||
125 | res->start = start; | ||
126 | res->end = end; | ||
127 | res->flags = acpi_dev_ioresource_flags(start, end, io_decode, false); | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * acpi_dev_resource_io - Extract ACPI I/O resource information. | ||
132 | * @ares: Input ACPI resource object. | ||
133 | * @res: Output generic resource object. | ||
134 | * | ||
135 | * Check if the given ACPI resource object represents an I/O resource and | ||
136 | * if that's the case, use the information in it to populate the generic | ||
137 | * resource object pointed to by @res. | ||
138 | */ | ||
139 | bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res) | ||
140 | { | ||
141 | struct acpi_resource_io *io; | ||
142 | struct acpi_resource_fixed_io *fixed_io; | ||
143 | |||
144 | switch (ares->type) { | ||
145 | case ACPI_RESOURCE_TYPE_IO: | ||
146 | io = &ares->data.io; | ||
147 | acpi_dev_get_ioresource(res, io->minimum, | ||
148 | io->address_length, | ||
149 | io->io_decode); | ||
150 | break; | ||
151 | case ACPI_RESOURCE_TYPE_FIXED_IO: | ||
152 | fixed_io = &ares->data.fixed_io; | ||
153 | acpi_dev_get_ioresource(res, fixed_io->address, | ||
154 | fixed_io->address_length, | ||
155 | ACPI_DECODE_10); | ||
156 | break; | ||
157 | default: | ||
158 | return false; | ||
159 | } | ||
160 | return true; | ||
161 | } | ||
162 | EXPORT_SYMBOL_GPL(acpi_dev_resource_io); | ||
163 | |||
164 | /** | ||
165 | * acpi_dev_resource_address_space - Extract ACPI address space information. | ||
166 | * @ares: Input ACPI resource object. | ||
167 | * @res: Output generic resource object. | ||
168 | * | ||
169 | * Check if the given ACPI resource object represents an address space resource | ||
170 | * and if that's the case, use the information in it to populate the generic | ||
171 | * resource object pointed to by @res. | ||
172 | */ | ||
173 | bool acpi_dev_resource_address_space(struct acpi_resource *ares, | ||
174 | struct resource *res) | ||
175 | { | ||
176 | acpi_status status; | ||
177 | struct acpi_resource_address64 addr; | ||
178 | bool window; | ||
179 | u64 len; | ||
180 | u8 io_decode; | ||
181 | |||
182 | switch (ares->type) { | ||
183 | case ACPI_RESOURCE_TYPE_ADDRESS16: | ||
184 | case ACPI_RESOURCE_TYPE_ADDRESS32: | ||
185 | case ACPI_RESOURCE_TYPE_ADDRESS64: | ||
186 | break; | ||
187 | default: | ||
188 | return false; | ||
189 | } | ||
190 | |||
191 | status = acpi_resource_to_address64(ares, &addr); | ||
192 | if (ACPI_FAILURE(status)) | ||
193 | return true; | ||
194 | |||
195 | res->start = addr.minimum; | ||
196 | res->end = addr.maximum; | ||
197 | window = addr.producer_consumer == ACPI_PRODUCER; | ||
198 | |||
199 | switch(addr.resource_type) { | ||
200 | case ACPI_MEMORY_RANGE: | ||
201 | len = addr.maximum - addr.minimum + 1; | ||
202 | res->flags = acpi_dev_memresource_flags(len, | ||
203 | addr.info.mem.write_protect, | ||
204 | window); | ||
205 | break; | ||
206 | case ACPI_IO_RANGE: | ||
207 | io_decode = addr.granularity == 0xfff ? | ||
208 | ACPI_DECODE_10 : ACPI_DECODE_16; | ||
209 | res->flags = acpi_dev_ioresource_flags(addr.minimum, | ||
210 | addr.maximum, | ||
211 | io_decode, window); | ||
212 | break; | ||
213 | case ACPI_BUS_NUMBER_RANGE: | ||
214 | res->flags = IORESOURCE_BUS; | ||
215 | break; | ||
216 | default: | ||
217 | res->flags = 0; | ||
218 | } | ||
219 | |||
220 | return true; | ||
221 | } | ||
222 | EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space); | ||
223 | |||
224 | /** | ||
225 | * acpi_dev_resource_ext_address_space - Extract ACPI address space information. | ||
226 | * @ares: Input ACPI resource object. | ||
227 | * @res: Output generic resource object. | ||
228 | * | ||
229 | * Check if the given ACPI resource object represents an extended address space | ||
230 | * resource and if that's the case, use the information in it to populate the | ||
231 | * generic resource object pointed to by @res. | ||
232 | */ | ||
233 | bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, | ||
234 | struct resource *res) | ||
235 | { | ||
236 | struct acpi_resource_extended_address64 *ext_addr; | ||
237 | bool window; | ||
238 | u64 len; | ||
239 | u8 io_decode; | ||
240 | |||
241 | if (ares->type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64) | ||
242 | return false; | ||
243 | |||
244 | ext_addr = &ares->data.ext_address64; | ||
245 | |||
246 | res->start = ext_addr->minimum; | ||
247 | res->end = ext_addr->maximum; | ||
248 | window = ext_addr->producer_consumer == ACPI_PRODUCER; | ||
249 | |||
250 | switch(ext_addr->resource_type) { | ||
251 | case ACPI_MEMORY_RANGE: | ||
252 | len = ext_addr->maximum - ext_addr->minimum + 1; | ||
253 | res->flags = acpi_dev_memresource_flags(len, | ||
254 | ext_addr->info.mem.write_protect, | ||
255 | window); | ||
256 | break; | ||
257 | case ACPI_IO_RANGE: | ||
258 | io_decode = ext_addr->granularity == 0xfff ? | ||
259 | ACPI_DECODE_10 : ACPI_DECODE_16; | ||
260 | res->flags = acpi_dev_ioresource_flags(ext_addr->minimum, | ||
261 | ext_addr->maximum, | ||
262 | io_decode, window); | ||
263 | break; | ||
264 | case ACPI_BUS_NUMBER_RANGE: | ||
265 | res->flags = IORESOURCE_BUS; | ||
266 | break; | ||
267 | default: | ||
268 | res->flags = 0; | ||
269 | } | ||
270 | |||
271 | return true; | ||
272 | } | ||
273 | EXPORT_SYMBOL_GPL(acpi_dev_resource_ext_address_space); | ||
274 | |||
275 | /** | ||
276 | * acpi_dev_irq_flags - Determine IRQ resource flags. | ||
277 | * @triggering: Triggering type as provided by ACPI. | ||
278 | * @polarity: Interrupt polarity as provided by ACPI. | ||
279 | * @shareable: Whether or not the interrupt is shareable. | ||
280 | */ | ||
281 | unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable) | ||
282 | { | ||
283 | unsigned long flags; | ||
284 | |||
285 | if (triggering == ACPI_LEVEL_SENSITIVE) | ||
286 | flags = polarity == ACPI_ACTIVE_LOW ? | ||
287 | IORESOURCE_IRQ_LOWLEVEL : IORESOURCE_IRQ_HIGHLEVEL; | ||
288 | else | ||
289 | flags = polarity == ACPI_ACTIVE_LOW ? | ||
290 | IORESOURCE_IRQ_LOWEDGE : IORESOURCE_IRQ_HIGHEDGE; | ||
291 | |||
292 | if (shareable == ACPI_SHARED) | ||
293 | flags |= IORESOURCE_IRQ_SHAREABLE; | ||
294 | |||
295 | return flags | IORESOURCE_IRQ; | ||
296 | } | ||
297 | EXPORT_SYMBOL_GPL(acpi_dev_irq_flags); | ||
298 | |||
299 | static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi) | ||
300 | { | ||
301 | res->start = gsi; | ||
302 | res->end = gsi; | ||
303 | res->flags = IORESOURCE_IRQ | IORESOURCE_DISABLED; | ||
304 | } | ||
305 | |||
306 | static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, | ||
307 | u8 triggering, u8 polarity, u8 shareable) | ||
308 | { | ||
309 | int irq, p, t; | ||
310 | |||
311 | if (!valid_IRQ(gsi)) { | ||
312 | acpi_dev_irqresource_disabled(res, gsi); | ||
313 | return; | ||
314 | } | ||
315 | |||
316 | /* | ||
317 | * In IO-APIC mode, use overrided attribute. Two reasons: | ||
318 | * 1. BIOS bug in DSDT | ||
319 | * 2. BIOS uses IO-APIC mode Interrupt Source Override | ||
320 | */ | ||
321 | if (!acpi_get_override_irq(gsi, &t, &p)) { | ||
322 | u8 trig = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; | ||
323 | u8 pol = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; | ||
324 | |||
325 | if (triggering != trig || polarity != pol) { | ||
326 | pr_warning("ACPI: IRQ %d override to %s, %s\n", gsi, | ||
327 | t ? "edge" : "level", p ? "low" : "high"); | ||
328 | triggering = trig; | ||
329 | polarity = pol; | ||
330 | } | ||
331 | } | ||
332 | |||
333 | res->flags = acpi_dev_irq_flags(triggering, polarity, shareable); | ||
334 | irq = acpi_register_gsi(NULL, gsi, triggering, polarity); | ||
335 | if (irq >= 0) { | ||
336 | res->start = irq; | ||
337 | res->end = irq; | ||
338 | } else { | ||
339 | acpi_dev_irqresource_disabled(res, gsi); | ||
340 | } | ||
341 | } | ||
342 | |||
343 | /** | ||
344 | * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information. | ||
345 | * @ares: Input ACPI resource object. | ||
346 | * @index: Index into the array of GSIs represented by the resource. | ||
347 | * @res: Output generic resource object. | ||
348 | * | ||
349 | * Check if the given ACPI resource object represents an interrupt resource | ||
350 | * and @index does not exceed the resource's interrupt count (true is returned | ||
351 | * in that case regardless of the results of the other checks)). If that's the | ||
352 | * case, register the GSI corresponding to @index from the array of interrupts | ||
353 | * represented by the resource and populate the generic resource object pointed | ||
354 | * to by @res accordingly. If the registration of the GSI is not successful, | ||
355 | * IORESOURCE_DISABLED will be set it that object's flags. | ||
356 | */ | ||
357 | bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, | ||
358 | struct resource *res) | ||
359 | { | ||
360 | struct acpi_resource_irq *irq; | ||
361 | struct acpi_resource_extended_irq *ext_irq; | ||
362 | |||
363 | switch (ares->type) { | ||
364 | case ACPI_RESOURCE_TYPE_IRQ: | ||
365 | /* | ||
366 | * Per spec, only one interrupt per descriptor is allowed in | ||
367 | * _CRS, but some firmware violates this, so parse them all. | ||
368 | */ | ||
369 | irq = &ares->data.irq; | ||
370 | if (index >= irq->interrupt_count) { | ||
371 | acpi_dev_irqresource_disabled(res, 0); | ||
372 | return false; | ||
373 | } | ||
374 | acpi_dev_get_irqresource(res, irq->interrupts[index], | ||
375 | irq->triggering, irq->polarity, | ||
376 | irq->sharable); | ||
377 | break; | ||
378 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | ||
379 | ext_irq = &ares->data.extended_irq; | ||
380 | if (index >= ext_irq->interrupt_count) { | ||
381 | acpi_dev_irqresource_disabled(res, 0); | ||
382 | return false; | ||
383 | } | ||
384 | acpi_dev_get_irqresource(res, ext_irq->interrupts[index], | ||
385 | ext_irq->triggering, ext_irq->polarity, | ||
386 | ext_irq->sharable); | ||
387 | break; | ||
388 | default: | ||
389 | return false; | ||
390 | } | ||
391 | |||
392 | return true; | ||
393 | } | ||
394 | EXPORT_SYMBOL_GPL(acpi_dev_resource_interrupt); | ||
395 | |||
396 | /** | ||
397 | * acpi_dev_free_resource_list - Free resource from %acpi_dev_get_resources(). | ||
398 | * @list: The head of the resource list to free. | ||
399 | */ | ||
400 | void acpi_dev_free_resource_list(struct list_head *list) | ||
401 | { | ||
402 | struct resource_list_entry *rentry, *re; | ||
403 | |||
404 | list_for_each_entry_safe(rentry, re, list, node) { | ||
405 | list_del(&rentry->node); | ||
406 | kfree(rentry); | ||
407 | } | ||
408 | } | ||
409 | EXPORT_SYMBOL_GPL(acpi_dev_free_resource_list); | ||
410 | |||
411 | struct res_proc_context { | ||
412 | struct list_head *list; | ||
413 | int (*preproc)(struct acpi_resource *, void *); | ||
414 | void *preproc_data; | ||
415 | int count; | ||
416 | int error; | ||
417 | }; | ||
418 | |||
419 | static acpi_status acpi_dev_new_resource_entry(struct resource *r, | ||
420 | struct res_proc_context *c) | ||
421 | { | ||
422 | struct resource_list_entry *rentry; | ||
423 | |||
424 | rentry = kmalloc(sizeof(*rentry), GFP_KERNEL); | ||
425 | if (!rentry) { | ||
426 | c->error = -ENOMEM; | ||
427 | return AE_NO_MEMORY; | ||
428 | } | ||
429 | rentry->res = *r; | ||
430 | list_add_tail(&rentry->node, c->list); | ||
431 | c->count++; | ||
432 | return AE_OK; | ||
433 | } | ||
434 | |||
435 | static acpi_status acpi_dev_process_resource(struct acpi_resource *ares, | ||
436 | void *context) | ||
437 | { | ||
438 | struct res_proc_context *c = context; | ||
439 | struct resource r; | ||
440 | int i; | ||
441 | |||
442 | if (c->preproc) { | ||
443 | int ret; | ||
444 | |||
445 | ret = c->preproc(ares, c->preproc_data); | ||
446 | if (ret < 0) { | ||
447 | c->error = ret; | ||
448 | return AE_CTRL_TERMINATE; | ||
449 | } else if (ret > 0) { | ||
450 | return AE_OK; | ||
451 | } | ||
452 | } | ||
453 | |||
454 | memset(&r, 0, sizeof(r)); | ||
455 | |||
456 | if (acpi_dev_resource_memory(ares, &r) | ||
457 | || acpi_dev_resource_io(ares, &r) | ||
458 | || acpi_dev_resource_address_space(ares, &r) | ||
459 | || acpi_dev_resource_ext_address_space(ares, &r)) | ||
460 | return acpi_dev_new_resource_entry(&r, c); | ||
461 | |||
462 | for (i = 0; acpi_dev_resource_interrupt(ares, i, &r); i++) { | ||
463 | acpi_status status; | ||
464 | |||
465 | status = acpi_dev_new_resource_entry(&r, c); | ||
466 | if (ACPI_FAILURE(status)) | ||
467 | return status; | ||
468 | } | ||
469 | |||
470 | return AE_OK; | ||
471 | } | ||
472 | |||
473 | /** | ||
474 | * acpi_dev_get_resources - Get current resources of a device. | ||
475 | * @adev: ACPI device node to get the resources for. | ||
476 | * @list: Head of the resultant list of resources (must be empty). | ||
477 | * @preproc: The caller's preprocessing routine. | ||
478 | * @preproc_data: Pointer passed to the caller's preprocessing routine. | ||
479 | * | ||
480 | * Evaluate the _CRS method for the given device node and process its output by | ||
481 | * (1) executing the @preproc() rountine provided by the caller, passing the | ||
482 | * resource pointer and @preproc_data to it as arguments, for each ACPI resource | ||
483 | * returned and (2) converting all of the returned ACPI resources into struct | ||
484 | * resource objects if possible. If the return value of @preproc() in step (1) | ||
485 | * is different from 0, step (2) is not applied to the given ACPI resource and | ||
486 | * if that value is negative, the whole processing is aborted and that value is | ||
487 | * returned as the final error code. | ||
488 | * | ||
489 | * The resultant struct resource objects are put on the list pointed to by | ||
490 | * @list, that must be empty initially, as members of struct resource_list_entry | ||
491 | * objects. Callers of this routine should use %acpi_dev_free_resource_list() to | ||
492 | * free that list. | ||
493 | * | ||
494 | * The number of resources in the output list is returned on success, an error | ||
495 | * code reflecting the error condition is returned otherwise. | ||
496 | */ | ||
497 | int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, | ||
498 | int (*preproc)(struct acpi_resource *, void *), | ||
499 | void *preproc_data) | ||
500 | { | ||
501 | struct res_proc_context c; | ||
502 | acpi_handle not_used; | ||
503 | acpi_status status; | ||
504 | |||
505 | if (!adev || !adev->handle || !list_empty(list)) | ||
506 | return -EINVAL; | ||
507 | |||
508 | status = acpi_get_handle(adev->handle, METHOD_NAME__CRS, ¬_used); | ||
509 | if (ACPI_FAILURE(status)) | ||
510 | return 0; | ||
511 | |||
512 | c.list = list; | ||
513 | c.preproc = preproc; | ||
514 | c.preproc_data = preproc_data; | ||
515 | c.count = 0; | ||
516 | c.error = 0; | ||
517 | status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS, | ||
518 | acpi_dev_process_resource, &c); | ||
519 | if (ACPI_FAILURE(status)) { | ||
520 | acpi_dev_free_resource_list(list); | ||
521 | return c.error ? c.error : -EIO; | ||
522 | } | ||
523 | |||
524 | return c.count; | ||
525 | } | ||
526 | EXPORT_SYMBOL_GPL(acpi_dev_get_resources); | ||
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index d0b38ab47ab5..67a7fa638f7f 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -29,6 +29,17 @@ extern struct acpi_device *acpi_root; | |||
29 | 29 | ||
30 | static const char *dummy_hid = "device"; | 30 | static const char *dummy_hid = "device"; |
31 | 31 | ||
32 | /* | ||
33 | * The following ACPI IDs are known to be suitable for representing as | ||
34 | * platform devices. | ||
35 | */ | ||
36 | static const struct acpi_device_id acpi_platform_device_ids[] = { | ||
37 | |||
38 | { "PNP0D40" }, | ||
39 | |||
40 | { } | ||
41 | }; | ||
42 | |||
32 | static LIST_HEAD(acpi_device_list); | 43 | static LIST_HEAD(acpi_device_list); |
33 | static LIST_HEAD(acpi_bus_id_list); | 44 | static LIST_HEAD(acpi_bus_id_list); |
34 | DEFINE_MUTEX(acpi_device_lock); | 45 | DEFINE_MUTEX(acpi_device_lock); |
@@ -397,8 +408,8 @@ static void acpi_device_remove_files(struct acpi_device *dev) | |||
397 | ACPI Bus operations | 408 | ACPI Bus operations |
398 | -------------------------------------------------------------------------- */ | 409 | -------------------------------------------------------------------------- */ |
399 | 410 | ||
400 | int acpi_match_device_ids(struct acpi_device *device, | 411 | static const struct acpi_device_id *__acpi_match_device( |
401 | const struct acpi_device_id *ids) | 412 | struct acpi_device *device, const struct acpi_device_id *ids) |
402 | { | 413 | { |
403 | const struct acpi_device_id *id; | 414 | const struct acpi_device_id *id; |
404 | struct acpi_hardware_id *hwid; | 415 | struct acpi_hardware_id *hwid; |
@@ -408,14 +419,44 @@ int acpi_match_device_ids(struct acpi_device *device, | |||
408 | * driver for it. | 419 | * driver for it. |
409 | */ | 420 | */ |
410 | if (!device->status.present) | 421 | if (!device->status.present) |
411 | return -ENODEV; | 422 | return NULL; |
412 | 423 | ||
413 | for (id = ids; id->id[0]; id++) | 424 | for (id = ids; id->id[0]; id++) |
414 | list_for_each_entry(hwid, &device->pnp.ids, list) | 425 | list_for_each_entry(hwid, &device->pnp.ids, list) |
415 | if (!strcmp((char *) id->id, hwid->id)) | 426 | if (!strcmp((char *) id->id, hwid->id)) |
416 | return 0; | 427 | return id; |
428 | |||
429 | return NULL; | ||
430 | } | ||
431 | |||
432 | /** | ||
433 | * acpi_match_device - Match a struct device against a given list of ACPI IDs | ||
434 | * @ids: Array of struct acpi_device_id object to match against. | ||
435 | * @dev: The device structure to match. | ||
436 | * | ||
437 | * Check if @dev has a valid ACPI handle and if there is a struct acpi_device | ||
438 | * object for that handle and use that object to match against a given list of | ||
439 | * device IDs. | ||
440 | * | ||
441 | * Return a pointer to the first matching ID on success or %NULL on failure. | ||
442 | */ | ||
443 | const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, | ||
444 | const struct device *dev) | ||
445 | { | ||
446 | struct acpi_device *adev; | ||
417 | 447 | ||
418 | return -ENOENT; | 448 | if (!ids || !ACPI_HANDLE(dev) |
449 | || ACPI_FAILURE(acpi_bus_get_device(ACPI_HANDLE(dev), &adev))) | ||
450 | return NULL; | ||
451 | |||
452 | return __acpi_match_device(adev, ids); | ||
453 | } | ||
454 | EXPORT_SYMBOL_GPL(acpi_match_device); | ||
455 | |||
456 | int acpi_match_device_ids(struct acpi_device *device, | ||
457 | const struct acpi_device_id *ids) | ||
458 | { | ||
459 | return __acpi_match_device(device, ids) ? 0 : -ENOENT; | ||
419 | } | 460 | } |
420 | EXPORT_SYMBOL(acpi_match_device_ids); | 461 | EXPORT_SYMBOL(acpi_match_device_ids); |
421 | 462 | ||
@@ -1023,8 +1064,10 @@ static int acpi_bus_get_power_flags(struct acpi_device *device) | |||
1023 | * D3hot is only valid if _PR3 present. | 1064 | * D3hot is only valid if _PR3 present. |
1024 | */ | 1065 | */ |
1025 | if (ps->resources.count || | 1066 | if (ps->resources.count || |
1026 | (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT)) | 1067 | (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT)) { |
1027 | ps->flags.valid = 1; | 1068 | ps->flags.valid = 1; |
1069 | ps->flags.os_accessible = 1; | ||
1070 | } | ||
1028 | 1071 | ||
1029 | ps->power = -1; /* Unknown - driver assigned */ | 1072 | ps->power = -1; /* Unknown - driver assigned */ |
1030 | ps->latency = -1; /* Unknown - driver assigned */ | 1073 | ps->latency = -1; /* Unknown - driver assigned */ |
@@ -1040,6 +1083,11 @@ static int acpi_bus_get_power_flags(struct acpi_device *device) | |||
1040 | if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set) | 1083 | if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set) |
1041 | device->power.states[ACPI_STATE_D3_COLD].flags.explicit_set = 1; | 1084 | device->power.states[ACPI_STATE_D3_COLD].flags.explicit_set = 1; |
1042 | 1085 | ||
1086 | /* Presence of _PS3 or _PRx means we can put the device into D3 cold */ | ||
1087 | if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set || | ||
1088 | device->power.flags.power_resources) | ||
1089 | device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1; | ||
1090 | |||
1043 | acpi_bus_init_power(device); | 1091 | acpi_bus_init_power(device); |
1044 | 1092 | ||
1045 | return 0; | 1093 | return 0; |
@@ -1238,7 +1286,7 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
1238 | { | 1286 | { |
1239 | acpi_status status; | 1287 | acpi_status status; |
1240 | struct acpi_device_info *info; | 1288 | struct acpi_device_info *info; |
1241 | struct acpica_device_id_list *cid_list; | 1289 | struct acpi_pnp_device_id_list *cid_list; |
1242 | int i; | 1290 | int i; |
1243 | 1291 | ||
1244 | switch (device->device_type) { | 1292 | switch (device->device_type) { |
@@ -1539,8 +1587,13 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, | |||
1539 | */ | 1587 | */ |
1540 | device = NULL; | 1588 | device = NULL; |
1541 | acpi_bus_get_device(handle, &device); | 1589 | acpi_bus_get_device(handle, &device); |
1542 | if (ops->acpi_op_add && !device) | 1590 | if (ops->acpi_op_add && !device) { |
1543 | acpi_add_single_object(&device, handle, type, sta, ops); | 1591 | acpi_add_single_object(&device, handle, type, sta, ops); |
1592 | /* Is the device a known good platform device? */ | ||
1593 | if (device | ||
1594 | && !acpi_match_device_ids(device, acpi_platform_device_ids)) | ||
1595 | acpi_create_platform_device(device); | ||
1596 | } | ||
1544 | 1597 | ||
1545 | if (!device) | 1598 | if (!device) |
1546 | return AE_CTRL_DEPTH; | 1599 | return AE_CTRL_DEPTH; |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 6efef87b405c..2fcc67d34b11 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/reboot.h> | 18 | #include <linux/reboot.h> |
19 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/pm_runtime.h> | ||
22 | 21 | ||
23 | #include <asm/io.h> | 22 | #include <asm/io.h> |
24 | 23 | ||
@@ -81,6 +80,12 @@ static int acpi_sleep_prepare(u32 acpi_state) | |||
81 | 80 | ||
82 | #ifdef CONFIG_ACPI_SLEEP | 81 | #ifdef CONFIG_ACPI_SLEEP |
83 | static u32 acpi_target_sleep_state = ACPI_STATE_S0; | 82 | static u32 acpi_target_sleep_state = ACPI_STATE_S0; |
83 | |||
84 | u32 acpi_target_system_state(void) | ||
85 | { | ||
86 | return acpi_target_sleep_state; | ||
87 | } | ||
88 | |||
84 | static bool pwr_btn_event_pending; | 89 | static bool pwr_btn_event_pending; |
85 | 90 | ||
86 | /* | 91 | /* |
@@ -710,177 +715,6 @@ int acpi_suspend(u32 acpi_state) | |||
710 | return -EINVAL; | 715 | return -EINVAL; |
711 | } | 716 | } |
712 | 717 | ||
713 | #ifdef CONFIG_PM | ||
714 | /** | ||
715 | * acpi_pm_device_sleep_state - return preferred power state of ACPI device | ||
716 | * in the system sleep state given by %acpi_target_sleep_state | ||
717 | * @dev: device to examine; its driver model wakeup flags control | ||
718 | * whether it should be able to wake up the system | ||
719 | * @d_min_p: used to store the upper limit of allowed states range | ||
720 | * @d_max_in: specify the lowest allowed states | ||
721 | * Return value: preferred power state of the device on success, -ENODEV | ||
722 | * (ie. if there's no 'struct acpi_device' for @dev) or -EINVAL on failure | ||
723 | * | ||
724 | * Find the lowest power (highest number) ACPI device power state that | ||
725 | * device @dev can be in while the system is in the sleep state represented | ||
726 | * by %acpi_target_sleep_state. If @wake is nonzero, the device should be | ||
727 | * able to wake up the system from this sleep state. If @d_min_p is set, | ||
728 | * the highest power (lowest number) device power state of @dev allowed | ||
729 | * in this system sleep state is stored at the location pointed to by it. | ||
730 | * | ||
731 | * The caller must ensure that @dev is valid before using this function. | ||
732 | * The caller is also responsible for figuring out if the device is | ||
733 | * supposed to be able to wake up the system and passing this information | ||
734 | * via @wake. | ||
735 | */ | ||
736 | |||
737 | int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) | ||
738 | { | ||
739 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | ||
740 | struct acpi_device *adev; | ||
741 | char acpi_method[] = "_SxD"; | ||
742 | unsigned long long d_min, d_max; | ||
743 | |||
744 | if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3) | ||
745 | return -EINVAL; | ||
746 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { | ||
747 | printk(KERN_DEBUG "ACPI handle has no context!\n"); | ||
748 | return -ENODEV; | ||
749 | } | ||
750 | |||
751 | acpi_method[2] = '0' + acpi_target_sleep_state; | ||
752 | /* | ||
753 | * If the sleep state is S0, the lowest limit from ACPI is D3, | ||
754 | * but if the device has _S0W, we will use the value from _S0W | ||
755 | * as the lowest limit from ACPI. Finally, we will constrain | ||
756 | * the lowest limit with the specified one. | ||
757 | */ | ||
758 | d_min = ACPI_STATE_D0; | ||
759 | d_max = ACPI_STATE_D3; | ||
760 | |||
761 | /* | ||
762 | * If present, _SxD methods return the minimum D-state (highest power | ||
763 | * state) we can use for the corresponding S-states. Otherwise, the | ||
764 | * minimum D-state is D0 (ACPI 3.x). | ||
765 | * | ||
766 | * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer | ||
767 | * provided -- that's our fault recovery, we ignore retval. | ||
768 | */ | ||
769 | if (acpi_target_sleep_state > ACPI_STATE_S0) | ||
770 | acpi_evaluate_integer(handle, acpi_method, NULL, &d_min); | ||
771 | |||
772 | /* | ||
773 | * If _PRW says we can wake up the system from the target sleep state, | ||
774 | * the D-state returned by _SxD is sufficient for that (we assume a | ||
775 | * wakeup-aware driver if wake is set). Still, if _SxW exists | ||
776 | * (ACPI 3.x), it should return the maximum (lowest power) D-state that | ||
777 | * can wake the system. _S0W may be valid, too. | ||
778 | */ | ||
779 | if (acpi_target_sleep_state == ACPI_STATE_S0 || | ||
780 | (device_may_wakeup(dev) && adev->wakeup.flags.valid && | ||
781 | adev->wakeup.sleep_state >= acpi_target_sleep_state)) { | ||
782 | acpi_status status; | ||
783 | |||
784 | acpi_method[3] = 'W'; | ||
785 | status = acpi_evaluate_integer(handle, acpi_method, NULL, | ||
786 | &d_max); | ||
787 | if (ACPI_FAILURE(status)) { | ||
788 | if (acpi_target_sleep_state != ACPI_STATE_S0 || | ||
789 | status != AE_NOT_FOUND) | ||
790 | d_max = d_min; | ||
791 | } else if (d_max < d_min) { | ||
792 | /* Warn the user of the broken DSDT */ | ||
793 | printk(KERN_WARNING "ACPI: Wrong value from %s\n", | ||
794 | acpi_method); | ||
795 | /* Sanitize it */ | ||
796 | d_min = d_max; | ||
797 | } | ||
798 | } | ||
799 | |||
800 | if (d_max_in < d_min) | ||
801 | return -EINVAL; | ||
802 | if (d_min_p) | ||
803 | *d_min_p = d_min; | ||
804 | /* constrain d_max with specified lowest limit (max number) */ | ||
805 | if (d_max > d_max_in) { | ||
806 | for (d_max = d_max_in; d_max > d_min; d_max--) { | ||
807 | if (adev->power.states[d_max].flags.valid) | ||
808 | break; | ||
809 | } | ||
810 | } | ||
811 | return d_max; | ||
812 | } | ||
813 | EXPORT_SYMBOL(acpi_pm_device_sleep_state); | ||
814 | #endif /* CONFIG_PM */ | ||
815 | |||
816 | #ifdef CONFIG_PM_SLEEP | ||
817 | /** | ||
818 | * acpi_pm_device_run_wake - Enable/disable wake-up for given device. | ||
819 | * @phys_dev: Device to enable/disable the platform to wake-up the system for. | ||
820 | * @enable: Whether enable or disable the wake-up functionality. | ||
821 | * | ||
822 | * Find the ACPI device object corresponding to @pci_dev and try to | ||
823 | * enable/disable the GPE associated with it. | ||
824 | */ | ||
825 | int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) | ||
826 | { | ||
827 | struct acpi_device *dev; | ||
828 | acpi_handle handle; | ||
829 | |||
830 | if (!device_run_wake(phys_dev)) | ||
831 | return -EINVAL; | ||
832 | |||
833 | handle = DEVICE_ACPI_HANDLE(phys_dev); | ||
834 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &dev))) { | ||
835 | dev_dbg(phys_dev, "ACPI handle has no context in %s!\n", | ||
836 | __func__); | ||
837 | return -ENODEV; | ||
838 | } | ||
839 | |||
840 | if (enable) { | ||
841 | acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); | ||
842 | acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); | ||
843 | } else { | ||
844 | acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); | ||
845 | acpi_disable_wakeup_device_power(dev); | ||
846 | } | ||
847 | |||
848 | return 0; | ||
849 | } | ||
850 | EXPORT_SYMBOL(acpi_pm_device_run_wake); | ||
851 | |||
852 | /** | ||
853 | * acpi_pm_device_sleep_wake - enable or disable the system wake-up | ||
854 | * capability of given device | ||
855 | * @dev: device to handle | ||
856 | * @enable: 'true' - enable, 'false' - disable the wake-up capability | ||
857 | */ | ||
858 | int acpi_pm_device_sleep_wake(struct device *dev, bool enable) | ||
859 | { | ||
860 | acpi_handle handle; | ||
861 | struct acpi_device *adev; | ||
862 | int error; | ||
863 | |||
864 | if (!device_can_wakeup(dev)) | ||
865 | return -EINVAL; | ||
866 | |||
867 | handle = DEVICE_ACPI_HANDLE(dev); | ||
868 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { | ||
869 | dev_dbg(dev, "ACPI handle has no context in %s!\n", __func__); | ||
870 | return -ENODEV; | ||
871 | } | ||
872 | |||
873 | error = enable ? | ||
874 | acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) : | ||
875 | acpi_disable_wakeup_device_power(adev); | ||
876 | if (!error) | ||
877 | dev_info(dev, "wake-up capability %s by ACPI\n", | ||
878 | enable ? "enabled" : "disabled"); | ||
879 | |||
880 | return error; | ||
881 | } | ||
882 | #endif /* CONFIG_PM_SLEEP */ | ||
883 | |||
884 | static void acpi_power_off_prepare(void) | 718 | static void acpi_power_off_prepare(void) |
885 | { | 719 | { |
886 | /* Prepare to power off the system */ | 720 | /* Prepare to power off the system */ |
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 7c3f98ba4afe..ea61ca9129cd 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
@@ -476,7 +476,7 @@ static void fixed_event_count(u32 event_number) | |||
476 | return; | 476 | return; |
477 | } | 477 | } |
478 | 478 | ||
479 | static void acpi_gbl_event_handler(u32 event_type, acpi_handle device, | 479 | static void acpi_global_event_handler(u32 event_type, acpi_handle device, |
480 | u32 event_number, void *context) | 480 | u32 event_number, void *context) |
481 | { | 481 | { |
482 | if (event_type == ACPI_EVENT_TYPE_GPE) | 482 | if (event_type == ACPI_EVENT_TYPE_GPE) |
@@ -638,7 +638,7 @@ void acpi_irq_stats_init(void) | |||
638 | if (all_counters == NULL) | 638 | if (all_counters == NULL) |
639 | goto fail; | 639 | goto fail; |
640 | 640 | ||
641 | status = acpi_install_global_event_handler(acpi_gbl_event_handler, NULL); | 641 | status = acpi_install_global_event_handler(acpi_global_event_handler, NULL); |
642 | if (ACPI_FAILURE(status)) | 642 | if (ACPI_FAILURE(status)) |
643 | goto fail; | 643 | goto fail; |
644 | 644 | ||