diff options
Diffstat (limited to 'drivers/acpi/executer/exconfig.c')
-rw-r--r-- | drivers/acpi/executer/exconfig.c | 319 |
1 files changed, 155 insertions, 164 deletions
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index d11e9ec827f1..1ce365d651d8 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c | |||
@@ -41,7 +41,6 @@ | |||
41 | * POSSIBILITY OF SUCH DAMAGES. | 41 | * POSSIBILITY OF SUCH DAMAGES. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | |||
45 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
46 | #include <acpi/acinterp.h> | 45 | #include <acpi/acinterp.h> |
47 | #include <acpi/amlcode.h> | 46 | #include <acpi/amlcode.h> |
@@ -50,18 +49,14 @@ | |||
50 | #include <acpi/actables.h> | 49 | #include <acpi/actables.h> |
51 | #include <acpi/acdispat.h> | 50 | #include <acpi/acdispat.h> |
52 | 51 | ||
53 | |||
54 | #define _COMPONENT ACPI_EXECUTER | 52 | #define _COMPONENT ACPI_EXECUTER |
55 | ACPI_MODULE_NAME ("exconfig") | 53 | ACPI_MODULE_NAME("exconfig") |
56 | 54 | ||
57 | /* Local prototypes */ | 55 | /* Local prototypes */ |
58 | |||
59 | static acpi_status | 56 | static acpi_status |
60 | acpi_ex_add_table ( | 57 | acpi_ex_add_table(struct acpi_table_header *table, |
61 | struct acpi_table_header *table, | 58 | struct acpi_namespace_node *parent_node, |
62 | struct acpi_namespace_node *parent_node, | 59 | union acpi_operand_object **ddb_handle); |
63 | union acpi_operand_object **ddb_handle); | ||
64 | |||
65 | 60 | ||
66 | /******************************************************************************* | 61 | /******************************************************************************* |
67 | * | 62 | * |
@@ -79,24 +74,21 @@ acpi_ex_add_table ( | |||
79 | ******************************************************************************/ | 74 | ******************************************************************************/ |
80 | 75 | ||
81 | static acpi_status | 76 | static acpi_status |
82 | acpi_ex_add_table ( | 77 | acpi_ex_add_table(struct acpi_table_header *table, |
83 | struct acpi_table_header *table, | 78 | struct acpi_namespace_node *parent_node, |
84 | struct acpi_namespace_node *parent_node, | 79 | union acpi_operand_object **ddb_handle) |
85 | union acpi_operand_object **ddb_handle) | ||
86 | { | 80 | { |
87 | acpi_status status; | 81 | acpi_status status; |
88 | struct acpi_table_desc table_info; | 82 | struct acpi_table_desc table_info; |
89 | union acpi_operand_object *obj_desc; | 83 | union acpi_operand_object *obj_desc; |
90 | |||
91 | |||
92 | ACPI_FUNCTION_TRACE ("ex_add_table"); | ||
93 | 84 | ||
85 | ACPI_FUNCTION_TRACE("ex_add_table"); | ||
94 | 86 | ||
95 | /* Create an object to be the table handle */ | 87 | /* Create an object to be the table handle */ |
96 | 88 | ||
97 | obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE); | 89 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE); |
98 | if (!obj_desc) { | 90 | if (!obj_desc) { |
99 | return_ACPI_STATUS (AE_NO_MEMORY); | 91 | return_ACPI_STATUS(AE_NO_MEMORY); |
100 | } | 92 | } |
101 | 93 | ||
102 | /* Init the table handle */ | 94 | /* Init the table handle */ |
@@ -106,45 +98,43 @@ acpi_ex_add_table ( | |||
106 | 98 | ||
107 | /* Install the new table into the local data structures */ | 99 | /* Install the new table into the local data structures */ |
108 | 100 | ||
109 | ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc)); | 101 | ACPI_MEMSET(&table_info, 0, sizeof(struct acpi_table_desc)); |
110 | 102 | ||
111 | table_info.type = ACPI_TABLE_SSDT; | 103 | table_info.type = ACPI_TABLE_SSDT; |
112 | table_info.pointer = table; | 104 | table_info.pointer = table; |
113 | table_info.length = (acpi_size) table->length; | 105 | table_info.length = (acpi_size) table->length; |
114 | table_info.allocation = ACPI_MEM_ALLOCATED; | 106 | table_info.allocation = ACPI_MEM_ALLOCATED; |
115 | 107 | ||
116 | status = acpi_tb_install_table (&table_info); | 108 | status = acpi_tb_install_table(&table_info); |
117 | obj_desc->reference.object = table_info.installed_desc; | 109 | obj_desc->reference.object = table_info.installed_desc; |
118 | 110 | ||
119 | if (ACPI_FAILURE (status)) { | 111 | if (ACPI_FAILURE(status)) { |
120 | if (status == AE_ALREADY_EXISTS) { | 112 | if (status == AE_ALREADY_EXISTS) { |
121 | /* Table already exists, just return the handle */ | 113 | /* Table already exists, just return the handle */ |
122 | 114 | ||
123 | return_ACPI_STATUS (AE_OK); | 115 | return_ACPI_STATUS(AE_OK); |
124 | } | 116 | } |
125 | goto cleanup; | 117 | goto cleanup; |
126 | } | 118 | } |
127 | 119 | ||
128 | /* Add the table to the namespace */ | 120 | /* Add the table to the namespace */ |
129 | 121 | ||
130 | status = acpi_ns_load_table (table_info.installed_desc, parent_node); | 122 | status = acpi_ns_load_table(table_info.installed_desc, parent_node); |
131 | if (ACPI_FAILURE (status)) { | 123 | if (ACPI_FAILURE(status)) { |
132 | /* Uninstall table on error */ | 124 | /* Uninstall table on error */ |
133 | 125 | ||
134 | (void) acpi_tb_uninstall_table (table_info.installed_desc); | 126 | (void)acpi_tb_uninstall_table(table_info.installed_desc); |
135 | goto cleanup; | 127 | goto cleanup; |
136 | } | 128 | } |
137 | 129 | ||
138 | return_ACPI_STATUS (AE_OK); | 130 | return_ACPI_STATUS(AE_OK); |
139 | |||
140 | 131 | ||
141 | cleanup: | 132 | cleanup: |
142 | acpi_ut_remove_reference (obj_desc); | 133 | acpi_ut_remove_reference(obj_desc); |
143 | *ddb_handle = NULL; | 134 | *ddb_handle = NULL; |
144 | return_ACPI_STATUS (status); | 135 | return_ACPI_STATUS(status); |
145 | } | 136 | } |
146 | 137 | ||
147 | |||
148 | /******************************************************************************* | 138 | /******************************************************************************* |
149 | * | 139 | * |
150 | * FUNCTION: acpi_ex_load_table_op | 140 | * FUNCTION: acpi_ex_load_table_op |
@@ -159,56 +149,53 @@ cleanup: | |||
159 | ******************************************************************************/ | 149 | ******************************************************************************/ |
160 | 150 | ||
161 | acpi_status | 151 | acpi_status |
162 | acpi_ex_load_table_op ( | 152 | acpi_ex_load_table_op(struct acpi_walk_state *walk_state, |
163 | struct acpi_walk_state *walk_state, | 153 | union acpi_operand_object **return_desc) |
164 | union acpi_operand_object **return_desc) | ||
165 | { | 154 | { |
166 | acpi_status status; | 155 | acpi_status status; |
167 | union acpi_operand_object **operand = &walk_state->operands[0]; | 156 | union acpi_operand_object **operand = &walk_state->operands[0]; |
168 | struct acpi_table_header *table; | 157 | struct acpi_table_header *table; |
169 | struct acpi_namespace_node *parent_node; | 158 | struct acpi_namespace_node *parent_node; |
170 | struct acpi_namespace_node *start_node; | 159 | struct acpi_namespace_node *start_node; |
171 | struct acpi_namespace_node *parameter_node = NULL; | 160 | struct acpi_namespace_node *parameter_node = NULL; |
172 | union acpi_operand_object *ddb_handle; | 161 | union acpi_operand_object *ddb_handle; |
173 | |||
174 | |||
175 | ACPI_FUNCTION_TRACE ("ex_load_table_op"); | ||
176 | 162 | ||
163 | ACPI_FUNCTION_TRACE("ex_load_table_op"); | ||
177 | 164 | ||
178 | #if 0 | 165 | #if 0 |
179 | /* | 166 | /* |
180 | * Make sure that the signature does not match one of the tables that | 167 | * Make sure that the signature does not match one of the tables that |
181 | * is already loaded. | 168 | * is already loaded. |
182 | */ | 169 | */ |
183 | status = acpi_tb_match_signature (operand[0]->string.pointer, NULL); | 170 | status = acpi_tb_match_signature(operand[0]->string.pointer, NULL); |
184 | if (status == AE_OK) { | 171 | if (status == AE_OK) { |
185 | /* Signature matched -- don't allow override */ | 172 | /* Signature matched -- don't allow override */ |
186 | 173 | ||
187 | return_ACPI_STATUS (AE_ALREADY_EXISTS); | 174 | return_ACPI_STATUS(AE_ALREADY_EXISTS); |
188 | } | 175 | } |
189 | #endif | 176 | #endif |
190 | 177 | ||
191 | /* Find the ACPI table */ | 178 | /* Find the ACPI table */ |
192 | 179 | ||
193 | status = acpi_tb_find_table (operand[0]->string.pointer, | 180 | status = acpi_tb_find_table(operand[0]->string.pointer, |
194 | operand[1]->string.pointer, | 181 | operand[1]->string.pointer, |
195 | operand[2]->string.pointer, &table); | 182 | operand[2]->string.pointer, &table); |
196 | if (ACPI_FAILURE (status)) { | 183 | if (ACPI_FAILURE(status)) { |
197 | if (status != AE_NOT_FOUND) { | 184 | if (status != AE_NOT_FOUND) { |
198 | return_ACPI_STATUS (status); | 185 | return_ACPI_STATUS(status); |
199 | } | 186 | } |
200 | 187 | ||
201 | /* Table not found, return an Integer=0 and AE_OK */ | 188 | /* Table not found, return an Integer=0 and AE_OK */ |
202 | 189 | ||
203 | ddb_handle = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); | 190 | ddb_handle = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
204 | if (!ddb_handle) { | 191 | if (!ddb_handle) { |
205 | return_ACPI_STATUS (AE_NO_MEMORY); | 192 | return_ACPI_STATUS(AE_NO_MEMORY); |
206 | } | 193 | } |
207 | 194 | ||
208 | ddb_handle->integer.value = 0; | 195 | ddb_handle->integer.value = 0; |
209 | *return_desc = ddb_handle; | 196 | *return_desc = ddb_handle; |
210 | 197 | ||
211 | return_ACPI_STATUS (AE_OK); | 198 | return_ACPI_STATUS(AE_OK); |
212 | } | 199 | } |
213 | 200 | ||
214 | /* Default nodes */ | 201 | /* Default nodes */ |
@@ -223,10 +210,12 @@ acpi_ex_load_table_op ( | |||
223 | * Find the node referenced by the root_path_string. This is the | 210 | * Find the node referenced by the root_path_string. This is the |
224 | * location within the namespace where the table will be loaded. | 211 | * location within the namespace where the table will be loaded. |
225 | */ | 212 | */ |
226 | status = acpi_ns_get_node_by_path (operand[3]->string.pointer, start_node, | 213 | status = |
227 | ACPI_NS_SEARCH_PARENT, &parent_node); | 214 | acpi_ns_get_node_by_path(operand[3]->string.pointer, |
228 | if (ACPI_FAILURE (status)) { | 215 | start_node, ACPI_NS_SEARCH_PARENT, |
229 | return_ACPI_STATUS (status); | 216 | &parent_node); |
217 | if (ACPI_FAILURE(status)) { | ||
218 | return_ACPI_STATUS(status); | ||
230 | } | 219 | } |
231 | } | 220 | } |
232 | 221 | ||
@@ -234,7 +223,7 @@ acpi_ex_load_table_op ( | |||
234 | 223 | ||
235 | if (operand[4]->string.length > 0) { | 224 | if (operand[4]->string.length > 0) { |
236 | if ((operand[4]->string.pointer[0] != '\\') && | 225 | if ((operand[4]->string.pointer[0] != '\\') && |
237 | (operand[4]->string.pointer[0] != '^')) { | 226 | (operand[4]->string.pointer[0] != '^')) { |
238 | /* | 227 | /* |
239 | * Path is not absolute, so it will be relative to the node | 228 | * Path is not absolute, so it will be relative to the node |
240 | * referenced by the root_path_string (or the NS root if omitted) | 229 | * referenced by the root_path_string (or the NS root if omitted) |
@@ -244,18 +233,20 @@ acpi_ex_load_table_op ( | |||
244 | 233 | ||
245 | /* Find the node referenced by the parameter_path_string */ | 234 | /* Find the node referenced by the parameter_path_string */ |
246 | 235 | ||
247 | status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node, | 236 | status = |
248 | ACPI_NS_SEARCH_PARENT, ¶meter_node); | 237 | acpi_ns_get_node_by_path(operand[4]->string.pointer, |
249 | if (ACPI_FAILURE (status)) { | 238 | start_node, ACPI_NS_SEARCH_PARENT, |
250 | return_ACPI_STATUS (status); | 239 | ¶meter_node); |
240 | if (ACPI_FAILURE(status)) { | ||
241 | return_ACPI_STATUS(status); | ||
251 | } | 242 | } |
252 | } | 243 | } |
253 | 244 | ||
254 | /* Load the table into the namespace */ | 245 | /* Load the table into the namespace */ |
255 | 246 | ||
256 | status = acpi_ex_add_table (table, parent_node, &ddb_handle); | 247 | status = acpi_ex_add_table(table, parent_node, &ddb_handle); |
257 | if (ACPI_FAILURE (status)) { | 248 | if (ACPI_FAILURE(status)) { |
258 | return_ACPI_STATUS (status); | 249 | return_ACPI_STATUS(status); |
259 | } | 250 | } |
260 | 251 | ||
261 | /* Parameter Data (optional) */ | 252 | /* Parameter Data (optional) */ |
@@ -263,20 +254,20 @@ acpi_ex_load_table_op ( | |||
263 | if (parameter_node) { | 254 | if (parameter_node) { |
264 | /* Store the parameter data into the optional parameter object */ | 255 | /* Store the parameter data into the optional parameter object */ |
265 | 256 | ||
266 | status = acpi_ex_store (operand[5], | 257 | status = acpi_ex_store(operand[5], |
267 | ACPI_CAST_PTR (union acpi_operand_object, parameter_node), | 258 | ACPI_CAST_PTR(union acpi_operand_object, |
268 | walk_state); | 259 | parameter_node), |
269 | if (ACPI_FAILURE (status)) { | 260 | walk_state); |
270 | (void) acpi_ex_unload_table (ddb_handle); | 261 | if (ACPI_FAILURE(status)) { |
271 | return_ACPI_STATUS (status); | 262 | (void)acpi_ex_unload_table(ddb_handle); |
263 | return_ACPI_STATUS(status); | ||
272 | } | 264 | } |
273 | } | 265 | } |
274 | 266 | ||
275 | *return_desc = ddb_handle; | 267 | *return_desc = ddb_handle; |
276 | return_ACPI_STATUS (status); | 268 | return_ACPI_STATUS(status); |
277 | } | 269 | } |
278 | 270 | ||
279 | |||
280 | /******************************************************************************* | 271 | /******************************************************************************* |
281 | * | 272 | * |
282 | * FUNCTION: acpi_ex_load_op | 273 | * FUNCTION: acpi_ex_load_op |
@@ -293,38 +284,37 @@ acpi_ex_load_table_op ( | |||
293 | ******************************************************************************/ | 284 | ******************************************************************************/ |
294 | 285 | ||
295 | acpi_status | 286 | acpi_status |
296 | acpi_ex_load_op ( | 287 | acpi_ex_load_op(union acpi_operand_object *obj_desc, |
297 | union acpi_operand_object *obj_desc, | 288 | union acpi_operand_object *target, |
298 | union acpi_operand_object *target, | 289 | struct acpi_walk_state *walk_state) |
299 | struct acpi_walk_state *walk_state) | ||
300 | { | 290 | { |
301 | acpi_status status; | 291 | acpi_status status; |
302 | union acpi_operand_object *ddb_handle; | 292 | union acpi_operand_object *ddb_handle; |
303 | union acpi_operand_object *buffer_desc = NULL; | 293 | union acpi_operand_object *buffer_desc = NULL; |
304 | struct acpi_table_header *table_ptr = NULL; | 294 | struct acpi_table_header *table_ptr = NULL; |
305 | acpi_physical_address address; | 295 | acpi_physical_address address; |
306 | struct acpi_table_header table_header; | 296 | struct acpi_table_header table_header; |
307 | u32 i; | 297 | u32 i; |
308 | |||
309 | ACPI_FUNCTION_TRACE ("ex_load_op"); | ||
310 | 298 | ||
299 | ACPI_FUNCTION_TRACE("ex_load_op"); | ||
311 | 300 | ||
312 | /* Object can be either an op_region or a Field */ | 301 | /* Object can be either an op_region or a Field */ |
313 | 302 | ||
314 | switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { | 303 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
315 | case ACPI_TYPE_REGION: | 304 | case ACPI_TYPE_REGION: |
316 | 305 | ||
317 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", | 306 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Region %p %s\n", |
318 | obj_desc, acpi_ut_get_object_type_name (obj_desc))); | 307 | obj_desc, |
308 | acpi_ut_get_object_type_name(obj_desc))); | ||
319 | 309 | ||
320 | /* | 310 | /* |
321 | * If the Region Address and Length have not been previously evaluated, | 311 | * If the Region Address and Length have not been previously evaluated, |
322 | * evaluate them now and save the results. | 312 | * evaluate them now and save the results. |
323 | */ | 313 | */ |
324 | if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { | 314 | if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { |
325 | status = acpi_ds_get_region_arguments (obj_desc); | 315 | status = acpi_ds_get_region_arguments(obj_desc); |
326 | if (ACPI_FAILURE (status)) { | 316 | if (ACPI_FAILURE(status)) { |
327 | return_ACPI_STATUS (status); | 317 | return_ACPI_STATUS(status); |
328 | } | 318 | } |
329 | } | 319 | } |
330 | 320 | ||
@@ -336,121 +326,127 @@ acpi_ex_load_op ( | |||
336 | 326 | ||
337 | table_header.length = 0; | 327 | table_header.length = 0; |
338 | for (i = 0; i < 8; i++) { | 328 | for (i = 0; i < 8; i++) { |
339 | status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ, | 329 | status = |
340 | (acpi_physical_address) (i + address), 8, | 330 | acpi_ev_address_space_dispatch(obj_desc, ACPI_READ, |
341 | ((u8 *) &table_header) + i); | 331 | (acpi_physical_address) |
342 | if (ACPI_FAILURE (status)) { | 332 | (i + address), 8, |
343 | return_ACPI_STATUS (status); | 333 | ((u8 *) & |
334 | table_header) + i); | ||
335 | if (ACPI_FAILURE(status)) { | ||
336 | return_ACPI_STATUS(status); | ||
344 | } | 337 | } |
345 | } | 338 | } |
346 | 339 | ||
347 | /* Sanity check the table length */ | 340 | /* Sanity check the table length */ |
348 | 341 | ||
349 | if (table_header.length < sizeof (struct acpi_table_header)) { | 342 | if (table_header.length < sizeof(struct acpi_table_header)) { |
350 | return_ACPI_STATUS (AE_BAD_HEADER); | 343 | return_ACPI_STATUS(AE_BAD_HEADER); |
351 | } | 344 | } |
352 | 345 | ||
353 | /* Allocate a buffer for the entire table */ | 346 | /* Allocate a buffer for the entire table */ |
354 | 347 | ||
355 | table_ptr = ACPI_MEM_ALLOCATE (table_header.length); | 348 | table_ptr = ACPI_MEM_ALLOCATE(table_header.length); |
356 | if (!table_ptr) { | 349 | if (!table_ptr) { |
357 | return_ACPI_STATUS (AE_NO_MEMORY); | 350 | return_ACPI_STATUS(AE_NO_MEMORY); |
358 | } | 351 | } |
359 | 352 | ||
360 | /* Get the entire table from the op region */ | 353 | /* Get the entire table from the op region */ |
361 | 354 | ||
362 | for (i = 0; i < table_header.length; i++) { | 355 | for (i = 0; i < table_header.length; i++) { |
363 | status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ, | 356 | status = |
364 | (acpi_physical_address) (i + address), 8, | 357 | acpi_ev_address_space_dispatch(obj_desc, ACPI_READ, |
365 | ((u8 *) table_ptr + i)); | 358 | (acpi_physical_address) |
366 | if (ACPI_FAILURE (status)) { | 359 | (i + address), 8, |
360 | ((u8 *) table_ptr + | ||
361 | i)); | ||
362 | if (ACPI_FAILURE(status)) { | ||
367 | goto cleanup; | 363 | goto cleanup; |
368 | } | 364 | } |
369 | } | 365 | } |
370 | break; | 366 | break; |
371 | 367 | ||
372 | |||
373 | case ACPI_TYPE_LOCAL_REGION_FIELD: | 368 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
374 | case ACPI_TYPE_LOCAL_BANK_FIELD: | 369 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
375 | case ACPI_TYPE_LOCAL_INDEX_FIELD: | 370 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
376 | 371 | ||
377 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n", | 372 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Field %p %s\n", |
378 | obj_desc, acpi_ut_get_object_type_name (obj_desc))); | 373 | obj_desc, |
374 | acpi_ut_get_object_type_name(obj_desc))); | ||
379 | 375 | ||
380 | /* | 376 | /* |
381 | * The length of the field must be at least as large as the table. | 377 | * The length of the field must be at least as large as the table. |
382 | * Read the entire field and thus the entire table. Buffer is | 378 | * Read the entire field and thus the entire table. Buffer is |
383 | * allocated during the read. | 379 | * allocated during the read. |
384 | */ | 380 | */ |
385 | status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc); | 381 | status = |
386 | if (ACPI_FAILURE (status)) { | 382 | acpi_ex_read_data_from_field(walk_state, obj_desc, |
387 | return_ACPI_STATUS (status); | 383 | &buffer_desc); |
384 | if (ACPI_FAILURE(status)) { | ||
385 | return_ACPI_STATUS(status); | ||
388 | } | 386 | } |
389 | 387 | ||
390 | table_ptr = ACPI_CAST_PTR (struct acpi_table_header, | 388 | table_ptr = ACPI_CAST_PTR(struct acpi_table_header, |
391 | buffer_desc->buffer.pointer); | 389 | buffer_desc->buffer.pointer); |
392 | 390 | ||
393 | /* All done with the buffer_desc, delete it */ | 391 | /* All done with the buffer_desc, delete it */ |
394 | 392 | ||
395 | buffer_desc->buffer.pointer = NULL; | 393 | buffer_desc->buffer.pointer = NULL; |
396 | acpi_ut_remove_reference (buffer_desc); | 394 | acpi_ut_remove_reference(buffer_desc); |
397 | 395 | ||
398 | /* Sanity check the table length */ | 396 | /* Sanity check the table length */ |
399 | 397 | ||
400 | if (table_ptr->length < sizeof (struct acpi_table_header)) { | 398 | if (table_ptr->length < sizeof(struct acpi_table_header)) { |
401 | status = AE_BAD_HEADER; | 399 | status = AE_BAD_HEADER; |
402 | goto cleanup; | 400 | goto cleanup; |
403 | } | 401 | } |
404 | break; | 402 | break; |
405 | 403 | ||
406 | |||
407 | default: | 404 | default: |
408 | return_ACPI_STATUS (AE_AML_OPERAND_TYPE); | 405 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
409 | } | 406 | } |
410 | 407 | ||
411 | /* The table must be either an SSDT or a PSDT */ | 408 | /* The table must be either an SSDT or a PSDT */ |
412 | 409 | ||
413 | if ((!ACPI_STRNCMP (table_ptr->signature, | 410 | if ((!ACPI_STRNCMP(table_ptr->signature, |
414 | acpi_gbl_table_data[ACPI_TABLE_PSDT].signature, | 411 | acpi_gbl_table_data[ACPI_TABLE_PSDT].signature, |
415 | acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) && | 412 | acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) && |
416 | (!ACPI_STRNCMP (table_ptr->signature, | 413 | (!ACPI_STRNCMP(table_ptr->signature, |
417 | acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, | 414 | acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, |
418 | acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { | 415 | acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { |
419 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | 416 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
420 | "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", | 417 | "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", |
421 | table_ptr->signature)); | 418 | table_ptr->signature)); |
422 | status = AE_BAD_SIGNATURE; | 419 | status = AE_BAD_SIGNATURE; |
423 | goto cleanup; | 420 | goto cleanup; |
424 | } | 421 | } |
425 | 422 | ||
426 | /* Install the new table into the local data structures */ | 423 | /* Install the new table into the local data structures */ |
427 | 424 | ||
428 | status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle); | 425 | status = acpi_ex_add_table(table_ptr, acpi_gbl_root_node, &ddb_handle); |
429 | if (ACPI_FAILURE (status)) { | 426 | if (ACPI_FAILURE(status)) { |
430 | /* On error, table_ptr was deallocated above */ | 427 | /* On error, table_ptr was deallocated above */ |
431 | 428 | ||
432 | return_ACPI_STATUS (status); | 429 | return_ACPI_STATUS(status); |
433 | } | 430 | } |
434 | 431 | ||
435 | /* Store the ddb_handle into the Target operand */ | 432 | /* Store the ddb_handle into the Target operand */ |
436 | 433 | ||
437 | status = acpi_ex_store (ddb_handle, target, walk_state); | 434 | status = acpi_ex_store(ddb_handle, target, walk_state); |
438 | if (ACPI_FAILURE (status)) { | 435 | if (ACPI_FAILURE(status)) { |
439 | (void) acpi_ex_unload_table (ddb_handle); | 436 | (void)acpi_ex_unload_table(ddb_handle); |
440 | 437 | ||
441 | /* table_ptr was deallocated above */ | 438 | /* table_ptr was deallocated above */ |
442 | 439 | ||
443 | return_ACPI_STATUS (status); | 440 | return_ACPI_STATUS(status); |
444 | } | 441 | } |
445 | 442 | ||
446 | cleanup: | 443 | cleanup: |
447 | if (ACPI_FAILURE (status)) { | 444 | if (ACPI_FAILURE(status)) { |
448 | ACPI_MEM_FREE (table_ptr); | 445 | ACPI_MEM_FREE(table_ptr); |
449 | } | 446 | } |
450 | return_ACPI_STATUS (status); | 447 | return_ACPI_STATUS(status); |
451 | } | 448 | } |
452 | 449 | ||
453 | |||
454 | /******************************************************************************* | 450 | /******************************************************************************* |
455 | * | 451 | * |
456 | * FUNCTION: acpi_ex_unload_table | 452 | * FUNCTION: acpi_ex_unload_table |
@@ -463,17 +459,13 @@ cleanup: | |||
463 | * | 459 | * |
464 | ******************************************************************************/ | 460 | ******************************************************************************/ |
465 | 461 | ||
466 | acpi_status | 462 | acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle) |
467 | acpi_ex_unload_table ( | ||
468 | union acpi_operand_object *ddb_handle) | ||
469 | { | 463 | { |
470 | acpi_status status = AE_OK; | 464 | acpi_status status = AE_OK; |
471 | union acpi_operand_object *table_desc = ddb_handle; | 465 | union acpi_operand_object *table_desc = ddb_handle; |
472 | struct acpi_table_desc *table_info; | 466 | struct acpi_table_desc *table_info; |
473 | |||
474 | |||
475 | ACPI_FUNCTION_TRACE ("ex_unload_table"); | ||
476 | 467 | ||
468 | ACPI_FUNCTION_TRACE("ex_unload_table"); | ||
477 | 469 | ||
478 | /* | 470 | /* |
479 | * Validate the handle | 471 | * Validate the handle |
@@ -482,29 +474,28 @@ acpi_ex_unload_table ( | |||
482 | * validated here. | 474 | * validated here. |
483 | */ | 475 | */ |
484 | if ((!ddb_handle) || | 476 | if ((!ddb_handle) || |
485 | (ACPI_GET_DESCRIPTOR_TYPE (ddb_handle) != ACPI_DESC_TYPE_OPERAND) || | 477 | (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) || |
486 | (ACPI_GET_OBJECT_TYPE (ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) { | 478 | (ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) { |
487 | return_ACPI_STATUS (AE_BAD_PARAMETER); | 479 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
488 | } | 480 | } |
489 | 481 | ||
490 | /* Get the actual table descriptor from the ddb_handle */ | 482 | /* Get the actual table descriptor from the ddb_handle */ |
491 | 483 | ||
492 | table_info = (struct acpi_table_desc *) table_desc->reference.object; | 484 | table_info = (struct acpi_table_desc *)table_desc->reference.object; |
493 | 485 | ||
494 | /* | 486 | /* |
495 | * Delete the entire namespace under this table Node | 487 | * Delete the entire namespace under this table Node |
496 | * (Offset contains the table_id) | 488 | * (Offset contains the table_id) |
497 | */ | 489 | */ |
498 | acpi_ns_delete_namespace_by_owner (table_info->owner_id); | 490 | acpi_ns_delete_namespace_by_owner(table_info->owner_id); |
499 | acpi_ut_release_owner_id (&table_info->owner_id); | 491 | acpi_ut_release_owner_id(&table_info->owner_id); |
500 | 492 | ||
501 | /* Delete the table itself */ | 493 | /* Delete the table itself */ |
502 | 494 | ||
503 | (void) acpi_tb_uninstall_table (table_info->installed_desc); | 495 | (void)acpi_tb_uninstall_table(table_info->installed_desc); |
504 | 496 | ||
505 | /* Delete the table descriptor (ddb_handle) */ | 497 | /* Delete the table descriptor (ddb_handle) */ |
506 | 498 | ||
507 | acpi_ut_remove_reference (table_desc); | 499 | acpi_ut_remove_reference(table_desc); |
508 | return_ACPI_STATUS (status); | 500 | return_ACPI_STATUS(status); |
509 | } | 501 | } |
510 | |||