Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: nsload - namespace loading/expanding/contracting procedures |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | c8100dc | 2016-01-15 08:17:03 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2016, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
| 46 | #include "acnamesp.h" |
| 47 | #include "acdispat.h" |
| 48 | #include "actables.h" |
Lv Zheng | 74f51b8 | 2016-09-07 14:07:10 +0800 | [diff] [blame] | 49 | #include "acinterp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #define _COMPONENT ACPI_NAMESPACE |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 52 | ACPI_MODULE_NAME("nsload") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 54 | /* Local prototypes */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 55 | #ifdef ACPI_FUTURE_IMPLEMENTATION |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 56 | acpi_status acpi_ns_unload_namespace(acpi_handle handle); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 57 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 58 | static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 59 | #endif |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #ifndef ACPI_NO_METHOD_EXECUTION |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | /******************************************************************************* |
| 63 | * |
| 64 | * FUNCTION: acpi_ns_load_table |
| 65 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 66 | * PARAMETERS: table_index - Index for table to be loaded |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 67 | * node - Owning NS node |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | * |
| 69 | * RETURN: Status |
| 70 | * |
| 71 | * DESCRIPTION: Load one ACPI table into the namespace |
| 72 | * |
| 73 | ******************************************************************************/ |
| 74 | |
| 75 | acpi_status |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 76 | acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 78 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 80 | ACPI_FUNCTION_TRACE(ns_load_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 82 | /* If table already loaded into namespace, just return */ |
| 83 | |
| 84 | if (acpi_tb_is_table_loaded(table_index)) { |
| 85 | status = AE_ALREADY_EXISTS; |
| 86 | goto unlock; |
| 87 | } |
| 88 | |
| 89 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 90 | "**** Loading table into namespace ****\n")); |
| 91 | |
| 92 | status = acpi_tb_allocate_owner_id(table_index); |
| 93 | if (ACPI_FAILURE(status)) { |
| 94 | goto unlock; |
| 95 | } |
| 96 | |
Lv Zheng | 74f51b8 | 2016-09-07 14:07:10 +0800 | [diff] [blame] | 97 | /* |
| 98 | * Parse the table and load the namespace with all named |
| 99 | * objects found within. Control methods are NOT parsed |
| 100 | * at this time. In fact, the control methods cannot be |
| 101 | * parsed until the entire namespace is loaded, because |
| 102 | * if a control method makes a forward reference (call) |
| 103 | * to another control method, we can't continue parsing |
| 104 | * because we don't know how many arguments to parse next! |
| 105 | */ |
Bob Moore | 7f4ac9f | 2008-04-10 19:06:39 +0400 | [diff] [blame] | 106 | status = acpi_ns_parse_table(table_index, node); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 107 | if (ACPI_SUCCESS(status)) { |
| 108 | acpi_tb_set_table_loaded_flag(table_index, TRUE); |
| 109 | } else { |
Bob Moore | 4712f71 | 2015-08-25 10:28:26 +0800 | [diff] [blame] | 110 | /* |
| 111 | * On error, delete any namespace objects created by this table. |
| 112 | * We cannot initialize these objects, so delete them. There are |
| 113 | * a couple of expecially bad cases: |
| 114 | * AE_ALREADY_EXISTS - namespace collision. |
| 115 | * AE_NOT_FOUND - the target of a Scope operator does not |
| 116 | * exist. This target of Scope must already exist in the |
| 117 | * namespace, as per the ACPI specification. |
| 118 | */ |
Bob Moore | 4712f71 | 2015-08-25 10:28:26 +0800 | [diff] [blame] | 119 | acpi_ns_delete_namespace_by_owner(acpi_gbl_root_table_list. |
| 120 | tables[table_index].owner_id); |
Bob Moore | 4712f71 | 2015-08-25 10:28:26 +0800 | [diff] [blame] | 121 | |
Lv Zheng | 80b2881 | 2016-03-24 09:38:28 +0800 | [diff] [blame] | 122 | acpi_tb_release_owner_id(table_index); |
Bob Moore | 4712f71 | 2015-08-25 10:28:26 +0800 | [diff] [blame] | 123 | return_ACPI_STATUS(status); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 124 | } |
| 125 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 126 | unlock: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 127 | if (ACPI_FAILURE(status)) { |
| 128 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | /* |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 132 | * Now we can parse the control methods. We always parse |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | * them here for a sanity check, and if configured for |
| 134 | * just-in-time parsing, we delete the control method |
| 135 | * parse trees. |
| 136 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 137 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Bob Moore | 22b5afc | 2014-03-24 14:49:00 +0800 | [diff] [blame] | 138 | "**** Begin Table Object Initialization\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
Lv Zheng | 8633db6 | 2016-10-26 15:42:01 +0800 | [diff] [blame] | 140 | acpi_ex_enter_interpreter(); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 141 | status = acpi_ds_initialize_objects(table_index, node); |
Lv Zheng | 8633db6 | 2016-10-26 15:42:01 +0800 | [diff] [blame] | 142 | acpi_ex_exit_interpreter(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 144 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Bob Moore | 22b5afc | 2014-03-24 14:49:00 +0800 | [diff] [blame] | 145 | "**** Completed Table Object Initialization\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Bob Moore | 2785ce8 | 2015-12-29 14:04:19 +0800 | [diff] [blame] | 147 | /* |
| 148 | * Execute any module-level code that was detected during the table load |
| 149 | * phase. Although illegal since ACPI 2.0, there are many machines that |
| 150 | * contain this type of code. Each block of detected executable AML code |
| 151 | * outside of any control method is wrapped with a temporary control |
| 152 | * method object and placed on a global list. The methods on this list |
| 153 | * are executed below. |
| 154 | * |
| 155 | * This case executes the module-level code for each table immediately |
| 156 | * after the table has been loaded. This provides compatibility with |
| 157 | * other ACPI implementations. Optionally, the execution can be deferred |
| 158 | * until later, see acpi_initialize_objects. |
| 159 | */ |
Lv Zheng | de56ba9 | 2016-09-07 14:06:54 +0800 | [diff] [blame] | 160 | if (!acpi_gbl_parse_table_as_term_list |
| 161 | && !acpi_gbl_group_module_level_code) { |
Bob Moore | 2785ce8 | 2015-12-29 14:04:19 +0800 | [diff] [blame] | 162 | acpi_ns_exec_module_code_list(); |
| 163 | } |
| 164 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 165 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 168 | #ifdef ACPI_OBSOLETE_FUNCTIONS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | /******************************************************************************* |
| 170 | * |
| 171 | * FUNCTION: acpi_load_namespace |
| 172 | * |
| 173 | * PARAMETERS: None |
| 174 | * |
| 175 | * RETURN: Status |
| 176 | * |
| 177 | * DESCRIPTION: Load the name space from what ever is pointed to by DSDT. |
| 178 | * (DSDT points to either the BIOS or a buffer.) |
| 179 | * |
| 180 | ******************************************************************************/ |
| 181 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 182 | acpi_status acpi_ns_load_namespace(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 184 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 186 | ACPI_FUNCTION_TRACE(acpi_load_name_space); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
| 188 | /* There must be at least a DSDT installed */ |
| 189 | |
| 190 | if (acpi_gbl_DSDT == NULL) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 191 | ACPI_ERROR((AE_INFO, "DSDT is not in memory")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 192 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | /* |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 196 | * Load the namespace. The DSDT is required, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | * but the SSDT and PSDT tables are optional. |
| 198 | */ |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 199 | status = acpi_ns_load_table_by_type(ACPI_TABLE_ID_DSDT); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 200 | if (ACPI_FAILURE(status)) { |
| 201 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | /* Ignore exceptions from these */ |
| 205 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 206 | (void)acpi_ns_load_table_by_type(ACPI_TABLE_ID_SSDT); |
| 207 | (void)acpi_ns_load_table_by_type(ACPI_TABLE_ID_PSDT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 209 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, |
| 210 | "ACPI Namespace successfully loaded at root %p\n", |
| 211 | acpi_gbl_root_node)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 215 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 217 | #ifdef ACPI_FUTURE_IMPLEMENTATION |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | /******************************************************************************* |
| 219 | * |
| 220 | * FUNCTION: acpi_ns_delete_subtree |
| 221 | * |
| 222 | * PARAMETERS: start_handle - Handle in namespace where search begins |
| 223 | * |
| 224 | * RETURNS Status |
| 225 | * |
| 226 | * DESCRIPTION: Walks the namespace starting at the given handle and deletes |
| 227 | * all objects, entries, and scopes in the entire subtree. |
| 228 | * |
| 229 | * Namespace/Interpreter should be locked or the subsystem should |
| 230 | * be in shutdown before this routine is called. |
| 231 | * |
| 232 | ******************************************************************************/ |
| 233 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 234 | static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 236 | acpi_status status; |
| 237 | acpi_handle child_handle; |
| 238 | acpi_handle parent_handle; |
| 239 | acpi_handle next_child_handle; |
| 240 | acpi_handle dummy; |
| 241 | u32 level; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 243 | ACPI_FUNCTION_TRACE(ns_delete_subtree); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | |
| 245 | parent_handle = start_handle; |
| 246 | child_handle = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 247 | level = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
| 249 | /* |
| 250 | * Traverse the tree of objects until we bubble back up |
| 251 | * to where we started. |
| 252 | */ |
| 253 | while (level > 0) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 254 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | /* Attempt to get the next object in this scope */ |
| 256 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 257 | status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle, |
| 258 | child_handle, &next_child_handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | |
| 260 | child_handle = next_child_handle; |
| 261 | |
| 262 | /* Did we get a new object? */ |
| 263 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 264 | if (ACPI_SUCCESS(status)) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | /* Check if this object has any children */ |
| 267 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 268 | if (ACPI_SUCCESS |
| 269 | (acpi_get_next_object |
| 270 | (ACPI_TYPE_ANY, child_handle, NULL, &dummy))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | /* |
| 272 | * There is at least one child of this object, |
| 273 | * visit the object |
| 274 | */ |
| 275 | level++; |
| 276 | parent_handle = child_handle; |
| 277 | child_handle = NULL; |
| 278 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 279 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | /* |
| 281 | * No more children in this object, go back up to |
| 282 | * the object's parent |
| 283 | */ |
| 284 | level--; |
| 285 | |
| 286 | /* Delete all children now */ |
| 287 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 288 | acpi_ns_delete_children(child_handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | |
| 290 | child_handle = parent_handle; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 291 | status = acpi_get_parent(parent_handle, &parent_handle); |
| 292 | if (ACPI_FAILURE(status)) { |
| 293 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | /* Now delete the starting object, and we are done */ |
| 299 | |
Bob Moore | 8e4319c | 2009-06-29 13:43:27 +0800 | [diff] [blame] | 300 | acpi_ns_remove_node(child_handle); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 301 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | /******************************************************************************* |
| 305 | * |
| 306 | * FUNCTION: acpi_ns_unload_name_space |
| 307 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 308 | * PARAMETERS: handle - Root of namespace subtree to be deleted |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | * |
| 310 | * RETURN: Status |
| 311 | * |
| 312 | * DESCRIPTION: Shrinks the namespace, typically in response to an undocking |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 313 | * event. Deletes an entire subtree starting from (and |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | * including) the given handle. |
| 315 | * |
| 316 | ******************************************************************************/ |
| 317 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 318 | acpi_status acpi_ns_unload_namespace(acpi_handle handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 320 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 322 | ACPI_FUNCTION_TRACE(ns_unload_name_space); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | |
| 324 | /* Parameter validation */ |
| 325 | |
| 326 | if (!acpi_gbl_root_node) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 327 | return_ACPI_STATUS(AE_NO_NAMESPACE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | if (!handle) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 331 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | /* This function does the real work */ |
| 335 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 336 | status = acpi_ns_delete_subtree(handle); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 337 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 339 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | #endif |