diff options
Diffstat (limited to 'drivers/acpi/events/evregion.c')
-rw-r--r-- | drivers/acpi/events/evregion.c | 582 |
1 files changed, 279 insertions, 303 deletions
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c index a1d7276c5742..84fad082d80d 100644 --- a/drivers/acpi/events/evregion.c +++ b/drivers/acpi/events/evregion.c | |||
@@ -41,39 +41,30 @@ | |||
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/acevents.h> | 45 | #include <acpi/acevents.h> |
47 | #include <acpi/acnamesp.h> | 46 | #include <acpi/acnamesp.h> |
48 | #include <acpi/acinterp.h> | 47 | #include <acpi/acinterp.h> |
49 | 48 | ||
50 | #define _COMPONENT ACPI_EVENTS | 49 | #define _COMPONENT ACPI_EVENTS |
51 | ACPI_MODULE_NAME ("evregion") | 50 | ACPI_MODULE_NAME("evregion") |
52 | |||
53 | #define ACPI_NUM_DEFAULT_SPACES 4 | 51 | #define ACPI_NUM_DEFAULT_SPACES 4 |
54 | 52 | static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { | |
55 | static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { | 53 | ACPI_ADR_SPACE_SYSTEM_MEMORY, |
56 | ACPI_ADR_SPACE_SYSTEM_MEMORY, | 54 | ACPI_ADR_SPACE_SYSTEM_IO, |
57 | ACPI_ADR_SPACE_SYSTEM_IO, | 55 | ACPI_ADR_SPACE_PCI_CONFIG, |
58 | ACPI_ADR_SPACE_PCI_CONFIG, | 56 | ACPI_ADR_SPACE_DATA_TABLE |
59 | ACPI_ADR_SPACE_DATA_TABLE}; | 57 | }; |
60 | 58 | ||
61 | /* Local prototypes */ | 59 | /* Local prototypes */ |
62 | 60 | ||
63 | static acpi_status | 61 | static acpi_status |
64 | acpi_ev_reg_run ( | 62 | acpi_ev_reg_run(acpi_handle obj_handle, |
65 | acpi_handle obj_handle, | 63 | u32 level, void *context, void **return_value); |
66 | u32 level, | ||
67 | void *context, | ||
68 | void **return_value); | ||
69 | 64 | ||
70 | static acpi_status | 65 | static acpi_status |
71 | acpi_ev_install_handler ( | 66 | acpi_ev_install_handler(acpi_handle obj_handle, |
72 | acpi_handle obj_handle, | 67 | u32 level, void *context, void **return_value); |
73 | u32 level, | ||
74 | void *context, | ||
75 | void **return_value); | ||
76 | |||
77 | 68 | ||
78 | /******************************************************************************* | 69 | /******************************************************************************* |
79 | * | 70 | * |
@@ -87,19 +78,16 @@ acpi_ev_install_handler ( | |||
87 | * | 78 | * |
88 | ******************************************************************************/ | 79 | ******************************************************************************/ |
89 | 80 | ||
90 | acpi_status | 81 | acpi_status acpi_ev_install_region_handlers(void) |
91 | acpi_ev_install_region_handlers ( | 82 | { |
92 | void) { | 83 | acpi_status status; |
93 | acpi_status status; | 84 | acpi_native_uint i; |
94 | acpi_native_uint i; | ||
95 | |||
96 | |||
97 | ACPI_FUNCTION_TRACE ("ev_install_region_handlers"); | ||
98 | 85 | ||
86 | ACPI_FUNCTION_TRACE("ev_install_region_handlers"); | ||
99 | 87 | ||
100 | status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); | 88 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
101 | if (ACPI_FAILURE (status)) { | 89 | if (ACPI_FAILURE(status)) { |
102 | return_ACPI_STATUS (status); | 90 | return_ACPI_STATUS(status); |
103 | } | 91 | } |
104 | 92 | ||
105 | /* | 93 | /* |
@@ -121,9 +109,11 @@ acpi_ev_install_region_handlers ( | |||
121 | * Similar for AE_SAME_HANDLER. | 109 | * Similar for AE_SAME_HANDLER. |
122 | */ | 110 | */ |
123 | for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { | 111 | for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { |
124 | status = acpi_ev_install_space_handler (acpi_gbl_root_node, | 112 | status = acpi_ev_install_space_handler(acpi_gbl_root_node, |
125 | acpi_gbl_default_address_spaces[i], | 113 | acpi_gbl_default_address_spaces |
126 | ACPI_DEFAULT_HANDLER, NULL, NULL); | 114 | [i], |
115 | ACPI_DEFAULT_HANDLER, | ||
116 | NULL, NULL); | ||
127 | switch (status) { | 117 | switch (status) { |
128 | case AE_OK: | 118 | case AE_OK: |
129 | case AE_SAME_HANDLER: | 119 | case AE_SAME_HANDLER: |
@@ -140,12 +130,11 @@ acpi_ev_install_region_handlers ( | |||
140 | } | 130 | } |
141 | } | 131 | } |
142 | 132 | ||
143 | unlock_and_exit: | 133 | unlock_and_exit: |
144 | (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); | 134 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
145 | return_ACPI_STATUS (status); | 135 | return_ACPI_STATUS(status); |
146 | } | 136 | } |
147 | 137 | ||
148 | |||
149 | /******************************************************************************* | 138 | /******************************************************************************* |
150 | * | 139 | * |
151 | * FUNCTION: acpi_ev_initialize_op_regions | 140 | * FUNCTION: acpi_ev_initialize_op_regions |
@@ -159,20 +148,16 @@ unlock_and_exit: | |||
159 | * | 148 | * |
160 | ******************************************************************************/ | 149 | ******************************************************************************/ |
161 | 150 | ||
162 | acpi_status | 151 | acpi_status acpi_ev_initialize_op_regions(void) |
163 | acpi_ev_initialize_op_regions ( | ||
164 | void) | ||
165 | { | 152 | { |
166 | acpi_status status; | 153 | acpi_status status; |
167 | acpi_native_uint i; | 154 | acpi_native_uint i; |
168 | |||
169 | 155 | ||
170 | ACPI_FUNCTION_TRACE ("ev_initialize_op_regions"); | 156 | ACPI_FUNCTION_TRACE("ev_initialize_op_regions"); |
171 | 157 | ||
172 | 158 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | |
173 | status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); | 159 | if (ACPI_FAILURE(status)) { |
174 | if (ACPI_FAILURE (status)) { | 160 | return_ACPI_STATUS(status); |
175 | return_ACPI_STATUS (status); | ||
176 | } | 161 | } |
177 | 162 | ||
178 | /* | 163 | /* |
@@ -182,15 +167,15 @@ acpi_ev_initialize_op_regions ( | |||
182 | /* TBD: Make sure handler is the DEFAULT handler, otherwise | 167 | /* TBD: Make sure handler is the DEFAULT handler, otherwise |
183 | * _REG will have already been run. | 168 | * _REG will have already been run. |
184 | */ | 169 | */ |
185 | status = acpi_ev_execute_reg_methods (acpi_gbl_root_node, | 170 | status = acpi_ev_execute_reg_methods(acpi_gbl_root_node, |
186 | acpi_gbl_default_address_spaces[i]); | 171 | acpi_gbl_default_address_spaces |
172 | [i]); | ||
187 | } | 173 | } |
188 | 174 | ||
189 | (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); | 175 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
190 | return_ACPI_STATUS (status); | 176 | return_ACPI_STATUS(status); |
191 | } | 177 | } |
192 | 178 | ||
193 | |||
194 | /******************************************************************************* | 179 | /******************************************************************************* |
195 | * | 180 | * |
196 | * FUNCTION: acpi_ev_execute_reg_method | 181 | * FUNCTION: acpi_ev_execute_reg_method |
@@ -205,26 +190,22 @@ acpi_ev_initialize_op_regions ( | |||
205 | ******************************************************************************/ | 190 | ******************************************************************************/ |
206 | 191 | ||
207 | acpi_status | 192 | acpi_status |
208 | acpi_ev_execute_reg_method ( | 193 | acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) |
209 | union acpi_operand_object *region_obj, | ||
210 | u32 function) | ||
211 | { | 194 | { |
212 | struct acpi_parameter_info info; | 195 | struct acpi_parameter_info info; |
213 | union acpi_operand_object *params[3]; | 196 | union acpi_operand_object *params[3]; |
214 | union acpi_operand_object *region_obj2; | 197 | union acpi_operand_object *region_obj2; |
215 | acpi_status status; | 198 | acpi_status status; |
216 | |||
217 | 199 | ||
218 | ACPI_FUNCTION_TRACE ("ev_execute_reg_method"); | 200 | ACPI_FUNCTION_TRACE("ev_execute_reg_method"); |
219 | 201 | ||
220 | 202 | region_obj2 = acpi_ns_get_secondary_object(region_obj); | |
221 | region_obj2 = acpi_ns_get_secondary_object (region_obj); | ||
222 | if (!region_obj2) { | 203 | if (!region_obj2) { |
223 | return_ACPI_STATUS (AE_NOT_EXIST); | 204 | return_ACPI_STATUS(AE_NOT_EXIST); |
224 | } | 205 | } |
225 | 206 | ||
226 | if (region_obj2->extra.method_REG == NULL) { | 207 | if (region_obj2->extra.method_REG == NULL) { |
227 | return_ACPI_STATUS (AE_OK); | 208 | return_ACPI_STATUS(AE_OK); |
228 | } | 209 | } |
229 | 210 | ||
230 | /* | 211 | /* |
@@ -237,12 +218,12 @@ acpi_ev_execute_reg_method ( | |||
237 | * 0 for disconnecting the handler | 218 | * 0 for disconnecting the handler |
238 | * Passed as a parameter | 219 | * Passed as a parameter |
239 | */ | 220 | */ |
240 | params[0] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); | 221 | params[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
241 | if (!params[0]) { | 222 | if (!params[0]) { |
242 | return_ACPI_STATUS (AE_NO_MEMORY); | 223 | return_ACPI_STATUS(AE_NO_MEMORY); |
243 | } | 224 | } |
244 | 225 | ||
245 | params[1] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); | 226 | params[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
246 | if (!params[1]) { | 227 | if (!params[1]) { |
247 | status = AE_NO_MEMORY; | 228 | status = AE_NO_MEMORY; |
248 | goto cleanup; | 229 | goto cleanup; |
@@ -260,19 +241,18 @@ acpi_ev_execute_reg_method ( | |||
260 | 241 | ||
261 | /* Execute the method, no return value */ | 242 | /* Execute the method, no return value */ |
262 | 243 | ||
263 | ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname ( | 244 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname |
264 | ACPI_TYPE_METHOD, info.node, NULL)); | 245 | (ACPI_TYPE_METHOD, info.node, NULL)); |
265 | status = acpi_ns_evaluate_by_handle (&info); | 246 | status = acpi_ns_evaluate_by_handle(&info); |
266 | 247 | ||
267 | acpi_ut_remove_reference (params[1]); | 248 | acpi_ut_remove_reference(params[1]); |
268 | 249 | ||
269 | cleanup: | 250 | cleanup: |
270 | acpi_ut_remove_reference (params[0]); | 251 | acpi_ut_remove_reference(params[0]); |
271 | 252 | ||
272 | return_ACPI_STATUS (status); | 253 | return_ACPI_STATUS(status); |
273 | } | 254 | } |
274 | 255 | ||
275 | |||
276 | /******************************************************************************* | 256 | /******************************************************************************* |
277 | * | 257 | * |
278 | * FUNCTION: acpi_ev_address_space_dispatch | 258 | * FUNCTION: acpi_ev_address_space_dispatch |
@@ -291,40 +271,38 @@ cleanup: | |||
291 | ******************************************************************************/ | 271 | ******************************************************************************/ |
292 | 272 | ||
293 | acpi_status | 273 | acpi_status |
294 | acpi_ev_address_space_dispatch ( | 274 | acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, |
295 | union acpi_operand_object *region_obj, | 275 | u32 function, |
296 | u32 function, | 276 | acpi_physical_address address, |
297 | acpi_physical_address address, | 277 | u32 bit_width, void *value) |
298 | u32 bit_width, | ||
299 | void *value) | ||
300 | { | 278 | { |
301 | acpi_status status; | 279 | acpi_status status; |
302 | acpi_status status2; | 280 | acpi_status status2; |
303 | acpi_adr_space_handler handler; | 281 | acpi_adr_space_handler handler; |
304 | acpi_adr_space_setup region_setup; | 282 | acpi_adr_space_setup region_setup; |
305 | union acpi_operand_object *handler_desc; | 283 | union acpi_operand_object *handler_desc; |
306 | union acpi_operand_object *region_obj2; | 284 | union acpi_operand_object *region_obj2; |
307 | void *region_context = NULL; | 285 | void *region_context = NULL; |
308 | 286 | ||
287 | ACPI_FUNCTION_TRACE("ev_address_space_dispatch"); | ||
309 | 288 | ||
310 | ACPI_FUNCTION_TRACE ("ev_address_space_dispatch"); | 289 | region_obj2 = acpi_ns_get_secondary_object(region_obj); |
311 | |||
312 | |||
313 | region_obj2 = acpi_ns_get_secondary_object (region_obj); | ||
314 | if (!region_obj2) { | 290 | if (!region_obj2) { |
315 | return_ACPI_STATUS (AE_NOT_EXIST); | 291 | return_ACPI_STATUS(AE_NOT_EXIST); |
316 | } | 292 | } |
317 | 293 | ||
318 | /* Ensure that there is a handler associated with this region */ | 294 | /* Ensure that there is a handler associated with this region */ |
319 | 295 | ||
320 | handler_desc = region_obj->region.handler; | 296 | handler_desc = region_obj->region.handler; |
321 | if (!handler_desc) { | 297 | if (!handler_desc) { |
322 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | 298 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
323 | "No handler for Region [%4.4s] (%p) [%s]\n", | 299 | "No handler for Region [%4.4s] (%p) [%s]\n", |
324 | acpi_ut_get_node_name (region_obj->region.node), | 300 | acpi_ut_get_node_name(region_obj->region. |
325 | region_obj, acpi_ut_get_region_name (region_obj->region.space_id))); | 301 | node), region_obj, |
326 | 302 | acpi_ut_get_region_name(region_obj->region. | |
327 | return_ACPI_STATUS (AE_NOT_EXIST); | 303 | space_id))); |
304 | |||
305 | return_ACPI_STATUS(AE_NOT_EXIST); | ||
328 | } | 306 | } |
329 | 307 | ||
330 | /* | 308 | /* |
@@ -339,10 +317,13 @@ acpi_ev_address_space_dispatch ( | |||
339 | if (!region_setup) { | 317 | if (!region_setup) { |
340 | /* No initialization routine, exit with error */ | 318 | /* No initialization routine, exit with error */ |
341 | 319 | ||
342 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | 320 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
343 | "No init routine for region(%p) [%s]\n", | 321 | "No init routine for region(%p) [%s]\n", |
344 | region_obj, acpi_ut_get_region_name (region_obj->region.space_id))); | 322 | region_obj, |
345 | return_ACPI_STATUS (AE_NOT_EXIST); | 323 | acpi_ut_get_region_name(region_obj-> |
324 | region. | ||
325 | space_id))); | ||
326 | return_ACPI_STATUS(AE_NOT_EXIST); | ||
346 | } | 327 | } |
347 | 328 | ||
348 | /* | 329 | /* |
@@ -350,25 +331,29 @@ acpi_ev_address_space_dispatch ( | |||
350 | * setup will potentially execute control methods | 331 | * setup will potentially execute control methods |
351 | * (e.g., _REG method for this region) | 332 | * (e.g., _REG method for this region) |
352 | */ | 333 | */ |
353 | acpi_ex_exit_interpreter (); | 334 | acpi_ex_exit_interpreter(); |
354 | 335 | ||
355 | status = region_setup (region_obj, ACPI_REGION_ACTIVATE, | 336 | status = region_setup(region_obj, ACPI_REGION_ACTIVATE, |
356 | handler_desc->address_space.context, ®ion_context); | 337 | handler_desc->address_space.context, |
338 | ®ion_context); | ||
357 | 339 | ||
358 | /* Re-enter the interpreter */ | 340 | /* Re-enter the interpreter */ |
359 | 341 | ||
360 | status2 = acpi_ex_enter_interpreter (); | 342 | status2 = acpi_ex_enter_interpreter(); |
361 | if (ACPI_FAILURE (status2)) { | 343 | if (ACPI_FAILURE(status2)) { |
362 | return_ACPI_STATUS (status2); | 344 | return_ACPI_STATUS(status2); |
363 | } | 345 | } |
364 | 346 | ||
365 | /* Check for failure of the Region Setup */ | 347 | /* Check for failure of the Region Setup */ |
366 | 348 | ||
367 | if (ACPI_FAILURE (status)) { | 349 | if (ACPI_FAILURE(status)) { |
368 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region Init: %s [%s]\n", | 350 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
369 | acpi_format_exception (status), | 351 | "Region Init: %s [%s]\n", |
370 | acpi_ut_get_region_name (region_obj->region.space_id))); | 352 | acpi_format_exception(status), |
371 | return_ACPI_STATUS (status); | 353 | acpi_ut_get_region_name(region_obj-> |
354 | region. | ||
355 | space_id))); | ||
356 | return_ACPI_STATUS(status); | ||
372 | } | 357 | } |
373 | 358 | ||
374 | /* | 359 | /* |
@@ -380,14 +365,14 @@ acpi_ev_address_space_dispatch ( | |||
380 | if (region_obj2->extra.region_context) { | 365 | if (region_obj2->extra.region_context) { |
381 | /* The handler for this region was already installed */ | 366 | /* The handler for this region was already installed */ |
382 | 367 | ||
383 | ACPI_MEM_FREE (region_context); | 368 | ACPI_MEM_FREE(region_context); |
384 | } | 369 | } else { |
385 | else { | ||
386 | /* | 370 | /* |
387 | * Save the returned context for use in all accesses to | 371 | * Save the returned context for use in all accesses to |
388 | * this particular region | 372 | * this particular region |
389 | */ | 373 | */ |
390 | region_obj2->extra.region_context = region_context; | 374 | region_obj2->extra.region_context = |
375 | region_context; | ||
391 | } | 376 | } |
392 | } | 377 | } |
393 | } | 378 | } |
@@ -396,13 +381,16 @@ acpi_ev_address_space_dispatch ( | |||
396 | 381 | ||
397 | handler = handler_desc->address_space.handler; | 382 | handler = handler_desc->address_space.handler; |
398 | 383 | ||
399 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, | 384 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
400 | "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", | 385 | "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", |
401 | ®ion_obj->region.handler->address_space, handler, | 386 | ®ion_obj->region.handler->address_space, handler, |
402 | ACPI_FORMAT_UINT64 (address), | 387 | ACPI_FORMAT_UINT64(address), |
403 | acpi_ut_get_region_name (region_obj->region.space_id))); | 388 | acpi_ut_get_region_name(region_obj->region. |
389 | space_id))); | ||
404 | 390 | ||
405 | if (!(handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { | 391 | if (! |
392 | (handler_desc->address_space. | ||
393 | hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { | ||
406 | /* | 394 | /* |
407 | * For handlers other than the default (supplied) handlers, we must | 395 | * For handlers other than the default (supplied) handlers, we must |
408 | * exit the interpreter because the handler *might* block -- we don't | 396 | * exit the interpreter because the handler *might* block -- we don't |
@@ -413,31 +401,33 @@ acpi_ev_address_space_dispatch ( | |||
413 | 401 | ||
414 | /* Call the handler */ | 402 | /* Call the handler */ |
415 | 403 | ||
416 | status = handler (function, address, bit_width, value, | 404 | status = handler(function, address, bit_width, value, |
417 | handler_desc->address_space.context, | 405 | handler_desc->address_space.context, |
418 | region_obj2->extra.region_context); | 406 | region_obj2->extra.region_context); |
419 | 407 | ||
420 | if (ACPI_FAILURE (status)) { | 408 | if (ACPI_FAILURE(status)) { |
421 | ACPI_REPORT_ERROR (("Handler for [%s] returned %s\n", | 409 | ACPI_REPORT_ERROR(("Handler for [%s] returned %s\n", |
422 | acpi_ut_get_region_name (region_obj->region.space_id), | 410 | acpi_ut_get_region_name(region_obj->region. |
423 | acpi_format_exception (status))); | 411 | space_id), |
412 | acpi_format_exception(status))); | ||
424 | } | 413 | } |
425 | 414 | ||
426 | if (!(handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { | 415 | if (! |
416 | (handler_desc->address_space. | ||
417 | hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { | ||
427 | /* | 418 | /* |
428 | * We just returned from a non-default handler, we must re-enter the | 419 | * We just returned from a non-default handler, we must re-enter the |
429 | * interpreter | 420 | * interpreter |
430 | */ | 421 | */ |
431 | status2 = acpi_ex_enter_interpreter (); | 422 | status2 = acpi_ex_enter_interpreter(); |
432 | if (ACPI_FAILURE (status2)) { | 423 | if (ACPI_FAILURE(status2)) { |
433 | return_ACPI_STATUS (status2); | 424 | return_ACPI_STATUS(status2); |
434 | } | 425 | } |
435 | } | 426 | } |
436 | 427 | ||
437 | return_ACPI_STATUS (status); | 428 | return_ACPI_STATUS(status); |
438 | } | 429 | } |
439 | 430 | ||
440 | |||
441 | /******************************************************************************* | 431 | /******************************************************************************* |
442 | * | 432 | * |
443 | * FUNCTION: acpi_ev_detach_region | 433 | * FUNCTION: acpi_ev_detach_region |
@@ -453,23 +443,20 @@ acpi_ev_address_space_dispatch ( | |||
453 | ******************************************************************************/ | 443 | ******************************************************************************/ |
454 | 444 | ||
455 | void | 445 | void |
456 | acpi_ev_detach_region( | 446 | acpi_ev_detach_region(union acpi_operand_object *region_obj, |
457 | union acpi_operand_object *region_obj, | 447 | u8 acpi_ns_is_locked) |
458 | u8 acpi_ns_is_locked) | ||
459 | { | 448 | { |
460 | union acpi_operand_object *handler_obj; | 449 | union acpi_operand_object *handler_obj; |
461 | union acpi_operand_object *obj_desc; | 450 | union acpi_operand_object *obj_desc; |
462 | union acpi_operand_object **last_obj_ptr; | 451 | union acpi_operand_object **last_obj_ptr; |
463 | acpi_adr_space_setup region_setup; | 452 | acpi_adr_space_setup region_setup; |
464 | void **region_context; | 453 | void **region_context; |
465 | union acpi_operand_object *region_obj2; | 454 | union acpi_operand_object *region_obj2; |
466 | acpi_status status; | 455 | acpi_status status; |
467 | |||
468 | |||
469 | ACPI_FUNCTION_TRACE ("ev_detach_region"); | ||
470 | 456 | ||
457 | ACPI_FUNCTION_TRACE("ev_detach_region"); | ||
471 | 458 | ||
472 | region_obj2 = acpi_ns_get_secondary_object (region_obj); | 459 | region_obj2 = acpi_ns_get_secondary_object(region_obj); |
473 | if (!region_obj2) { | 460 | if (!region_obj2) { |
474 | return_VOID; | 461 | return_VOID; |
475 | } | 462 | } |
@@ -493,34 +480,39 @@ acpi_ev_detach_region( | |||
493 | /* Is this the correct Region? */ | 480 | /* Is this the correct Region? */ |
494 | 481 | ||
495 | if (obj_desc == region_obj) { | 482 | if (obj_desc == region_obj) { |
496 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, | 483 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
497 | "Removing Region %p from address handler %p\n", | 484 | "Removing Region %p from address handler %p\n", |
498 | region_obj, handler_obj)); | 485 | region_obj, handler_obj)); |
499 | 486 | ||
500 | /* This is it, remove it from the handler's list */ | 487 | /* This is it, remove it from the handler's list */ |
501 | 488 | ||
502 | *last_obj_ptr = obj_desc->region.next; | 489 | *last_obj_ptr = obj_desc->region.next; |
503 | obj_desc->region.next = NULL; /* Must clear field */ | 490 | obj_desc->region.next = NULL; /* Must clear field */ |
504 | 491 | ||
505 | if (acpi_ns_is_locked) { | 492 | if (acpi_ns_is_locked) { |
506 | status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); | 493 | status = |
507 | if (ACPI_FAILURE (status)) { | 494 | acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
495 | if (ACPI_FAILURE(status)) { | ||
508 | return_VOID; | 496 | return_VOID; |
509 | } | 497 | } |
510 | } | 498 | } |
511 | 499 | ||
512 | /* Now stop region accesses by executing the _REG method */ | 500 | /* Now stop region accesses by executing the _REG method */ |
513 | 501 | ||
514 | status = acpi_ev_execute_reg_method (region_obj, 0); | 502 | status = acpi_ev_execute_reg_method(region_obj, 0); |
515 | if (ACPI_FAILURE (status)) { | 503 | if (ACPI_FAILURE(status)) { |
516 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region _REG, [%s]\n", | 504 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
517 | acpi_format_exception (status), | 505 | "%s from region _REG, [%s]\n", |
518 | acpi_ut_get_region_name (region_obj->region.space_id))); | 506 | acpi_format_exception(status), |
507 | acpi_ut_get_region_name | ||
508 | (region_obj->region. | ||
509 | space_id))); | ||
519 | } | 510 | } |
520 | 511 | ||
521 | if (acpi_ns_is_locked) { | 512 | if (acpi_ns_is_locked) { |
522 | status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); | 513 | status = |
523 | if (ACPI_FAILURE (status)) { | 514 | acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
515 | if (ACPI_FAILURE(status)) { | ||
524 | return_VOID; | 516 | return_VOID; |
525 | } | 517 | } |
526 | } | 518 | } |
@@ -528,15 +520,20 @@ acpi_ev_detach_region( | |||
528 | /* Call the setup handler with the deactivate notification */ | 520 | /* Call the setup handler with the deactivate notification */ |
529 | 521 | ||
530 | region_setup = handler_obj->address_space.setup; | 522 | region_setup = handler_obj->address_space.setup; |
531 | status = region_setup (region_obj, ACPI_REGION_DEACTIVATE, | 523 | status = |
532 | handler_obj->address_space.context, region_context); | 524 | region_setup(region_obj, ACPI_REGION_DEACTIVATE, |
525 | handler_obj->address_space.context, | ||
526 | region_context); | ||
533 | 527 | ||
534 | /* Init routine may fail, Just ignore errors */ | 528 | /* Init routine may fail, Just ignore errors */ |
535 | 529 | ||
536 | if (ACPI_FAILURE (status)) { | 530 | if (ACPI_FAILURE(status)) { |
537 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region init, [%s]\n", | 531 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
538 | acpi_format_exception (status), | 532 | "%s from region init, [%s]\n", |
539 | acpi_ut_get_region_name (region_obj->region.space_id))); | 533 | acpi_format_exception(status), |
534 | acpi_ut_get_region_name | ||
535 | (region_obj->region. | ||
536 | space_id))); | ||
540 | } | 537 | } |
541 | 538 | ||
542 | region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); | 539 | region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); |
@@ -552,7 +549,7 @@ acpi_ev_detach_region( | |||
552 | * this better be the region's handler | 549 | * this better be the region's handler |
553 | */ | 550 | */ |
554 | region_obj->region.handler = NULL; | 551 | region_obj->region.handler = NULL; |
555 | acpi_ut_remove_reference (handler_obj); | 552 | acpi_ut_remove_reference(handler_obj); |
556 | 553 | ||
557 | return_VOID; | 554 | return_VOID; |
558 | } | 555 | } |
@@ -565,14 +562,13 @@ acpi_ev_detach_region( | |||
565 | 562 | ||
566 | /* If we get here, the region was not in the handler's region list */ | 563 | /* If we get here, the region was not in the handler's region list */ |
567 | 564 | ||
568 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, | 565 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
569 | "Cannot remove region %p from address handler %p\n", | 566 | "Cannot remove region %p from address handler %p\n", |
570 | region_obj, handler_obj)); | 567 | region_obj, handler_obj)); |
571 | 568 | ||
572 | return_VOID; | 569 | return_VOID; |
573 | } | 570 | } |
574 | 571 | ||
575 | |||
576 | /******************************************************************************* | 572 | /******************************************************************************* |
577 | * | 573 | * |
578 | * FUNCTION: acpi_ev_attach_region | 574 | * FUNCTION: acpi_ev_attach_region |
@@ -589,20 +585,19 @@ acpi_ev_detach_region( | |||
589 | ******************************************************************************/ | 585 | ******************************************************************************/ |
590 | 586 | ||
591 | acpi_status | 587 | acpi_status |
592 | acpi_ev_attach_region ( | 588 | acpi_ev_attach_region(union acpi_operand_object *handler_obj, |
593 | union acpi_operand_object *handler_obj, | 589 | union acpi_operand_object *region_obj, |
594 | union acpi_operand_object *region_obj, | 590 | u8 acpi_ns_is_locked) |
595 | u8 acpi_ns_is_locked) | ||
596 | { | 591 | { |
597 | 592 | ||
598 | ACPI_FUNCTION_TRACE ("ev_attach_region"); | 593 | ACPI_FUNCTION_TRACE("ev_attach_region"); |
599 | |||
600 | 594 | ||
601 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, | 595 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
602 | "Adding Region [%4.4s] %p to address handler %p [%s]\n", | 596 | "Adding Region [%4.4s] %p to address handler %p [%s]\n", |
603 | acpi_ut_get_node_name (region_obj->region.node), | 597 | acpi_ut_get_node_name(region_obj->region.node), |
604 | region_obj, handler_obj, | 598 | region_obj, handler_obj, |
605 | acpi_ut_get_region_name (region_obj->region.space_id))); | 599 | acpi_ut_get_region_name(region_obj->region. |
600 | space_id))); | ||
606 | 601 | ||
607 | /* Link this region to the front of the handler's list */ | 602 | /* Link this region to the front of the handler's list */ |
608 | 603 | ||
@@ -612,16 +607,15 @@ acpi_ev_attach_region ( | |||
612 | /* Install the region's handler */ | 607 | /* Install the region's handler */ |
613 | 608 | ||
614 | if (region_obj->region.handler) { | 609 | if (region_obj->region.handler) { |
615 | return_ACPI_STATUS (AE_ALREADY_EXISTS); | 610 | return_ACPI_STATUS(AE_ALREADY_EXISTS); |
616 | } | 611 | } |
617 | 612 | ||
618 | region_obj->region.handler = handler_obj; | 613 | region_obj->region.handler = handler_obj; |
619 | acpi_ut_add_reference (handler_obj); | 614 | acpi_ut_add_reference(handler_obj); |
620 | 615 | ||
621 | return_ACPI_STATUS (AE_OK); | 616 | return_ACPI_STATUS(AE_OK); |
622 | } | 617 | } |
623 | 618 | ||
624 | |||
625 | /******************************************************************************* | 619 | /******************************************************************************* |
626 | * | 620 | * |
627 | * FUNCTION: acpi_ev_install_handler | 621 | * FUNCTION: acpi_ev_install_handler |
@@ -640,23 +634,18 @@ acpi_ev_attach_region ( | |||
640 | ******************************************************************************/ | 634 | ******************************************************************************/ |
641 | 635 | ||
642 | static acpi_status | 636 | static acpi_status |
643 | acpi_ev_install_handler ( | 637 | acpi_ev_install_handler(acpi_handle obj_handle, |
644 | acpi_handle obj_handle, | 638 | u32 level, void *context, void **return_value) |
645 | u32 level, | ||
646 | void *context, | ||
647 | void **return_value) | ||
648 | { | 639 | { |
649 | union acpi_operand_object *handler_obj; | 640 | union acpi_operand_object *handler_obj; |
650 | union acpi_operand_object *next_handler_obj; | 641 | union acpi_operand_object *next_handler_obj; |
651 | union acpi_operand_object *obj_desc; | 642 | union acpi_operand_object *obj_desc; |
652 | struct acpi_namespace_node *node; | 643 | struct acpi_namespace_node *node; |
653 | acpi_status status; | 644 | acpi_status status; |
654 | 645 | ||
646 | ACPI_FUNCTION_NAME("ev_install_handler"); | ||
655 | 647 | ||
656 | ACPI_FUNCTION_NAME ("ev_install_handler"); | 648 | handler_obj = (union acpi_operand_object *)context; |
657 | |||
658 | |||
659 | handler_obj = (union acpi_operand_object *) context; | ||
660 | 649 | ||
661 | /* Parameter validation */ | 650 | /* Parameter validation */ |
662 | 651 | ||
@@ -666,7 +655,7 @@ acpi_ev_install_handler ( | |||
666 | 655 | ||
667 | /* Convert and validate the device handle */ | 656 | /* Convert and validate the device handle */ |
668 | 657 | ||
669 | node = acpi_ns_map_handle_to_node (obj_handle); | 658 | node = acpi_ns_map_handle_to_node(obj_handle); |
670 | if (!node) { | 659 | if (!node) { |
671 | return (AE_BAD_PARAMETER); | 660 | return (AE_BAD_PARAMETER); |
672 | } | 661 | } |
@@ -676,14 +665,13 @@ acpi_ev_install_handler ( | |||
676 | * that are allowed to have address space handlers | 665 | * that are allowed to have address space handlers |
677 | */ | 666 | */ |
678 | if ((node->type != ACPI_TYPE_DEVICE) && | 667 | if ((node->type != ACPI_TYPE_DEVICE) && |
679 | (node->type != ACPI_TYPE_REGION) && | 668 | (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { |
680 | (node != acpi_gbl_root_node)) { | ||
681 | return (AE_OK); | 669 | return (AE_OK); |
682 | } | 670 | } |
683 | 671 | ||
684 | /* Check for an existing internal object */ | 672 | /* Check for an existing internal object */ |
685 | 673 | ||
686 | obj_desc = acpi_ns_get_attached_object (node); | 674 | obj_desc = acpi_ns_get_attached_object(node); |
687 | if (!obj_desc) { | 675 | if (!obj_desc) { |
688 | /* No object, just exit */ | 676 | /* No object, just exit */ |
689 | 677 | ||
@@ -692,18 +680,22 @@ acpi_ev_install_handler ( | |||
692 | 680 | ||
693 | /* Devices are handled different than regions */ | 681 | /* Devices are handled different than regions */ |
694 | 682 | ||
695 | if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_DEVICE) { | 683 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_DEVICE) { |
696 | /* Check if this Device already has a handler for this address space */ | 684 | /* Check if this Device already has a handler for this address space */ |
697 | 685 | ||
698 | next_handler_obj = obj_desc->device.handler; | 686 | next_handler_obj = obj_desc->device.handler; |
699 | while (next_handler_obj) { | 687 | while (next_handler_obj) { |
700 | /* Found a handler, is it for the same address space? */ | 688 | /* Found a handler, is it for the same address space? */ |
701 | 689 | ||
702 | if (next_handler_obj->address_space.space_id == handler_obj->address_space.space_id) { | 690 | if (next_handler_obj->address_space.space_id == |
703 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, | 691 | handler_obj->address_space.space_id) { |
704 | "Found handler for region [%s] in device %p(%p) handler %p\n", | 692 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
705 | acpi_ut_get_region_name (handler_obj->address_space.space_id), | 693 | "Found handler for region [%s] in device %p(%p) handler %p\n", |
706 | obj_desc, next_handler_obj, handler_obj)); | 694 | acpi_ut_get_region_name |
695 | (handler_obj->address_space. | ||
696 | space_id), obj_desc, | ||
697 | next_handler_obj, | ||
698 | handler_obj)); | ||
707 | 699 | ||
708 | /* | 700 | /* |
709 | * Since the object we found it on was a device, then it | 701 | * Since the object we found it on was a device, then it |
@@ -744,15 +736,14 @@ acpi_ev_install_handler ( | |||
744 | * | 736 | * |
745 | * First disconnect region for any previous handler (if any) | 737 | * First disconnect region for any previous handler (if any) |
746 | */ | 738 | */ |
747 | acpi_ev_detach_region (obj_desc, FALSE); | 739 | acpi_ev_detach_region(obj_desc, FALSE); |
748 | 740 | ||
749 | /* Connect the region to the new handler */ | 741 | /* Connect the region to the new handler */ |
750 | 742 | ||
751 | status = acpi_ev_attach_region (handler_obj, obj_desc, FALSE); | 743 | status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE); |
752 | return (status); | 744 | return (status); |
753 | } | 745 | } |
754 | 746 | ||
755 | |||
756 | /******************************************************************************* | 747 | /******************************************************************************* |
757 | * | 748 | * |
758 | * FUNCTION: acpi_ev_install_space_handler | 749 | * FUNCTION: acpi_ev_install_space_handler |
@@ -771,32 +762,27 @@ acpi_ev_install_handler ( | |||
771 | ******************************************************************************/ | 762 | ******************************************************************************/ |
772 | 763 | ||
773 | acpi_status | 764 | acpi_status |
774 | acpi_ev_install_space_handler ( | 765 | acpi_ev_install_space_handler(struct acpi_namespace_node * node, |
775 | struct acpi_namespace_node *node, | 766 | acpi_adr_space_type space_id, |
776 | acpi_adr_space_type space_id, | 767 | acpi_adr_space_handler handler, |
777 | acpi_adr_space_handler handler, | 768 | acpi_adr_space_setup setup, void *context) |
778 | acpi_adr_space_setup setup, | ||
779 | void *context) | ||
780 | { | 769 | { |
781 | union acpi_operand_object *obj_desc; | 770 | union acpi_operand_object *obj_desc; |
782 | union acpi_operand_object *handler_obj; | 771 | union acpi_operand_object *handler_obj; |
783 | acpi_status status; | 772 | acpi_status status; |
784 | acpi_object_type type; | 773 | acpi_object_type type; |
785 | u16 flags = 0; | 774 | u16 flags = 0; |
786 | |||
787 | |||
788 | ACPI_FUNCTION_TRACE ("ev_install_space_handler"); | ||
789 | 775 | ||
776 | ACPI_FUNCTION_TRACE("ev_install_space_handler"); | ||
790 | 777 | ||
791 | /* | 778 | /* |
792 | * This registration is valid for only the types below | 779 | * This registration is valid for only the types below |
793 | * and the root. This is where the default handlers | 780 | * and the root. This is where the default handlers |
794 | * get placed. | 781 | * get placed. |
795 | */ | 782 | */ |
796 | if ((node->type != ACPI_TYPE_DEVICE) && | 783 | if ((node->type != ACPI_TYPE_DEVICE) && |
797 | (node->type != ACPI_TYPE_PROCESSOR) && | 784 | (node->type != ACPI_TYPE_PROCESSOR) && |
798 | (node->type != ACPI_TYPE_THERMAL) && | 785 | (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) { |
799 | (node != acpi_gbl_root_node)) { | ||
800 | status = AE_BAD_PARAMETER; | 786 | status = AE_BAD_PARAMETER; |
801 | goto unlock_and_exit; | 787 | goto unlock_and_exit; |
802 | } | 788 | } |
@@ -807,32 +793,32 @@ acpi_ev_install_space_handler ( | |||
807 | switch (space_id) { | 793 | switch (space_id) { |
808 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | 794 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
809 | handler = acpi_ex_system_memory_space_handler; | 795 | handler = acpi_ex_system_memory_space_handler; |
810 | setup = acpi_ev_system_memory_region_setup; | 796 | setup = acpi_ev_system_memory_region_setup; |
811 | break; | 797 | break; |
812 | 798 | ||
813 | case ACPI_ADR_SPACE_SYSTEM_IO: | 799 | case ACPI_ADR_SPACE_SYSTEM_IO: |
814 | handler = acpi_ex_system_io_space_handler; | 800 | handler = acpi_ex_system_io_space_handler; |
815 | setup = acpi_ev_io_space_region_setup; | 801 | setup = acpi_ev_io_space_region_setup; |
816 | break; | 802 | break; |
817 | 803 | ||
818 | case ACPI_ADR_SPACE_PCI_CONFIG: | 804 | case ACPI_ADR_SPACE_PCI_CONFIG: |
819 | handler = acpi_ex_pci_config_space_handler; | 805 | handler = acpi_ex_pci_config_space_handler; |
820 | setup = acpi_ev_pci_config_region_setup; | 806 | setup = acpi_ev_pci_config_region_setup; |
821 | break; | 807 | break; |
822 | 808 | ||
823 | case ACPI_ADR_SPACE_CMOS: | 809 | case ACPI_ADR_SPACE_CMOS: |
824 | handler = acpi_ex_cmos_space_handler; | 810 | handler = acpi_ex_cmos_space_handler; |
825 | setup = acpi_ev_cmos_region_setup; | 811 | setup = acpi_ev_cmos_region_setup; |
826 | break; | 812 | break; |
827 | 813 | ||
828 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: | 814 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: |
829 | handler = acpi_ex_pci_bar_space_handler; | 815 | handler = acpi_ex_pci_bar_space_handler; |
830 | setup = acpi_ev_pci_bar_region_setup; | 816 | setup = acpi_ev_pci_bar_region_setup; |
831 | break; | 817 | break; |
832 | 818 | ||
833 | case ACPI_ADR_SPACE_DATA_TABLE: | 819 | case ACPI_ADR_SPACE_DATA_TABLE: |
834 | handler = acpi_ex_data_table_space_handler; | 820 | handler = acpi_ex_data_table_space_handler; |
835 | setup = NULL; | 821 | setup = NULL; |
836 | break; | 822 | break; |
837 | 823 | ||
838 | default: | 824 | default: |
@@ -849,7 +835,7 @@ acpi_ev_install_space_handler ( | |||
849 | 835 | ||
850 | /* Check for an existing internal object */ | 836 | /* Check for an existing internal object */ |
851 | 837 | ||
852 | obj_desc = acpi_ns_get_attached_object (node); | 838 | obj_desc = acpi_ns_get_attached_object(node); |
853 | if (obj_desc) { | 839 | if (obj_desc) { |
854 | /* | 840 | /* |
855 | * The attached device object already exists. | 841 | * The attached device object already exists. |
@@ -863,7 +849,8 @@ acpi_ev_install_space_handler ( | |||
863 | /* Same space_id indicates a handler already installed */ | 849 | /* Same space_id indicates a handler already installed */ |
864 | 850 | ||
865 | if (handler_obj->address_space.space_id == space_id) { | 851 | if (handler_obj->address_space.space_id == space_id) { |
866 | if (handler_obj->address_space.handler == handler) { | 852 | if (handler_obj->address_space.handler == |
853 | handler) { | ||
867 | /* | 854 | /* |
868 | * It is (relatively) OK to attempt to install the SAME | 855 | * It is (relatively) OK to attempt to install the SAME |
869 | * handler twice. This can easily happen | 856 | * handler twice. This can easily happen |
@@ -871,8 +858,7 @@ acpi_ev_install_space_handler ( | |||
871 | */ | 858 | */ |
872 | status = AE_SAME_HANDLER; | 859 | status = AE_SAME_HANDLER; |
873 | goto unlock_and_exit; | 860 | goto unlock_and_exit; |
874 | } | 861 | } else { |
875 | else { | ||
876 | /* A handler is already installed */ | 862 | /* A handler is already installed */ |
877 | 863 | ||
878 | status = AE_ALREADY_EXISTS; | 864 | status = AE_ALREADY_EXISTS; |
@@ -884,21 +870,20 @@ acpi_ev_install_space_handler ( | |||
884 | 870 | ||
885 | handler_obj = handler_obj->address_space.next; | 871 | handler_obj = handler_obj->address_space.next; |
886 | } | 872 | } |
887 | } | 873 | } else { |
888 | else { | 874 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
889 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, | 875 | "Creating object on Device %p while installing handler\n", |
890 | "Creating object on Device %p while installing handler\n", node)); | 876 | node)); |
891 | 877 | ||
892 | /* obj_desc does not exist, create one */ | 878 | /* obj_desc does not exist, create one */ |
893 | 879 | ||
894 | if (node->type == ACPI_TYPE_ANY) { | 880 | if (node->type == ACPI_TYPE_ANY) { |
895 | type = ACPI_TYPE_DEVICE; | 881 | type = ACPI_TYPE_DEVICE; |
896 | } | 882 | } else { |
897 | else { | ||
898 | type = node->type; | 883 | type = node->type; |
899 | } | 884 | } |
900 | 885 | ||
901 | obj_desc = acpi_ut_create_internal_object (type); | 886 | obj_desc = acpi_ut_create_internal_object(type); |
902 | if (!obj_desc) { | 887 | if (!obj_desc) { |
903 | status = AE_NO_MEMORY; | 888 | status = AE_NO_MEMORY; |
904 | goto unlock_and_exit; | 889 | goto unlock_and_exit; |
@@ -910,21 +895,21 @@ acpi_ev_install_space_handler ( | |||
910 | 895 | ||
911 | /* Attach the new object to the Node */ | 896 | /* Attach the new object to the Node */ |
912 | 897 | ||
913 | status = acpi_ns_attach_object (node, obj_desc, type); | 898 | status = acpi_ns_attach_object(node, obj_desc, type); |
914 | 899 | ||
915 | /* Remove local reference to the object */ | 900 | /* Remove local reference to the object */ |
916 | 901 | ||
917 | acpi_ut_remove_reference (obj_desc); | 902 | acpi_ut_remove_reference(obj_desc); |
918 | 903 | ||
919 | if (ACPI_FAILURE (status)) { | 904 | if (ACPI_FAILURE(status)) { |
920 | goto unlock_and_exit; | 905 | goto unlock_and_exit; |
921 | } | 906 | } |
922 | } | 907 | } |
923 | 908 | ||
924 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, | 909 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
925 | "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", | 910 | "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", |
926 | acpi_ut_get_region_name (space_id), space_id, | 911 | acpi_ut_get_region_name(space_id), space_id, |
927 | acpi_ut_get_node_name (node), node, obj_desc)); | 912 | acpi_ut_get_node_name(node), node, obj_desc)); |
928 | 913 | ||
929 | /* | 914 | /* |
930 | * Install the handler | 915 | * Install the handler |
@@ -933,7 +918,8 @@ acpi_ev_install_space_handler ( | |||
933 | * Just allocate the object for the handler and link it | 918 | * Just allocate the object for the handler and link it |
934 | * into the list. | 919 | * into the list. |
935 | */ | 920 | */ |
936 | handler_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); | 921 | handler_obj = |
922 | acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); | ||
937 | if (!handler_obj) { | 923 | if (!handler_obj) { |
938 | status = AE_NO_MEMORY; | 924 | status = AE_NO_MEMORY; |
939 | goto unlock_and_exit; | 925 | goto unlock_and_exit; |
@@ -941,17 +927,17 @@ acpi_ev_install_space_handler ( | |||
941 | 927 | ||
942 | /* Init handler obj */ | 928 | /* Init handler obj */ |
943 | 929 | ||
944 | handler_obj->address_space.space_id = (u8) space_id; | 930 | handler_obj->address_space.space_id = (u8) space_id; |
945 | handler_obj->address_space.hflags = flags; | 931 | handler_obj->address_space.hflags = flags; |
946 | handler_obj->address_space.region_list = NULL; | 932 | handler_obj->address_space.region_list = NULL; |
947 | handler_obj->address_space.node = node; | 933 | handler_obj->address_space.node = node; |
948 | handler_obj->address_space.handler = handler; | 934 | handler_obj->address_space.handler = handler; |
949 | handler_obj->address_space.context = context; | 935 | handler_obj->address_space.context = context; |
950 | handler_obj->address_space.setup = setup; | 936 | handler_obj->address_space.setup = setup; |
951 | 937 | ||
952 | /* Install at head of Device.address_space list */ | 938 | /* Install at head of Device.address_space list */ |
953 | 939 | ||
954 | handler_obj->address_space.next = obj_desc->device.handler; | 940 | handler_obj->address_space.next = obj_desc->device.handler; |
955 | 941 | ||
956 | /* | 942 | /* |
957 | * The Device object is the first reference on the handler_obj. | 943 | * The Device object is the first reference on the handler_obj. |
@@ -971,15 +957,15 @@ acpi_ev_install_space_handler ( | |||
971 | * In either case, back up and search down the remainder | 957 | * In either case, back up and search down the remainder |
972 | * of the branch | 958 | * of the branch |
973 | */ | 959 | */ |
974 | status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, | 960 | status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, |
975 | ACPI_NS_WALK_UNLOCK, acpi_ev_install_handler, | 961 | ACPI_NS_WALK_UNLOCK, |
976 | handler_obj, NULL); | 962 | acpi_ev_install_handler, handler_obj, |
963 | NULL); | ||
977 | 964 | ||
978 | unlock_and_exit: | 965 | unlock_and_exit: |
979 | return_ACPI_STATUS (status); | 966 | return_ACPI_STATUS(status); |
980 | } | 967 | } |
981 | 968 | ||
982 | |||
983 | /******************************************************************************* | 969 | /******************************************************************************* |
984 | * | 970 | * |
985 | * FUNCTION: acpi_ev_execute_reg_methods | 971 | * FUNCTION: acpi_ev_execute_reg_methods |
@@ -995,15 +981,12 @@ unlock_and_exit: | |||
995 | ******************************************************************************/ | 981 | ******************************************************************************/ |
996 | 982 | ||
997 | acpi_status | 983 | acpi_status |
998 | acpi_ev_execute_reg_methods ( | 984 | acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, |
999 | struct acpi_namespace_node *node, | 985 | acpi_adr_space_type space_id) |
1000 | acpi_adr_space_type space_id) | ||
1001 | { | 986 | { |
1002 | acpi_status status; | 987 | acpi_status status; |
1003 | |||
1004 | |||
1005 | ACPI_FUNCTION_TRACE ("ev_execute_reg_methods"); | ||
1006 | 988 | ||
989 | ACPI_FUNCTION_TRACE("ev_execute_reg_methods"); | ||
1007 | 990 | ||
1008 | /* | 991 | /* |
1009 | * Run all _REG methods for all Operation Regions for this | 992 | * Run all _REG methods for all Operation Regions for this |
@@ -1012,14 +995,13 @@ acpi_ev_execute_reg_methods ( | |||
1012 | * must be installed for all regions of this Space ID before we | 995 | * must be installed for all regions of this Space ID before we |
1013 | * can run any _REG methods) | 996 | * can run any _REG methods) |
1014 | */ | 997 | */ |
1015 | status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, | 998 | status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, |
1016 | ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, | 999 | ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, |
1017 | &space_id, NULL); | 1000 | &space_id, NULL); |
1018 | 1001 | ||
1019 | return_ACPI_STATUS (status); | 1002 | return_ACPI_STATUS(status); |
1020 | } | 1003 | } |
1021 | 1004 | ||
1022 | |||
1023 | /******************************************************************************* | 1005 | /******************************************************************************* |
1024 | * | 1006 | * |
1025 | * FUNCTION: acpi_ev_reg_run | 1007 | * FUNCTION: acpi_ev_reg_run |
@@ -1031,23 +1013,19 @@ acpi_ev_execute_reg_methods ( | |||
1031 | ******************************************************************************/ | 1013 | ******************************************************************************/ |
1032 | 1014 | ||
1033 | static acpi_status | 1015 | static acpi_status |
1034 | acpi_ev_reg_run ( | 1016 | acpi_ev_reg_run(acpi_handle obj_handle, |
1035 | acpi_handle obj_handle, | 1017 | u32 level, void *context, void **return_value) |
1036 | u32 level, | ||
1037 | void *context, | ||
1038 | void **return_value) | ||
1039 | { | 1018 | { |
1040 | union acpi_operand_object *obj_desc; | 1019 | union acpi_operand_object *obj_desc; |
1041 | struct acpi_namespace_node *node; | 1020 | struct acpi_namespace_node *node; |
1042 | acpi_adr_space_type space_id; | 1021 | acpi_adr_space_type space_id; |
1043 | acpi_status status; | 1022 | acpi_status status; |
1044 | 1023 | ||
1045 | 1024 | space_id = *ACPI_CAST_PTR(acpi_adr_space_type, context); | |
1046 | space_id = *ACPI_CAST_PTR (acpi_adr_space_type, context); | ||
1047 | 1025 | ||
1048 | /* Convert and validate the device handle */ | 1026 | /* Convert and validate the device handle */ |
1049 | 1027 | ||
1050 | node = acpi_ns_map_handle_to_node (obj_handle); | 1028 | node = acpi_ns_map_handle_to_node(obj_handle); |
1051 | if (!node) { | 1029 | if (!node) { |
1052 | return (AE_BAD_PARAMETER); | 1030 | return (AE_BAD_PARAMETER); |
1053 | } | 1031 | } |
@@ -1056,14 +1034,13 @@ acpi_ev_reg_run ( | |||
1056 | * We only care about regions.and objects | 1034 | * We only care about regions.and objects |
1057 | * that are allowed to have address space handlers | 1035 | * that are allowed to have address space handlers |
1058 | */ | 1036 | */ |
1059 | if ((node->type != ACPI_TYPE_REGION) && | 1037 | if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { |
1060 | (node != acpi_gbl_root_node)) { | ||
1061 | return (AE_OK); | 1038 | return (AE_OK); |
1062 | } | 1039 | } |
1063 | 1040 | ||
1064 | /* Check for an existing internal object */ | 1041 | /* Check for an existing internal object */ |
1065 | 1042 | ||
1066 | obj_desc = acpi_ns_get_attached_object (node); | 1043 | obj_desc = acpi_ns_get_attached_object(node); |
1067 | if (!obj_desc) { | 1044 | if (!obj_desc) { |
1068 | /* No object, just exit */ | 1045 | /* No object, just exit */ |
1069 | 1046 | ||
@@ -1080,7 +1057,6 @@ acpi_ev_reg_run ( | |||
1080 | return (AE_OK); | 1057 | return (AE_OK); |
1081 | } | 1058 | } |
1082 | 1059 | ||
1083 | status = acpi_ev_execute_reg_method (obj_desc, 1); | 1060 | status = acpi_ev_execute_reg_method(obj_desc, 1); |
1084 | return (status); | 1061 | return (status); |
1085 | } | 1062 | } |
1086 | |||