diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-07-13 17:27:25 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-07-22 22:00:23 -0400 |
commit | 5a3bc573ae32a71bb9e307812d4de1bdcab6b9fb (patch) | |
tree | a0d437fdef258deae5c45cf6430d1df7385a9f6d /drivers/pci/hotplug/acpiphp_glue.c | |
parent | bd4674dfc5fc704837148f36af41e1e0a640dfec (diff) |
ACPI / hotplug / PCI: Drop handle field from struct acpiphp_func
The ACPI handle stored in struct acpiphp_func is also stored in the
struct acpiphp_context object containing it and it is trivial to get
from a struct acpiphp_func pointer to the handle field of the outer
struct acpiphp_context.
Hence, the handle field of struct acpiphp_func is redundant, so drop
it and provide a helper function, func_to_handle(), allowing it
users to get the ACPI handle for the given struct acpiphp_func
pointer.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/pci/hotplug/acpiphp_glue.c')
-rw-r--r-- | drivers/pci/hotplug/acpiphp_glue.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index cc7453e0722e..9e4ad6f37647 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -293,7 +293,6 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data, | |||
293 | return AE_NOT_EXIST; | 293 | return AE_NOT_EXIST; |
294 | } | 294 | } |
295 | newfunc = &context->func; | 295 | newfunc = &context->func; |
296 | newfunc->handle = handle; | ||
297 | newfunc->function = function; | 296 | newfunc->function = function; |
298 | mutex_unlock(&acpiphp_context_lock); | 297 | mutex_unlock(&acpiphp_context_lock); |
299 | 298 | ||
@@ -425,11 +424,13 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) | |||
425 | 424 | ||
426 | list_for_each_entry(slot, &bridge->slots, node) { | 425 | list_for_each_entry(slot, &bridge->slots, node) { |
427 | list_for_each_entry(func, &slot->funcs, sibling) { | 426 | list_for_each_entry(func, &slot->funcs, sibling) { |
428 | if (is_dock_device(func->handle)) { | 427 | acpi_handle handle = func_to_handle(func); |
429 | unregister_hotplug_dock_device(func->handle); | 428 | |
430 | } | 429 | if (is_dock_device(handle)) |
430 | unregister_hotplug_dock_device(handle); | ||
431 | |||
431 | if (!(func->flags & FUNC_HAS_DCK)) { | 432 | if (!(func->flags & FUNC_HAS_DCK)) { |
432 | status = acpi_remove_notify_handler(func->handle, | 433 | status = acpi_remove_notify_handler(handle, |
433 | ACPI_SYSTEM_NOTIFY, | 434 | ACPI_SYSTEM_NOTIFY, |
434 | handle_hotplug_event); | 435 | handle_hotplug_event); |
435 | if (ACPI_FAILURE(status)) | 436 | if (ACPI_FAILURE(status)) |
@@ -457,7 +458,8 @@ static int power_on_slot(struct acpiphp_slot *slot) | |||
457 | list_for_each_entry(func, &slot->funcs, sibling) { | 458 | list_for_each_entry(func, &slot->funcs, sibling) { |
458 | if (func->flags & FUNC_HAS_PS0) { | 459 | if (func->flags & FUNC_HAS_PS0) { |
459 | dbg("%s: executing _PS0\n", __func__); | 460 | dbg("%s: executing _PS0\n", __func__); |
460 | status = acpi_evaluate_object(func->handle, "_PS0", NULL, NULL); | 461 | status = acpi_evaluate_object(func_to_handle(func), |
462 | "_PS0", NULL, NULL); | ||
461 | if (ACPI_FAILURE(status)) { | 463 | if (ACPI_FAILURE(status)) { |
462 | warn("%s: _PS0 failed\n", __func__); | 464 | warn("%s: _PS0 failed\n", __func__); |
463 | retval = -1; | 465 | retval = -1; |
@@ -489,7 +491,8 @@ static int power_off_slot(struct acpiphp_slot *slot) | |||
489 | 491 | ||
490 | list_for_each_entry(func, &slot->funcs, sibling) { | 492 | list_for_each_entry(func, &slot->funcs, sibling) { |
491 | if (func->flags & FUNC_HAS_PS3) { | 493 | if (func->flags & FUNC_HAS_PS3) { |
492 | status = acpi_evaluate_object(func->handle, "_PS3", NULL, NULL); | 494 | status = acpi_evaluate_object(func_to_handle(func), |
495 | "_PS3", NULL, NULL); | ||
493 | if (ACPI_FAILURE(status)) { | 496 | if (ACPI_FAILURE(status)) { |
494 | warn("%s: _PS3 failed\n", __func__); | 497 | warn("%s: _PS3 failed\n", __func__); |
495 | retval = -1; | 498 | retval = -1; |
@@ -543,10 +546,11 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus) | |||
543 | */ | 546 | */ |
544 | static int acpiphp_bus_add(struct acpiphp_func *func) | 547 | static int acpiphp_bus_add(struct acpiphp_func *func) |
545 | { | 548 | { |
549 | acpi_handle handle = func_to_handle(func); | ||
546 | struct acpi_device *device; | 550 | struct acpi_device *device; |
547 | int ret_val; | 551 | int ret_val; |
548 | 552 | ||
549 | if (!acpi_bus_get_device(func->handle, &device)) { | 553 | if (!acpi_bus_get_device(handle, &device)) { |
550 | dbg("bus exists... trim\n"); | 554 | dbg("bus exists... trim\n"); |
551 | /* this shouldn't be in here, so remove | 555 | /* this shouldn't be in here, so remove |
552 | * the bus then re-add it... | 556 | * the bus then re-add it... |
@@ -554,9 +558,9 @@ static int acpiphp_bus_add(struct acpiphp_func *func) | |||
554 | acpi_bus_trim(device); | 558 | acpi_bus_trim(device); |
555 | } | 559 | } |
556 | 560 | ||
557 | ret_val = acpi_bus_scan(func->handle); | 561 | ret_val = acpi_bus_scan(handle); |
558 | if (!ret_val) | 562 | if (!ret_val) |
559 | ret_val = acpi_bus_get_device(func->handle, &device); | 563 | ret_val = acpi_bus_get_device(handle, &device); |
560 | 564 | ||
561 | if (ret_val) | 565 | if (ret_val) |
562 | dbg("error adding bus, %x\n", -ret_val); | 566 | dbg("error adding bus, %x\n", -ret_val); |
@@ -598,7 +602,8 @@ static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) | |||
598 | params[1].type = ACPI_TYPE_INTEGER; | 602 | params[1].type = ACPI_TYPE_INTEGER; |
599 | params[1].integer.value = 1; | 603 | params[1].integer.value = 1; |
600 | /* _REG is optional, we don't care about if there is failure */ | 604 | /* _REG is optional, we don't care about if there is failure */ |
601 | acpi_evaluate_object(func->handle, "_REG", &arg_list, NULL); | 605 | acpi_evaluate_object(func_to_handle(func), "_REG", &arg_list, |
606 | NULL); | ||
602 | } | 607 | } |
603 | } | 608 | } |
604 | 609 | ||
@@ -739,9 +744,8 @@ static int disable_device(struct acpiphp_slot *slot) | |||
739 | pci_dev_put(pdev); | 744 | pci_dev_put(pdev); |
740 | } | 745 | } |
741 | 746 | ||
742 | list_for_each_entry(func, &slot->funcs, sibling) { | 747 | list_for_each_entry(func, &slot->funcs, sibling) |
743 | acpiphp_bus_trim(func->handle); | 748 | acpiphp_bus_trim(func_to_handle(func)); |
744 | } | ||
745 | 749 | ||
746 | slot->flags &= (~SLOT_ENABLED); | 750 | slot->flags &= (~SLOT_ENABLED); |
747 | 751 | ||
@@ -763,17 +767,20 @@ static int disable_device(struct acpiphp_slot *slot) | |||
763 | */ | 767 | */ |
764 | static unsigned int get_slot_status(struct acpiphp_slot *slot) | 768 | static unsigned int get_slot_status(struct acpiphp_slot *slot) |
765 | { | 769 | { |
766 | acpi_status status; | ||
767 | unsigned long long sta = 0; | 770 | unsigned long long sta = 0; |
768 | u32 dvid; | ||
769 | struct acpiphp_func *func; | 771 | struct acpiphp_func *func; |
770 | 772 | ||
771 | list_for_each_entry(func, &slot->funcs, sibling) { | 773 | list_for_each_entry(func, &slot->funcs, sibling) { |
772 | if (func->flags & FUNC_HAS_STA) { | 774 | if (func->flags & FUNC_HAS_STA) { |
773 | status = acpi_evaluate_integer(func->handle, "_STA", NULL, &sta); | 775 | acpi_status status; |
776 | |||
777 | status = acpi_evaluate_integer(func_to_handle(func), | ||
778 | "_STA", NULL, &sta); | ||
774 | if (ACPI_SUCCESS(status) && sta) | 779 | if (ACPI_SUCCESS(status) && sta) |
775 | break; | 780 | break; |
776 | } else { | 781 | } else { |
782 | u32 dvid; | ||
783 | |||
777 | pci_bus_read_config_dword(slot->bridge->pci_bus, | 784 | pci_bus_read_config_dword(slot->bridge->pci_bus, |
778 | PCI_DEVFN(slot->device, | 785 | PCI_DEVFN(slot->device, |
779 | func->function), | 786 | func->function), |
@@ -798,12 +805,13 @@ int acpiphp_eject_slot(struct acpiphp_slot *slot) | |||
798 | 805 | ||
799 | list_for_each_entry(func, &slot->funcs, sibling) { | 806 | list_for_each_entry(func, &slot->funcs, sibling) { |
800 | /* We don't want to call _EJ0 on non-existing functions. */ | 807 | /* We don't want to call _EJ0 on non-existing functions. */ |
801 | if ((func->flags & FUNC_HAS_EJ0)) { | 808 | if (!(func->flags & FUNC_HAS_EJ0)) |
802 | if (ACPI_FAILURE(acpi_evaluate_ej0(func->handle))) | 809 | continue; |
803 | return -1; | 810 | |
804 | else | 811 | if (ACPI_FAILURE(acpi_evaluate_ej0(func_to_handle(func)))) |
805 | break; | 812 | return -1; |
806 | } | 813 | else |
814 | break; | ||
807 | } | 815 | } |
808 | return 0; | 816 | return 0; |
809 | } | 817 | } |