nsxfname.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /******************************************************************************
  2. *
  3. * Module Name: nsxfname - Public interfaces to the ACPI subsystem
  4. * ACPI Namespace oriented interfaces
  5. *
  6. *****************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2016, Intel Corp.
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions, and the following disclaimer,
  16. * without modification.
  17. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18. * substantially similar to the "NO WARRANTY" disclaimer below
  19. * ("Disclaimer") and any redistribution must be conditioned upon
  20. * including a substantially similar Disclaimer requirement for further
  21. * binary redistribution.
  22. * 3. Neither the names of the above-listed copyright holders nor the names
  23. * of any contributors may be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * Alternatively, this software may be distributed under the terms of the
  27. * GNU General Public License ("GPL") version 2 as published by the Free
  28. * Software Foundation.
  29. *
  30. * NO WARRANTY
  31. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. * POSSIBILITY OF SUCH DAMAGES.
  42. */
  43. #define EXPORT_ACPI_INTERFACES
  44. #include <acpi/acpi.h>
  45. #include "accommon.h"
  46. #include "acnamesp.h"
  47. #include "acparser.h"
  48. #include "amlcode.h"
  49. #define _COMPONENT ACPI_NAMESPACE
  50. ACPI_MODULE_NAME("nsxfname")
  51. /* Local prototypes */
  52. static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest,
  53. struct acpi_pnp_device_id *source,
  54. char *string_area);
  55. /******************************************************************************
  56. *
  57. * FUNCTION: acpi_get_handle
  58. *
  59. * PARAMETERS: parent - Object to search under (search scope).
  60. * pathname - Pointer to an asciiz string containing the
  61. * name
  62. * ret_handle - Where the return handle is returned
  63. *
  64. * RETURN: Status
  65. *
  66. * DESCRIPTION: This routine will search for a caller specified name in the
  67. * name space. The caller can restrict the search region by
  68. * specifying a non NULL parent. The parent value is itself a
  69. * namespace handle.
  70. *
  71. ******************************************************************************/
  72. acpi_status
  73. acpi_get_handle(acpi_handle parent,
  74. acpi_string pathname, acpi_handle *ret_handle)
  75. {
  76. acpi_status status;
  77. struct acpi_namespace_node *node = NULL;
  78. struct acpi_namespace_node *prefix_node = NULL;
  79. ACPI_FUNCTION_ENTRY();
  80. /* Parameter Validation */
  81. if (!ret_handle || !pathname) {
  82. return (AE_BAD_PARAMETER);
  83. }
  84. /* Convert a parent handle to a prefix node */
  85. if (parent) {
  86. prefix_node = acpi_ns_validate_handle(parent);
  87. if (!prefix_node) {
  88. return (AE_BAD_PARAMETER);
  89. }
  90. }
  91. /*
  92. * Valid cases are:
  93. * 1) Fully qualified pathname
  94. * 2) Parent + Relative pathname
  95. *
  96. * Error for <null Parent + relative path>
  97. */
  98. if (ACPI_IS_ROOT_PREFIX(pathname[0])) {
  99. /* Pathname is fully qualified (starts with '\') */
  100. /* Special case for root-only, since we can't search for it */
  101. if (!strcmp(pathname, ACPI_NS_ROOT_PATH)) {
  102. *ret_handle =
  103. ACPI_CAST_PTR(acpi_handle, acpi_gbl_root_node);
  104. return (AE_OK);
  105. }
  106. } else if (!prefix_node) {
  107. /* Relative path with null prefix is disallowed */
  108. return (AE_BAD_PARAMETER);
  109. }
  110. /* Find the Node and convert to a handle */
  111. status =
  112. acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node);
  113. if (ACPI_SUCCESS(status)) {
  114. *ret_handle = ACPI_CAST_PTR(acpi_handle, node);
  115. }
  116. return (status);
  117. }
  118. ACPI_EXPORT_SYMBOL(acpi_get_handle)
  119. /******************************************************************************
  120. *
  121. * FUNCTION: acpi_get_name
  122. *
  123. * PARAMETERS: handle - Handle to be converted to a pathname
  124. * name_type - Full pathname or single segment
  125. * buffer - Buffer for returned path
  126. *
  127. * RETURN: Pointer to a string containing the fully qualified Name.
  128. *
  129. * DESCRIPTION: This routine returns the fully qualified name associated with
  130. * the Handle parameter. This and the acpi_pathname_to_handle are
  131. * complementary functions.
  132. *
  133. ******************************************************************************/
  134. acpi_status
  135. acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer *buffer)
  136. {
  137. acpi_status status;
  138. struct acpi_namespace_node *node;
  139. const char *node_name;
  140. /* Parameter validation */
  141. if (name_type > ACPI_NAME_TYPE_MAX) {
  142. return (AE_BAD_PARAMETER);
  143. }
  144. status = acpi_ut_validate_buffer(buffer);
  145. if (ACPI_FAILURE(status)) {
  146. return (status);
  147. }
  148. if (name_type == ACPI_FULL_PATHNAME ||
  149. name_type == ACPI_FULL_PATHNAME_NO_TRAILING) {
  150. /* Get the full pathname (From the namespace root) */
  151. status = acpi_ns_handle_to_pathname(handle, buffer,
  152. name_type ==
  153. ACPI_FULL_PATHNAME ? FALSE :
  154. TRUE);
  155. return (status);
  156. }
  157. /*
  158. * Wants the single segment ACPI name.
  159. * Validate handle and convert to a namespace Node
  160. */
  161. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  162. if (ACPI_FAILURE(status)) {
  163. return (status);
  164. }
  165. node = acpi_ns_validate_handle(handle);
  166. if (!node) {
  167. status = AE_BAD_PARAMETER;
  168. goto unlock_and_exit;
  169. }
  170. /* Validate/Allocate/Clear caller buffer */
  171. status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
  172. if (ACPI_FAILURE(status)) {
  173. goto unlock_and_exit;
  174. }
  175. /* Just copy the ACPI name from the Node and zero terminate it */
  176. node_name = acpi_ut_get_node_name(node);
  177. ACPI_MOVE_NAME(buffer->pointer, node_name);
  178. ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
  179. status = AE_OK;
  180. unlock_and_exit:
  181. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  182. return (status);
  183. }
  184. ACPI_EXPORT_SYMBOL(acpi_get_name)
  185. /******************************************************************************
  186. *
  187. * FUNCTION: acpi_ns_copy_device_id
  188. *
  189. * PARAMETERS: dest - Pointer to the destination PNP_DEVICE_ID
  190. * source - Pointer to the source PNP_DEVICE_ID
  191. * string_area - Pointer to where to copy the dest string
  192. *
  193. * RETURN: Pointer to the next string area
  194. *
  195. * DESCRIPTION: Copy a single PNP_DEVICE_ID, including the string data.
  196. *
  197. ******************************************************************************/
  198. static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest,
  199. struct acpi_pnp_device_id *source,
  200. char *string_area)
  201. {
  202. /* Create the destination PNP_DEVICE_ID */
  203. dest->string = string_area;
  204. dest->length = source->length;
  205. /* Copy actual string and return a pointer to the next string area */
  206. memcpy(string_area, source->string, source->length);
  207. return (string_area + source->length);
  208. }
  209. /******************************************************************************
  210. *
  211. * FUNCTION: acpi_get_object_info
  212. *
  213. * PARAMETERS: handle - Object Handle
  214. * return_buffer - Where the info is returned
  215. *
  216. * RETURN: Status
  217. *
  218. * DESCRIPTION: Returns information about an object as gleaned from the
  219. * namespace node and possibly by running several standard
  220. * control methods (Such as in the case of a device.)
  221. *
  222. * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA,
  223. * _CLS, _ADR, _sx_w, and _sx_d methods.
  224. *
  225. * Note: Allocates the return buffer, must be freed by the caller.
  226. *
  227. * Note: This interface is intended to be used during the initial device
  228. * discovery namespace traversal. Therefore, no complex methods can be
  229. * executed, especially those that access operation regions. Therefore, do
  230. * not add any additional methods that could cause problems in this area.
  231. * this was the fate of the _SUB method which was found to cause such
  232. * problems and was removed (11/2015).
  233. *
  234. ******************************************************************************/
  235. acpi_status
  236. acpi_get_object_info(acpi_handle handle,
  237. struct acpi_device_info **return_buffer)
  238. {
  239. struct acpi_namespace_node *node;
  240. struct acpi_device_info *info;
  241. struct acpi_pnp_device_id_list *cid_list = NULL;
  242. struct acpi_pnp_device_id *hid = NULL;
  243. struct acpi_pnp_device_id *uid = NULL;
  244. struct acpi_pnp_device_id *cls = NULL;
  245. char *next_id_string;
  246. acpi_object_type type;
  247. acpi_name name;
  248. u8 param_count = 0;
  249. u16 valid = 0;
  250. u32 info_size;
  251. u32 i;
  252. acpi_status status;
  253. /* Parameter validation */
  254. if (!handle || !return_buffer) {
  255. return (AE_BAD_PARAMETER);
  256. }
  257. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  258. if (ACPI_FAILURE(status)) {
  259. return (status);
  260. }
  261. node = acpi_ns_validate_handle(handle);
  262. if (!node) {
  263. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  264. return (AE_BAD_PARAMETER);
  265. }
  266. /* Get the namespace node data while the namespace is locked */
  267. info_size = sizeof(struct acpi_device_info);
  268. type = node->type;
  269. name = node->name.integer;
  270. if (node->type == ACPI_TYPE_METHOD) {
  271. param_count = node->object->method.param_count;
  272. }
  273. status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  274. if (ACPI_FAILURE(status)) {
  275. return (status);
  276. }
  277. if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) {
  278. /*
  279. * Get extra info for ACPI Device/Processor objects only:
  280. * Run the Device _HID, _UID, _CLS, and _CID methods.
  281. *
  282. * Note: none of these methods are required, so they may or may
  283. * not be present for this device. The Info->Valid bitfield is used
  284. * to indicate which methods were found and run successfully.
  285. */
  286. /* Execute the Device._HID method */
  287. status = acpi_ut_execute_HID(node, &hid);
  288. if (ACPI_SUCCESS(status)) {
  289. info_size += hid->length;
  290. valid |= ACPI_VALID_HID;
  291. }
  292. /* Execute the Device._UID method */
  293. status = acpi_ut_execute_UID(node, &uid);
  294. if (ACPI_SUCCESS(status)) {
  295. info_size += uid->length;
  296. valid |= ACPI_VALID_UID;
  297. }
  298. /* Execute the Device._CID method */
  299. status = acpi_ut_execute_CID(node, &cid_list);
  300. if (ACPI_SUCCESS(status)) {
  301. /* Add size of CID strings and CID pointer array */
  302. info_size +=
  303. (cid_list->list_size -
  304. sizeof(struct acpi_pnp_device_id_list));
  305. valid |= ACPI_VALID_CID;
  306. }
  307. /* Execute the Device._CLS method */
  308. status = acpi_ut_execute_CLS(node, &cls);
  309. if (ACPI_SUCCESS(status)) {
  310. info_size += cls->length;
  311. valid |= ACPI_VALID_CLS;
  312. }
  313. }
  314. /*
  315. * Now that we have the variable-length data, we can allocate the
  316. * return buffer
  317. */
  318. info = ACPI_ALLOCATE_ZEROED(info_size);
  319. if (!info) {
  320. status = AE_NO_MEMORY;
  321. goto cleanup;
  322. }
  323. /* Get the fixed-length data */
  324. if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) {
  325. /*
  326. * Get extra info for ACPI Device/Processor objects only:
  327. * Run the _STA, _ADR and, sx_w, and _sx_d methods.
  328. *
  329. * Notes: none of these methods are required, so they may or may
  330. * not be present for this device. The Info->Valid bitfield is used
  331. * to indicate which methods were found and run successfully.
  332. *
  333. * For _STA, if the method does not exist, then (as per the ACPI
  334. * specification), the returned current_status flags will indicate
  335. * that the device is present/functional/enabled. Otherwise, the
  336. * current_status flags reflect the value returned from _STA.
  337. */
  338. /* Execute the Device._STA method */
  339. status = acpi_ut_execute_STA(node, &info->current_status);
  340. if (ACPI_SUCCESS(status)) {
  341. valid |= ACPI_VALID_STA;
  342. }
  343. /* Execute the Device._ADR method */
  344. status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node,
  345. &info->address);
  346. if (ACPI_SUCCESS(status)) {
  347. valid |= ACPI_VALID_ADR;
  348. }
  349. /* Execute the Device._sx_w methods */
  350. status = acpi_ut_execute_power_methods(node,
  351. acpi_gbl_lowest_dstate_names,
  352. ACPI_NUM_sx_w_METHODS,
  353. info->lowest_dstates);
  354. if (ACPI_SUCCESS(status)) {
  355. valid |= ACPI_VALID_SXWS;
  356. }
  357. /* Execute the Device._sx_d methods */
  358. status = acpi_ut_execute_power_methods(node,
  359. acpi_gbl_highest_dstate_names,
  360. ACPI_NUM_sx_d_METHODS,
  361. info->highest_dstates);
  362. if (ACPI_SUCCESS(status)) {
  363. valid |= ACPI_VALID_SXDS;
  364. }
  365. }
  366. /*
  367. * Create a pointer to the string area of the return buffer.
  368. * Point to the end of the base struct acpi_device_info structure.
  369. */
  370. next_id_string = ACPI_CAST_PTR(char, info->compatible_id_list.ids);
  371. if (cid_list) {
  372. /* Point past the CID PNP_DEVICE_ID array */
  373. next_id_string +=
  374. ((acpi_size)cid_list->count *
  375. sizeof(struct acpi_pnp_device_id));
  376. }
  377. /*
  378. * Copy the HID, UID, and CIDs to the return buffer. The variable-length
  379. * strings are copied to the reserved area at the end of the buffer.
  380. *
  381. * For HID and CID, check if the ID is a PCI Root Bridge.
  382. */
  383. if (hid) {
  384. next_id_string = acpi_ns_copy_device_id(&info->hardware_id,
  385. hid, next_id_string);
  386. if (acpi_ut_is_pci_root_bridge(hid->string)) {
  387. info->flags |= ACPI_PCI_ROOT_BRIDGE;
  388. }
  389. }
  390. if (uid) {
  391. next_id_string = acpi_ns_copy_device_id(&info->unique_id,
  392. uid, next_id_string);
  393. }
  394. if (cid_list) {
  395. info->compatible_id_list.count = cid_list->count;
  396. info->compatible_id_list.list_size = cid_list->list_size;
  397. /* Copy each CID */
  398. for (i = 0; i < cid_list->count; i++) {
  399. next_id_string =
  400. acpi_ns_copy_device_id(&info->compatible_id_list.
  401. ids[i], &cid_list->ids[i],
  402. next_id_string);
  403. if (acpi_ut_is_pci_root_bridge(cid_list->ids[i].string)) {
  404. info->flags |= ACPI_PCI_ROOT_BRIDGE;
  405. }
  406. }
  407. }
  408. if (cls) {
  409. next_id_string = acpi_ns_copy_device_id(&info->class_code,
  410. cls, next_id_string);
  411. }
  412. /* Copy the fixed-length data */
  413. info->info_size = info_size;
  414. info->type = type;
  415. info->name = name;
  416. info->param_count = param_count;
  417. info->valid = valid;
  418. *return_buffer = info;
  419. status = AE_OK;
  420. cleanup:
  421. if (hid) {
  422. ACPI_FREE(hid);
  423. }
  424. if (uid) {
  425. ACPI_FREE(uid);
  426. }
  427. if (cid_list) {
  428. ACPI_FREE(cid_list);
  429. }
  430. if (cls) {
  431. ACPI_FREE(cls);
  432. }
  433. return (status);
  434. }
  435. ACPI_EXPORT_SYMBOL(acpi_get_object_info)
  436. /******************************************************************************
  437. *
  438. * FUNCTION: acpi_install_method
  439. *
  440. * PARAMETERS: buffer - An ACPI table containing one control method
  441. *
  442. * RETURN: Status
  443. *
  444. * DESCRIPTION: Install a control method into the namespace. If the method
  445. * name already exists in the namespace, it is overwritten. The
  446. * input buffer must contain a valid DSDT or SSDT containing a
  447. * single control method.
  448. *
  449. ******************************************************************************/
  450. acpi_status acpi_install_method(u8 *buffer)
  451. {
  452. struct acpi_table_header *table =
  453. ACPI_CAST_PTR(struct acpi_table_header, buffer);
  454. u8 *aml_buffer;
  455. u8 *aml_start;
  456. char *path;
  457. struct acpi_namespace_node *node;
  458. union acpi_operand_object *method_obj;
  459. struct acpi_parse_state parser_state;
  460. u32 aml_length;
  461. u16 opcode;
  462. u8 method_flags;
  463. acpi_status status;
  464. /* Parameter validation */
  465. if (!buffer) {
  466. return (AE_BAD_PARAMETER);
  467. }
  468. /* Table must be a DSDT or SSDT */
  469. if (!ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) &&
  470. !ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) {
  471. return (AE_BAD_HEADER);
  472. }
  473. /* First AML opcode in the table must be a control method */
  474. parser_state.aml = buffer + sizeof(struct acpi_table_header);
  475. opcode = acpi_ps_peek_opcode(&parser_state);
  476. if (opcode != AML_METHOD_OP) {
  477. return (AE_BAD_PARAMETER);
  478. }
  479. /* Extract method information from the raw AML */
  480. parser_state.aml += acpi_ps_get_opcode_size(opcode);
  481. parser_state.pkg_end = acpi_ps_get_next_package_end(&parser_state);
  482. path = acpi_ps_get_next_namestring(&parser_state);
  483. method_flags = *parser_state.aml++;
  484. aml_start = parser_state.aml;
  485. aml_length = ACPI_PTR_DIFF(parser_state.pkg_end, aml_start);
  486. /*
  487. * Allocate resources up-front. We don't want to have to delete a new
  488. * node from the namespace if we cannot allocate memory.
  489. */
  490. aml_buffer = ACPI_ALLOCATE(aml_length);
  491. if (!aml_buffer) {
  492. return (AE_NO_MEMORY);
  493. }
  494. method_obj = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
  495. if (!method_obj) {
  496. ACPI_FREE(aml_buffer);
  497. return (AE_NO_MEMORY);
  498. }
  499. /* Lock namespace for acpi_ns_lookup, we may be creating a new node */
  500. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  501. if (ACPI_FAILURE(status)) {
  502. goto error_exit;
  503. }
  504. /* The lookup either returns an existing node or creates a new one */
  505. status =
  506. acpi_ns_lookup(NULL, path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1,
  507. ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND,
  508. NULL, &node);
  509. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  510. if (ACPI_FAILURE(status)) { /* ns_lookup */
  511. if (status != AE_ALREADY_EXISTS) {
  512. goto error_exit;
  513. }
  514. /* Node existed previously, make sure it is a method node */
  515. if (node->type != ACPI_TYPE_METHOD) {
  516. status = AE_TYPE;
  517. goto error_exit;
  518. }
  519. }
  520. /* Copy the method AML to the local buffer */
  521. memcpy(aml_buffer, aml_start, aml_length);
  522. /* Initialize the method object with the new method's information */
  523. method_obj->method.aml_start = aml_buffer;
  524. method_obj->method.aml_length = aml_length;
  525. method_obj->method.param_count = (u8)
  526. (method_flags & AML_METHOD_ARG_COUNT);
  527. if (method_flags & AML_METHOD_SERIALIZED) {
  528. method_obj->method.info_flags = ACPI_METHOD_SERIALIZED;
  529. method_obj->method.sync_level = (u8)
  530. ((method_flags & AML_METHOD_SYNC_LEVEL) >> 4);
  531. }
  532. /*
  533. * Now that it is complete, we can attach the new method object to
  534. * the method Node (detaches/deletes any existing object)
  535. */
  536. status = acpi_ns_attach_object(node, method_obj, ACPI_TYPE_METHOD);
  537. /*
  538. * Flag indicates AML buffer is dynamic, must be deleted later.
  539. * Must be set only after attach above.
  540. */
  541. node->flags |= ANOBJ_ALLOCATED_BUFFER;
  542. /* Remove local reference to the method object */
  543. acpi_ut_remove_reference(method_obj);
  544. return (status);
  545. error_exit:
  546. ACPI_FREE(aml_buffer);
  547. ACPI_FREE(method_obj);
  548. return (status);
  549. }
  550. ACPI_EXPORT_SYMBOL(acpi_install_method)