diff options
Diffstat (limited to 'drivers/acpi/tables/tbget.c')
-rw-r--r-- | drivers/acpi/tables/tbget.c | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c index 3a4f46ca3884..99eacceff563 100644 --- a/drivers/acpi/tables/tbget.c +++ b/drivers/acpi/tables/tbget.c | |||
@@ -417,7 +417,7 @@ acpi_tb_get_this_table(struct acpi_pointer *address, | |||
417 | * | 417 | * |
418 | * PARAMETERS: table_type - one of the defined table types | 418 | * PARAMETERS: table_type - one of the defined table types |
419 | * Instance - Which table of this type | 419 | * Instance - Which table of this type |
420 | * table_ptr_loc - pointer to location to place the pointer for | 420 | * return_table - pointer to location to place the pointer for |
421 | * return | 421 | * return |
422 | * | 422 | * |
423 | * RETURN: Status | 423 | * RETURN: Status |
@@ -428,58 +428,34 @@ acpi_tb_get_this_table(struct acpi_pointer *address, | |||
428 | 428 | ||
429 | acpi_status | 429 | acpi_status |
430 | acpi_tb_get_table_ptr(acpi_table_type table_type, | 430 | acpi_tb_get_table_ptr(acpi_table_type table_type, |
431 | u32 instance, struct acpi_table_header **table_ptr_loc) | 431 | u32 instance, struct acpi_table_header **return_table) |
432 | { | 432 | { |
433 | struct acpi_table_desc *table_desc; | 433 | struct acpi_table_desc *table_desc; |
434 | u32 i; | 434 | u32 i; |
435 | 435 | ||
436 | ACPI_FUNCTION_TRACE(tb_get_table_ptr); | 436 | ACPI_FUNCTION_TRACE(tb_get_table_ptr); |
437 | 437 | ||
438 | if (!acpi_gbl_DSDT) { | ||
439 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); | ||
440 | } | ||
441 | |||
442 | if (table_type > ACPI_TABLE_ID_MAX) { | 438 | if (table_type > ACPI_TABLE_ID_MAX) { |
443 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 439 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
444 | } | 440 | } |
445 | 441 | ||
446 | /* | 442 | /* Check for instance out of range of the current table count */ |
447 | * For all table types (Single/Multiple), the first | ||
448 | * instance is always in the list head. | ||
449 | */ | ||
450 | if (instance == 1) { | ||
451 | |||
452 | /* Get the first */ | ||
453 | |||
454 | *table_ptr_loc = NULL; | ||
455 | if (acpi_gbl_table_lists[table_type].next) { | ||
456 | *table_ptr_loc = | ||
457 | acpi_gbl_table_lists[table_type].next->pointer; | ||
458 | } | ||
459 | return_ACPI_STATUS(AE_OK); | ||
460 | } | ||
461 | |||
462 | /* Check for instance out of range */ | ||
463 | 443 | ||
464 | if (instance > acpi_gbl_table_lists[table_type].count) { | 444 | if (instance > acpi_gbl_table_lists[table_type].count) { |
465 | return_ACPI_STATUS(AE_NOT_EXIST); | 445 | return_ACPI_STATUS(AE_NOT_EXIST); |
466 | } | 446 | } |
467 | 447 | ||
468 | /* Walk the list to get the desired table | 448 | /* |
469 | * Since the if (Instance == 1) check above checked for the | 449 | * Walk the list to get the desired table |
470 | * first table, setting table_desc equal to the .Next member | 450 | * Note: Instance is one-based |
471 | * is actually pointing to the second table. Therefore, we | ||
472 | * need to walk from the 2nd table until we reach the Instance | ||
473 | * that the user is looking for and return its table pointer. | ||
474 | */ | 451 | */ |
475 | table_desc = acpi_gbl_table_lists[table_type].next; | 452 | table_desc = acpi_gbl_table_lists[table_type].next; |
476 | for (i = 2; i < instance; i++) { | 453 | for (i = 1; i < instance; i++) { |
477 | table_desc = table_desc->next; | 454 | table_desc = table_desc->next; |
478 | } | 455 | } |
479 | 456 | ||
480 | /* We are now pointing to the requested table's descriptor */ | 457 | /* We are now pointing to the requested table's descriptor */ |
481 | 458 | ||
482 | *table_ptr_loc = table_desc->pointer; | 459 | *return_table = table_desc->pointer; |
483 | |||
484 | return_ACPI_STATUS(AE_OK); | 460 | return_ACPI_STATUS(AE_OK); |
485 | } | 461 | } |