Merge master.kernel.org:/pub/scm/linux/kernel/git/dtor/input
[pandora-kernel.git] / drivers / acpi / namespace / nsxfeval.c
1 /*******************************************************************************
2  *
3  * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
4  *                         ACPI Object evaluation interfaces
5  *
6  ******************************************************************************/
7
8 /*
9  * Copyright (C) 2000 - 2005, R. Byron Moore
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions, and the following disclaimer,
17  *    without modification.
18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19  *    substantially similar to the "NO WARRANTY" disclaimer below
20  *    ("Disclaimer") and any redistribution must be conditioned upon
21  *    including a substantially similar Disclaimer requirement for further
22  *    binary redistribution.
23  * 3. Neither the names of the above-listed copyright holders nor the names
24  *    of any contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * Alternatively, this software may be distributed under the terms of the
28  * GNU General Public License ("GPL") version 2 as published by the Free
29  * Software Foundation.
30  *
31  * NO WARRANTY
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42  * POSSIBILITY OF SUCH DAMAGES.
43  */
44
45 #include <linux/module.h>
46
47 #include <acpi/acpi.h>
48 #include <acpi/acnamesp.h>
49 #include <acpi/acinterp.h>
50
51
52 #define _COMPONENT          ACPI_NAMESPACE
53          ACPI_MODULE_NAME    ("nsxfeval")
54
55
56 /*******************************************************************************
57  *
58  * FUNCTION:    acpi_evaluate_object_typed
59  *
60  * PARAMETERS:  Handle              - Object handle (optional)
61  *              Pathname            - Object pathname (optional)
62  *              external_params     - List of parameters to pass to method,
63  *                                    terminated by NULL.  May be NULL
64  *                                    if no parameters are being passed.
65  *              return_buffer       - Where to put method's return value (if
66  *                                    any).  If NULL, no value is returned.
67  *              return_type         - Expected type of return object
68  *
69  * RETURN:      Status
70  *
71  * DESCRIPTION: Find and evaluate the given object, passing the given
72  *              parameters if necessary.  One of "Handle" or "Pathname" must
73  *              be valid (non-null)
74  *
75  ******************************************************************************/
76
77 #ifdef ACPI_FUTURE_USAGE
78 acpi_status
79 acpi_evaluate_object_typed (
80         acpi_handle                     handle,
81         acpi_string                     pathname,
82         struct acpi_object_list         *external_params,
83         struct acpi_buffer              *return_buffer,
84         acpi_object_type                return_type)
85 {
86         acpi_status                     status;
87         u8                              must_free = FALSE;
88
89
90         ACPI_FUNCTION_TRACE ("acpi_evaluate_object_typed");
91
92
93         /* Return buffer must be valid */
94
95         if (!return_buffer) {
96                 return_ACPI_STATUS (AE_BAD_PARAMETER);
97         }
98
99         if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
100                 must_free = TRUE;
101         }
102
103         /* Evaluate the object */
104
105         status = acpi_evaluate_object (handle, pathname, external_params, return_buffer);
106         if (ACPI_FAILURE (status)) {
107                 return_ACPI_STATUS (status);
108         }
109
110         /* Type ANY means "don't care" */
111
112         if (return_type == ACPI_TYPE_ANY) {
113                 return_ACPI_STATUS (AE_OK);
114         }
115
116         if (return_buffer->length == 0) {
117                 /* Error because caller specifically asked for a return value */
118
119                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
120                         "No return value\n"));
121
122                 return_ACPI_STATUS (AE_NULL_OBJECT);
123         }
124
125         /* Examine the object type returned from evaluate_object */
126
127         if (((union acpi_object *) return_buffer->pointer)->type == return_type) {
128                 return_ACPI_STATUS (AE_OK);
129         }
130
131         /* Return object type does not match requested type */
132
133         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
134                 "Incorrect return type [%s] requested [%s]\n",
135                 acpi_ut_get_type_name (((union acpi_object *) return_buffer->pointer)->type),
136                 acpi_ut_get_type_name (return_type)));
137
138         if (must_free) {
139                 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
140
141                 acpi_os_free (return_buffer->pointer);
142                 return_buffer->pointer = NULL;
143         }
144
145         return_buffer->length = 0;
146         return_ACPI_STATUS (AE_TYPE);
147 }
148 #endif  /*  ACPI_FUTURE_USAGE  */
149
150
151 /*******************************************************************************
152  *
153  * FUNCTION:    acpi_evaluate_object
154  *
155  * PARAMETERS:  Handle              - Object handle (optional)
156  *              Pathname            - Object pathname (optional)
157  *              external_params     - List of parameters to pass to method,
158  *                                    terminated by NULL.  May be NULL
159  *                                    if no parameters are being passed.
160  *              return_buffer       - Where to put method's return value (if
161  *                                    any).  If NULL, no value is returned.
162  *
163  * RETURN:      Status
164  *
165  * DESCRIPTION: Find and evaluate the given object, passing the given
166  *              parameters if necessary.  One of "Handle" or "Pathname" must
167  *              be valid (non-null)
168  *
169  ******************************************************************************/
170
171 acpi_status
172 acpi_evaluate_object (
173         acpi_handle                     handle,
174         acpi_string                     pathname,
175         struct acpi_object_list         *external_params,
176         struct acpi_buffer              *return_buffer)
177 {
178         acpi_status                     status;
179         acpi_status                     status2;
180         struct acpi_parameter_info      info;
181         acpi_size                       buffer_space_needed;
182         u32                             i;
183
184
185         ACPI_FUNCTION_TRACE ("acpi_evaluate_object");
186
187
188         info.node = handle;
189         info.parameters = NULL;
190         info.return_object = NULL;
191         info.parameter_type = ACPI_PARAM_ARGS;
192
193         /*
194          * If there are parameters to be passed to the object
195          * (which must be a control method), the external objects
196          * must be converted to internal objects
197          */
198         if (external_params && external_params->count) {
199                 /*
200                  * Allocate a new parameter block for the internal objects
201                  * Add 1 to count to allow for null terminated internal list
202                  */
203                 info.parameters = ACPI_MEM_CALLOCATE (
204                                  ((acpi_size) external_params->count + 1) *
205                                  sizeof (void *));
206                 if (!info.parameters) {
207                         return_ACPI_STATUS (AE_NO_MEMORY);
208                 }
209
210                 /*
211                  * Convert each external object in the list to an
212                  * internal object
213                  */
214                 for (i = 0; i < external_params->count; i++) {
215                         status = acpi_ut_copy_eobject_to_iobject (&external_params->pointer[i],
216                                           &info.parameters[i]);
217                         if (ACPI_FAILURE (status)) {
218                                 acpi_ut_delete_internal_object_list (info.parameters);
219                                 return_ACPI_STATUS (status);
220                         }
221                 }
222                 info.parameters[external_params->count] = NULL;
223         }
224
225
226         /*
227          * Three major cases:
228          * 1) Fully qualified pathname
229          * 2) No handle, not fully qualified pathname (error)
230          * 3) Valid handle
231          */
232         if ((pathname) &&
233                 (acpi_ns_valid_root_prefix (pathname[0]))) {
234                 /*
235                  *  The path is fully qualified, just evaluate by name
236                  */
237                 status = acpi_ns_evaluate_by_name (pathname, &info);
238         }
239         else if (!handle) {
240                 /*
241                  * A handle is optional iff a fully qualified pathname
242                  * is specified.  Since we've already handled fully
243                  * qualified names above, this is an error
244                  */
245                 if (!pathname) {
246                         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
247                                 "Both Handle and Pathname are NULL\n"));
248                 }
249                 else {
250                         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
251                                 "Handle is NULL and Pathname is relative\n"));
252                 }
253
254                 status = AE_BAD_PARAMETER;
255         }
256         else {
257                 /*
258                  * We get here if we have a handle -- and if we have a
259                  * pathname it is relative.  The handle will be validated
260                  * in the lower procedures
261                  */
262                 if (!pathname) {
263                         /*
264                          * The null pathname case means the handle is for
265                          * the actual object to be evaluated
266                          */
267                         status = acpi_ns_evaluate_by_handle (&info);
268                 }
269                 else {
270                    /*
271                         * Both a Handle and a relative Pathname
272                         */
273                         status = acpi_ns_evaluate_relative (pathname, &info);
274                 }
275         }
276
277
278         /*
279          * If we are expecting a return value, and all went well above,
280          * copy the return value to an external object.
281          */
282         if (return_buffer) {
283                 if (!info.return_object) {
284                         return_buffer->length = 0;
285                 }
286                 else {
287                         if (ACPI_GET_DESCRIPTOR_TYPE (info.return_object) == ACPI_DESC_TYPE_NAMED) {
288                                 /*
289                                  * If we received a NS Node as a return object, this means that
290                                  * the object we are evaluating has nothing interesting to
291                                  * return (such as a mutex, etc.)  We return an error because
292                                  * these types are essentially unsupported by this interface.
293                                  * We don't check up front because this makes it easier to add
294                                  * support for various types at a later date if necessary.
295                                  */
296                                 status = AE_TYPE;
297                                 info.return_object = NULL;  /* No need to delete a NS Node */
298                                 return_buffer->length = 0;
299                         }
300
301                         if (ACPI_SUCCESS (status)) {
302                                 /*
303                                  * Find out how large a buffer is needed
304                                  * to contain the returned object
305                                  */
306                                 status = acpi_ut_get_object_size (info.return_object,
307                                                    &buffer_space_needed);
308                                 if (ACPI_SUCCESS (status)) {
309                                         /* Validate/Allocate/Clear caller buffer */
310
311                                         status = acpi_ut_initialize_buffer (return_buffer,
312                                                           buffer_space_needed);
313                                         if (ACPI_FAILURE (status)) {
314                                                 /*
315                                                  * Caller's buffer is too small or a new one can't be allocated
316                                                  */
317                                                 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
318                                                         "Needed buffer size %X, %s\n",
319                                                         (u32) buffer_space_needed,
320                                                         acpi_format_exception (status)));
321                                         }
322                                         else {
323                                                 /*
324                                                  *  We have enough space for the object, build it
325                                                  */
326                                                 status = acpi_ut_copy_iobject_to_eobject (info.return_object,
327                                                                   return_buffer);
328                                         }
329                                 }
330                         }
331                 }
332         }
333
334         if (info.return_object) {
335                 /*
336                  * Delete the internal return object.  NOTE: Interpreter
337                  * must be locked to avoid race condition.
338                  */
339                 status2 = acpi_ex_enter_interpreter ();
340                 if (ACPI_SUCCESS (status2)) {
341                         /*
342                          * Delete the internal return object. (Or at least
343                          * decrement the reference count by one)
344                          */
345                         acpi_ut_remove_reference (info.return_object);
346                         acpi_ex_exit_interpreter ();
347                 }
348         }
349
350         /*
351          * Free the input parameter list (if we created one),
352          */
353         if (info.parameters) {
354                 /* Free the allocated parameter block */
355
356                 acpi_ut_delete_internal_object_list (info.parameters);
357         }
358
359         return_ACPI_STATUS (status);
360 }
361 EXPORT_SYMBOL(acpi_evaluate_object);
362
363
364 /*******************************************************************************
365  *
366  * FUNCTION:    acpi_walk_namespace
367  *
368  * PARAMETERS:  Type                - acpi_object_type to search for
369  *              start_object        - Handle in namespace where search begins
370  *              max_depth           - Depth to which search is to reach
371  *              user_function       - Called when an object of "Type" is found
372  *              Context             - Passed to user function
373  *              return_value        - Location where return value of
374  *                                    user_function is put if terminated early
375  *
376  * RETURNS      Return value from the user_function if terminated early.
377  *              Otherwise, returns NULL.
378  *
379  * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
380  *              starting (and ending) at the object specified by start_handle.
381  *              The user_function is called whenever an object that matches
382  *              the type parameter is found.  If the user function returns
383  *              a non-zero value, the search is terminated immediately and this
384  *              value is returned to the caller.
385  *
386  *              The point of this procedure is to provide a generic namespace
387  *              walk routine that can be called from multiple places to
388  *              provide multiple services;  the User Function can be tailored
389  *              to each task, whether it is a print function, a compare
390  *              function, etc.
391  *
392  ******************************************************************************/
393
394 acpi_status
395 acpi_walk_namespace (
396         acpi_object_type                type,
397         acpi_handle                     start_object,
398         u32                             max_depth,
399         acpi_walk_callback              user_function,
400         void                            *context,
401         void                            **return_value)
402 {
403         acpi_status                     status;
404
405
406         ACPI_FUNCTION_TRACE ("acpi_walk_namespace");
407
408
409         /* Parameter validation */
410
411         if ((type > ACPI_TYPE_EXTERNAL_MAX) ||
412                 (!max_depth)                    ||
413                 (!user_function)) {
414                 return_ACPI_STATUS (AE_BAD_PARAMETER);
415         }
416
417         /*
418          * Lock the namespace around the walk.
419          * The namespace will be unlocked/locked around each call
420          * to the user function - since this function
421          * must be allowed to make Acpi calls itself.
422          */
423         status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
424         if (ACPI_FAILURE (status)) {
425                 return_ACPI_STATUS (status);
426         }
427
428         status = acpi_ns_walk_namespace (type, start_object, max_depth,
429                           ACPI_NS_WALK_UNLOCK,
430                           user_function, context, return_value);
431
432         (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
433         return_ACPI_STATUS (status);
434 }
435 EXPORT_SYMBOL(acpi_walk_namespace);
436
437
438 /*******************************************************************************
439  *
440  * FUNCTION:    acpi_ns_get_device_callback
441  *
442  * PARAMETERS:  Callback from acpi_get_device
443  *
444  * RETURN:      Status
445  *
446  * DESCRIPTION: Takes callbacks from walk_namespace and filters out all non-
447  *              present devices, or if they specified a HID, it filters based
448  *              on that.
449  *
450  ******************************************************************************/
451
452 static acpi_status
453 acpi_ns_get_device_callback (
454         acpi_handle                     obj_handle,
455         u32                             nesting_level,
456         void                            *context,
457         void                            **return_value)
458 {
459         struct acpi_get_devices_info    *info = context;
460         acpi_status                     status;
461         struct acpi_namespace_node      *node;
462         u32                             flags;
463         struct acpi_device_id           hid;
464         struct acpi_compatible_id_list *cid;
465         acpi_native_uint                i;
466
467
468         status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
469         if (ACPI_FAILURE (status)) {
470                 return (status);
471         }
472
473         node = acpi_ns_map_handle_to_node (obj_handle);
474         status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
475         if (ACPI_FAILURE (status)) {
476                 return (status);
477         }
478
479         if (!node) {
480                 return (AE_BAD_PARAMETER);
481         }
482
483         /* Run _STA to determine if device is present */
484
485         status = acpi_ut_execute_STA (node, &flags);
486         if (ACPI_FAILURE (status)) {
487                 return (AE_CTRL_DEPTH);
488         }
489
490         if (!(flags & 0x01)) {
491                 /* Don't return at the device or children of the device if not there */
492
493                 return (AE_CTRL_DEPTH);
494         }
495
496         /* Filter based on device HID & CID */
497
498         if (info->hid != NULL) {
499                 status = acpi_ut_execute_HID (node, &hid);
500                 if (status == AE_NOT_FOUND) {
501                         return (AE_OK);
502                 }
503                 else if (ACPI_FAILURE (status)) {
504                         return (AE_CTRL_DEPTH);
505                 }
506
507                 if (ACPI_STRNCMP (hid.value, info->hid, sizeof (hid.value)) != 0) {
508                         /* Get the list of Compatible IDs */
509
510                         status = acpi_ut_execute_CID (node, &cid);
511                         if (status == AE_NOT_FOUND) {
512                                 return (AE_OK);
513                         }
514                         else if (ACPI_FAILURE (status)) {
515                                 return (AE_CTRL_DEPTH);
516                         }
517
518                         /* Walk the CID list */
519
520                         for (i = 0; i < cid->count; i++) {
521                                 if (ACPI_STRNCMP (cid->id[i].value, info->hid,
522                                                  sizeof (struct acpi_compatible_id)) != 0) {
523                                         ACPI_MEM_FREE (cid);
524                                         return (AE_OK);
525                                 }
526                         }
527                         ACPI_MEM_FREE (cid);
528                 }
529         }
530
531         status = info->user_function (obj_handle, nesting_level, info->context,
532                          return_value);
533         return (status);
534 }
535
536
537 /*******************************************************************************
538  *
539  * FUNCTION:    acpi_get_devices
540  *
541  * PARAMETERS:  HID                 - HID to search for. Can be NULL.
542  *              user_function       - Called when a matching object is found
543  *              Context             - Passed to user function
544  *              return_value        - Location where return value of
545  *                                    user_function is put if terminated early
546  *
547  * RETURNS      Return value from the user_function if terminated early.
548  *              Otherwise, returns NULL.
549  *
550  * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
551  *              starting (and ending) at the object specified by start_handle.
552  *              The user_function is called whenever an object of type
553  *              Device is found.  If the user function returns
554  *              a non-zero value, the search is terminated immediately and this
555  *              value is returned to the caller.
556  *
557  *              This is a wrapper for walk_namespace, but the callback performs
558  *              additional filtering. Please see acpi_get_device_callback.
559  *
560  ******************************************************************************/
561
562 acpi_status
563 acpi_get_devices (
564         char                            *HID,
565         acpi_walk_callback              user_function,
566         void                            *context,
567         void                            **return_value)
568 {
569         acpi_status                     status;
570         struct acpi_get_devices_info    info;
571
572
573         ACPI_FUNCTION_TRACE ("acpi_get_devices");
574
575
576         /* Parameter validation */
577
578         if (!user_function) {
579                 return_ACPI_STATUS (AE_BAD_PARAMETER);
580         }
581
582         /*
583          * We're going to call their callback from OUR callback, so we need
584          * to know what it is, and their context parameter.
585          */
586         info.context      = context;
587         info.user_function = user_function;
588         info.hid          = HID;
589
590         /*
591          * Lock the namespace around the walk.
592          * The namespace will be unlocked/locked around each call
593          * to the user function - since this function
594          * must be allowed to make Acpi calls itself.
595          */
596         status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
597         if (ACPI_FAILURE (status)) {
598                 return_ACPI_STATUS (status);
599         }
600
601         status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE,
602                            ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
603                            ACPI_NS_WALK_UNLOCK,
604                            acpi_ns_get_device_callback, &info,
605                            return_value);
606
607         (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
608         return_ACPI_STATUS (status);
609 }
610 EXPORT_SYMBOL(acpi_get_devices);
611
612
613 /*******************************************************************************
614  *
615  * FUNCTION:    acpi_attach_data
616  *
617  * PARAMETERS:  obj_handle          - Namespace node
618  *              Handler             - Handler for this attachment
619  *              Data                - Pointer to data to be attached
620  *
621  * RETURN:      Status
622  *
623  * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
624  *
625  ******************************************************************************/
626
627 acpi_status
628 acpi_attach_data (
629         acpi_handle                     obj_handle,
630         acpi_object_handler             handler,
631         void                            *data)
632 {
633         struct acpi_namespace_node      *node;
634         acpi_status                     status;
635
636
637         /* Parameter validation */
638
639         if (!obj_handle ||
640                 !handler    ||
641                 !data) {
642                 return (AE_BAD_PARAMETER);
643         }
644
645         status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
646         if (ACPI_FAILURE (status)) {
647                 return (status);
648         }
649
650         /* Convert and validate the handle */
651
652         node = acpi_ns_map_handle_to_node (obj_handle);
653         if (!node) {
654                 status = AE_BAD_PARAMETER;
655                 goto unlock_and_exit;
656         }
657
658         status = acpi_ns_attach_data (node, handler, data);
659
660 unlock_and_exit:
661         (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
662         return (status);
663 }
664
665
666 /*******************************************************************************
667  *
668  * FUNCTION:    acpi_detach_data
669  *
670  * PARAMETERS:  obj_handle          - Namespace node handle
671  *              Handler             - Handler used in call to acpi_attach_data
672  *
673  * RETURN:      Status
674  *
675  * DESCRIPTION: Remove data that was previously attached to a node.
676  *
677  ******************************************************************************/
678
679 acpi_status
680 acpi_detach_data (
681         acpi_handle                     obj_handle,
682         acpi_object_handler             handler)
683 {
684         struct acpi_namespace_node      *node;
685         acpi_status                     status;
686
687
688         /* Parameter validation */
689
690         if (!obj_handle ||
691                 !handler) {
692                 return (AE_BAD_PARAMETER);
693         }
694
695         status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
696         if (ACPI_FAILURE (status)) {
697                 return (status);
698         }
699
700         /* Convert and validate the handle */
701
702         node = acpi_ns_map_handle_to_node (obj_handle);
703         if (!node) {
704                 status = AE_BAD_PARAMETER;
705                 goto unlock_and_exit;
706         }
707
708         status = acpi_ns_detach_data (node, handler);
709
710 unlock_and_exit:
711         (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
712         return (status);
713 }
714
715
716 /*******************************************************************************
717  *
718  * FUNCTION:    acpi_get_data
719  *
720  * PARAMETERS:  obj_handle          - Namespace node
721  *              Handler             - Handler used in call to attach_data
722  *              Data                - Where the data is returned
723  *
724  * RETURN:      Status
725  *
726  * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
727  *
728  ******************************************************************************/
729
730 acpi_status
731 acpi_get_data (
732         acpi_handle                     obj_handle,
733         acpi_object_handler             handler,
734         void                            **data)
735 {
736         struct acpi_namespace_node      *node;
737         acpi_status                     status;
738
739
740         /* Parameter validation */
741
742         if (!obj_handle ||
743                 !handler    ||
744                 !data) {
745                 return (AE_BAD_PARAMETER);
746         }
747
748         status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
749         if (ACPI_FAILURE (status)) {
750                 return (status);
751         }
752
753         /* Convert and validate the handle */
754
755         node = acpi_ns_map_handle_to_node (obj_handle);
756         if (!node) {
757                 status = AE_BAD_PARAMETER;
758                 goto unlock_and_exit;
759         }
760
761         status = acpi_ns_get_attached_data (node, handler, data);
762
763 unlock_and_exit:
764         (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
765         return (status);
766 }
767
768