aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace/nsobject.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/namespace/nsobject.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/namespace/nsobject.c')
-rw-r--r--drivers/acpi/namespace/nsobject.c209
1 files changed, 90 insertions, 119 deletions
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
index 27258c1ca4f1..fc9be946ebed 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/namespace/nsobject.c
@@ -42,14 +42,11 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsobject") 49ACPI_MODULE_NAME("nsobject")
52
53 50
54/******************************************************************************* 51/*******************************************************************************
55 * 52 *
@@ -71,20 +68,15 @@
71 * MUTEX: Assumes namespace is locked 68 * MUTEX: Assumes namespace is locked
72 * 69 *
73 ******************************************************************************/ 70 ******************************************************************************/
74
75acpi_status 71acpi_status
76acpi_ns_attach_object ( 72acpi_ns_attach_object(struct acpi_namespace_node *node,
77 struct acpi_namespace_node *node, 73 union acpi_operand_object *object, acpi_object_type type)
78 union acpi_operand_object *object,
79 acpi_object_type type)
80{ 74{
81 union acpi_operand_object *obj_desc; 75 union acpi_operand_object *obj_desc;
82 union acpi_operand_object *last_obj_desc; 76 union acpi_operand_object *last_obj_desc;
83 acpi_object_type object_type = ACPI_TYPE_ANY; 77 acpi_object_type object_type = ACPI_TYPE_ANY;
84
85
86 ACPI_FUNCTION_TRACE ("ns_attach_object");
87 78
79 ACPI_FUNCTION_TRACE("ns_attach_object");
88 80
89 /* 81 /*
90 * Parameter validation 82 * Parameter validation
@@ -92,40 +84,39 @@ acpi_ns_attach_object (
92 if (!node) { 84 if (!node) {
93 /* Invalid handle */ 85 /* Invalid handle */
94 86
95 ACPI_REPORT_ERROR (("ns_attach_object: Null named_obj handle\n")); 87 ACPI_REPORT_ERROR(("ns_attach_object: Null named_obj handle\n"));
96 return_ACPI_STATUS (AE_BAD_PARAMETER); 88 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 89 }
98 90
99 if (!object && (ACPI_TYPE_ANY != type)) { 91 if (!object && (ACPI_TYPE_ANY != type)) {
100 /* Null object */ 92 /* Null object */
101 93
102 ACPI_REPORT_ERROR (( 94 ACPI_REPORT_ERROR(("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
103 "ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); 95 return_ACPI_STATUS(AE_BAD_PARAMETER);
104 return_ACPI_STATUS (AE_BAD_PARAMETER);
105 } 96 }
106 97
107 if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { 98 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
108 /* Not a name handle */ 99 /* Not a name handle */
109 100
110 ACPI_REPORT_ERROR (("ns_attach_object: Invalid handle %p [%s]\n", 101 ACPI_REPORT_ERROR(("ns_attach_object: Invalid handle %p [%s]\n",
111 node, acpi_ut_get_descriptor_name (node))); 102 node, acpi_ut_get_descriptor_name(node)));
112 return_ACPI_STATUS (AE_BAD_PARAMETER); 103 return_ACPI_STATUS(AE_BAD_PARAMETER);
113 } 104 }
114 105
115 /* Check if this object is already attached */ 106 /* Check if this object is already attached */
116 107
117 if (node->object == object) { 108 if (node->object == object) {
118 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 109 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
119 "Obj %p already installed in name_obj %p\n", 110 "Obj %p already installed in name_obj %p\n",
120 object, node)); 111 object, node));
121 112
122 return_ACPI_STATUS (AE_OK); 113 return_ACPI_STATUS(AE_OK);
123 } 114 }
124 115
125 /* If null object, we will just install it */ 116 /* If null object, we will just install it */
126 117
127 if (!object) { 118 if (!object) {
128 obj_desc = NULL; 119 obj_desc = NULL;
129 object_type = ACPI_TYPE_ANY; 120 object_type = ACPI_TYPE_ANY;
130 } 121 }
131 122
@@ -133,14 +124,14 @@ acpi_ns_attach_object (
133 * If the source object is a namespace Node with an attached object, 124 * If the source object is a namespace Node with an attached object,
134 * we will use that (attached) object 125 * we will use that (attached) object
135 */ 126 */
136 else if ((ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) && 127 else if ((ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) &&
137 ((struct acpi_namespace_node *) object)->object) { 128 ((struct acpi_namespace_node *)object)->object) {
138 /* 129 /*
139 * Value passed is a name handle and that name has a 130 * Value passed is a name handle and that name has a
140 * non-null value. Use that name's value and type. 131 * non-null value. Use that name's value and type.
141 */ 132 */
142 obj_desc = ((struct acpi_namespace_node *) object)->object; 133 obj_desc = ((struct acpi_namespace_node *)object)->object;
143 object_type = ((struct acpi_namespace_node *) object)->type; 134 object_type = ((struct acpi_namespace_node *)object)->type;
144 } 135 }
145 136
146 /* 137 /*
@@ -148,20 +139,20 @@ acpi_ns_attach_object (
148 * it first 139 * it first
149 */ 140 */
150 else { 141 else {
151 obj_desc = (union acpi_operand_object *) object; 142 obj_desc = (union acpi_operand_object *)object;
152 143
153 /* Use the given type */ 144 /* Use the given type */
154 145
155 object_type = type; 146 object_type = type;
156 } 147 }
157 148
158 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", 149 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
159 obj_desc, node, acpi_ut_get_node_name (node))); 150 obj_desc, node, acpi_ut_get_node_name(node)));
160 151
161 /* Detach an existing attached object if present */ 152 /* Detach an existing attached object if present */
162 153
163 if (node->object) { 154 if (node->object) {
164 acpi_ns_detach_object (node); 155 acpi_ns_detach_object(node);
165 } 156 }
166 157
167 if (obj_desc) { 158 if (obj_desc) {
@@ -169,7 +160,7 @@ acpi_ns_attach_object (
169 * Must increment the new value's reference count 160 * Must increment the new value's reference count
170 * (if it is an internal object) 161 * (if it is an internal object)
171 */ 162 */
172 acpi_ut_add_reference (obj_desc); 163 acpi_ut_add_reference(obj_desc);
173 164
174 /* 165 /*
175 * Handle objects with multiple descriptors - walk 166 * Handle objects with multiple descriptors - walk
@@ -185,13 +176,12 @@ acpi_ns_attach_object (
185 last_obj_desc->common.next_object = node->object; 176 last_obj_desc->common.next_object = node->object;
186 } 177 }
187 178
188 node->type = (u8) object_type; 179 node->type = (u8) object_type;
189 node->object = obj_desc; 180 node->object = obj_desc;
190 181
191 return_ACPI_STATUS (AE_OK); 182 return_ACPI_STATUS(AE_OK);
192} 183}
193 184
194
195/******************************************************************************* 185/*******************************************************************************
196 * 186 *
197 * FUNCTION: acpi_ns_detach_object 187 * FUNCTION: acpi_ns_detach_object
@@ -206,30 +196,27 @@ acpi_ns_attach_object (
206 * 196 *
207 ******************************************************************************/ 197 ******************************************************************************/
208 198
209void 199void acpi_ns_detach_object(struct acpi_namespace_node *node)
210acpi_ns_detach_object (
211 struct acpi_namespace_node *node)
212{ 200{
213 union acpi_operand_object *obj_desc; 201 union acpi_operand_object *obj_desc;
214
215
216 ACPI_FUNCTION_TRACE ("ns_detach_object");
217 202
203 ACPI_FUNCTION_TRACE("ns_detach_object");
218 204
219 obj_desc = node->object; 205 obj_desc = node->object;
220 206
221 if (!obj_desc || 207 if (!obj_desc ||
222 (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA)) { 208 (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA)) {
223 return_VOID; 209 return_VOID;
224 } 210 }
225 211
226 /* Clear the entry in all cases */ 212 /* Clear the entry in all cases */
227 213
228 node->object = NULL; 214 node->object = NULL;
229 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) { 215 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) {
230 node->object = obj_desc->common.next_object; 216 node->object = obj_desc->common.next_object;
231 if (node->object && 217 if (node->object &&
232 (ACPI_GET_OBJECT_TYPE (node->object) != ACPI_TYPE_LOCAL_DATA)) { 218 (ACPI_GET_OBJECT_TYPE(node->object) !=
219 ACPI_TYPE_LOCAL_DATA)) {
233 node->object = node->object->common.next_object; 220 node->object = node->object->common.next_object;
234 } 221 }
235 } 222 }
@@ -238,16 +225,15 @@ acpi_ns_detach_object (
238 225
239 node->type = ACPI_TYPE_ANY; 226 node->type = ACPI_TYPE_ANY;
240 227
241 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", 228 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
242 node, acpi_ut_get_node_name (node), obj_desc)); 229 node, acpi_ut_get_node_name(node), obj_desc));
243 230
244 /* Remove one reference on the object (and all subobjects) */ 231 /* Remove one reference on the object (and all subobjects) */
245 232
246 acpi_ut_remove_reference (obj_desc); 233 acpi_ut_remove_reference(obj_desc);
247 return_VOID; 234 return_VOID;
248} 235}
249 236
250
251/******************************************************************************* 237/*******************************************************************************
252 * 238 *
253 * FUNCTION: acpi_ns_get_attached_object 239 * FUNCTION: acpi_ns_get_attached_object
@@ -261,29 +247,28 @@ acpi_ns_detach_object (
261 * 247 *
262 ******************************************************************************/ 248 ******************************************************************************/
263 249
264union acpi_operand_object * 250union acpi_operand_object *acpi_ns_get_attached_object(struct
265acpi_ns_get_attached_object ( 251 acpi_namespace_node
266 struct acpi_namespace_node *node) 252 *node)
267{ 253{
268 ACPI_FUNCTION_TRACE_PTR ("ns_get_attached_object", node); 254 ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node);
269
270 255
271 if (!node) { 256 if (!node) {
272 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Null Node ptr\n")); 257 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Null Node ptr\n"));
273 return_PTR (NULL); 258 return_PTR(NULL);
274 } 259 }
275 260
276 if (!node->object || 261 if (!node->object ||
277 ((ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_OPERAND) && 262 ((ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_OPERAND)
278 (ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_NAMED)) || 263 && (ACPI_GET_DESCRIPTOR_TYPE(node->object) !=
279 (ACPI_GET_OBJECT_TYPE (node->object) == ACPI_TYPE_LOCAL_DATA)) { 264 ACPI_DESC_TYPE_NAMED))
280 return_PTR (NULL); 265 || (ACPI_GET_OBJECT_TYPE(node->object) == ACPI_TYPE_LOCAL_DATA)) {
266 return_PTR(NULL);
281 } 267 }
282 268
283 return_PTR (node->object); 269 return_PTR(node->object);
284} 270}
285 271
286
287/******************************************************************************* 272/*******************************************************************************
288 * 273 *
289 * FUNCTION: acpi_ns_get_secondary_object 274 * FUNCTION: acpi_ns_get_secondary_object
@@ -297,24 +282,23 @@ acpi_ns_get_attached_object (
297 * 282 *
298 ******************************************************************************/ 283 ******************************************************************************/
299 284
300union acpi_operand_object * 285union acpi_operand_object *acpi_ns_get_secondary_object(union
301acpi_ns_get_secondary_object ( 286 acpi_operand_object
302 union acpi_operand_object *obj_desc) 287 *obj_desc)
303{ 288{
304 ACPI_FUNCTION_TRACE_PTR ("ns_get_secondary_object", obj_desc); 289 ACPI_FUNCTION_TRACE_PTR("ns_get_secondary_object", obj_desc);
305 290
306 291 if ((!obj_desc) ||
307 if ((!obj_desc) || 292 (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) ||
308 (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) || 293 (!obj_desc->common.next_object) ||
309 (!obj_desc->common.next_object) || 294 (ACPI_GET_OBJECT_TYPE(obj_desc->common.next_object) ==
310 (ACPI_GET_OBJECT_TYPE (obj_desc->common.next_object) == ACPI_TYPE_LOCAL_DATA)) { 295 ACPI_TYPE_LOCAL_DATA)) {
311 return_PTR (NULL); 296 return_PTR(NULL);
312 } 297 }
313 298
314 return_PTR (obj_desc->common.next_object); 299 return_PTR(obj_desc->common.next_object);
315} 300}
316 301
317
318/******************************************************************************* 302/*******************************************************************************
319 * 303 *
320 * FUNCTION: acpi_ns_attach_data 304 * FUNCTION: acpi_ns_attach_data
@@ -330,23 +314,20 @@ acpi_ns_get_secondary_object (
330 ******************************************************************************/ 314 ******************************************************************************/
331 315
332acpi_status 316acpi_status
333acpi_ns_attach_data ( 317acpi_ns_attach_data(struct acpi_namespace_node *node,
334 struct acpi_namespace_node *node, 318 acpi_object_handler handler, void *data)
335 acpi_object_handler handler,
336 void *data)
337{ 319{
338 union acpi_operand_object *prev_obj_desc; 320 union acpi_operand_object *prev_obj_desc;
339 union acpi_operand_object *obj_desc; 321 union acpi_operand_object *obj_desc;
340 union acpi_operand_object *data_desc; 322 union acpi_operand_object *data_desc;
341
342 323
343 /* We only allow one attachment per handler */ 324 /* We only allow one attachment per handler */
344 325
345 prev_obj_desc = NULL; 326 prev_obj_desc = NULL;
346 obj_desc = node->object; 327 obj_desc = node->object;
347 while (obj_desc) { 328 while (obj_desc) {
348 if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && 329 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
349 (obj_desc->data.handler == handler)) { 330 (obj_desc->data.handler == handler)) {
350 return (AE_ALREADY_EXISTS); 331 return (AE_ALREADY_EXISTS);
351 } 332 }
352 333
@@ -356,7 +337,7 @@ acpi_ns_attach_data (
356 337
357 /* Create an internal object for the data */ 338 /* Create an internal object for the data */
358 339
359 data_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_DATA); 340 data_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_DATA);
360 if (!data_desc) { 341 if (!data_desc) {
361 return (AE_NO_MEMORY); 342 return (AE_NO_MEMORY);
362 } 343 }
@@ -368,15 +349,13 @@ acpi_ns_attach_data (
368 349
369 if (prev_obj_desc) { 350 if (prev_obj_desc) {
370 prev_obj_desc->common.next_object = data_desc; 351 prev_obj_desc->common.next_object = data_desc;
371 } 352 } else {
372 else {
373 node->object = data_desc; 353 node->object = data_desc;
374 } 354 }
375 355
376 return (AE_OK); 356 return (AE_OK);
377} 357}
378 358
379
380/******************************************************************************* 359/*******************************************************************************
381 * 360 *
382 * FUNCTION: acpi_ns_detach_data 361 * FUNCTION: acpi_ns_detach_data
@@ -392,27 +371,25 @@ acpi_ns_attach_data (
392 ******************************************************************************/ 371 ******************************************************************************/
393 372
394acpi_status 373acpi_status
395acpi_ns_detach_data ( 374acpi_ns_detach_data(struct acpi_namespace_node * node,
396 struct acpi_namespace_node *node, 375 acpi_object_handler handler)
397 acpi_object_handler handler)
398{ 376{
399 union acpi_operand_object *obj_desc; 377 union acpi_operand_object *obj_desc;
400 union acpi_operand_object *prev_obj_desc; 378 union acpi_operand_object *prev_obj_desc;
401
402 379
403 prev_obj_desc = NULL; 380 prev_obj_desc = NULL;
404 obj_desc = node->object; 381 obj_desc = node->object;
405 while (obj_desc) { 382 while (obj_desc) {
406 if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && 383 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
407 (obj_desc->data.handler == handler)) { 384 (obj_desc->data.handler == handler)) {
408 if (prev_obj_desc) { 385 if (prev_obj_desc) {
409 prev_obj_desc->common.next_object = obj_desc->common.next_object; 386 prev_obj_desc->common.next_object =
410 } 387 obj_desc->common.next_object;
411 else { 388 } else {
412 node->object = obj_desc->common.next_object; 389 node->object = obj_desc->common.next_object;
413 } 390 }
414 391
415 acpi_ut_remove_reference (obj_desc); 392 acpi_ut_remove_reference(obj_desc);
416 return (AE_OK); 393 return (AE_OK);
417 } 394 }
418 395
@@ -423,7 +400,6 @@ acpi_ns_detach_data (
423 return (AE_NOT_FOUND); 400 return (AE_NOT_FOUND);
424} 401}
425 402
426
427/******************************************************************************* 403/*******************************************************************************
428 * 404 *
429 * FUNCTION: acpi_ns_get_attached_data 405 * FUNCTION: acpi_ns_get_attached_data
@@ -440,18 +416,15 @@ acpi_ns_detach_data (
440 ******************************************************************************/ 416 ******************************************************************************/
441 417
442acpi_status 418acpi_status
443acpi_ns_get_attached_data ( 419acpi_ns_get_attached_data(struct acpi_namespace_node * node,
444 struct acpi_namespace_node *node, 420 acpi_object_handler handler, void **data)
445 acpi_object_handler handler,
446 void **data)
447{ 421{
448 union acpi_operand_object *obj_desc; 422 union acpi_operand_object *obj_desc;
449
450 423
451 obj_desc = node->object; 424 obj_desc = node->object;
452 while (obj_desc) { 425 while (obj_desc) {
453 if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && 426 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
454 (obj_desc->data.handler == handler)) { 427 (obj_desc->data.handler == handler)) {
455 *data = obj_desc->data.pointer; 428 *data = obj_desc->data.pointer;
456 return (AE_OK); 429 return (AE_OK);
457 } 430 }
@@ -461,5 +434,3 @@ acpi_ns_get_attached_data (
461 434
462 return (AE_NOT_FOUND); 435 return (AE_NOT_FOUND);
463} 436}
464
465