diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-02-03 15:54:48 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-02-03 15:54:48 -0500 |
commit | d2cecb3d66e39765f3dec8adfb88c322e709b06d (patch) | |
tree | e0f81ce37c0dab193dce3d0113044d334cd6d489 | |
parent | 2a7383529109252a7f9d81639784e5fddb4f3df4 (diff) |
ACPI / cpuidle: Merge acpi_idle_enter_c1() and acpi_idle_enter_simple()
acpi_idle_enter_c1() and acpi_idle_enter_simple() are close enough to
each other that they can be merged into one function which reduces
duplication of code quite a bit.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/processor_idle.c | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index eaa32586f89c..58113a6fa1d3 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -704,34 +704,6 @@ static void acpi_idle_do_entry(struct acpi_processor_cx *cx) | |||
704 | } | 704 | } |
705 | 705 | ||
706 | /** | 706 | /** |
707 | * acpi_idle_enter_c1 - enters an ACPI C1 state-type | ||
708 | * @dev: the target CPU | ||
709 | * @drv: cpuidle driver containing cpuidle state info | ||
710 | * @index: index of target state | ||
711 | * | ||
712 | * This is equivalent to the HALT instruction. | ||
713 | */ | ||
714 | static int acpi_idle_enter_c1(struct cpuidle_device *dev, | ||
715 | struct cpuidle_driver *drv, int index) | ||
716 | { | ||
717 | struct acpi_processor *pr; | ||
718 | struct acpi_processor_cx *cx = per_cpu(acpi_cstate[index], dev->cpu); | ||
719 | |||
720 | pr = __this_cpu_read(processors); | ||
721 | |||
722 | if (unlikely(!pr)) | ||
723 | return -EINVAL; | ||
724 | |||
725 | lapic_timer_state_broadcast(pr, cx, 1); | ||
726 | acpi_idle_do_entry(cx); | ||
727 | |||
728 | lapic_timer_state_broadcast(pr, cx, 0); | ||
729 | |||
730 | return index; | ||
731 | } | ||
732 | |||
733 | |||
734 | /** | ||
735 | * acpi_idle_play_dead - enters an ACPI state for long-term idle (i.e. off-lining) | 707 | * acpi_idle_play_dead - enters an ACPI state for long-term idle (i.e. off-lining) |
736 | * @dev: the target CPU | 708 | * @dev: the target CPU |
737 | * @index: the index of suggested state | 709 | * @index: the index of suggested state |
@@ -766,7 +738,7 @@ static bool acpi_idle_fallback_to_c1(struct acpi_processor *pr) | |||
766 | } | 738 | } |
767 | 739 | ||
768 | /** | 740 | /** |
769 | * acpi_idle_enter_simple - enters an ACPI state without BM handling | 741 | * acpi_idle_enter_simple - enters a CPU idle state without BM handling |
770 | * @dev: the target CPU | 742 | * @dev: the target CPU |
771 | * @drv: cpuidle driver with cpuidle state information | 743 | * @drv: cpuidle driver with cpuidle state information |
772 | * @index: the index of suggested state | 744 | * @index: the index of suggested state |
@@ -782,8 +754,10 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
782 | if (unlikely(!pr)) | 754 | if (unlikely(!pr)) |
783 | return -EINVAL; | 755 | return -EINVAL; |
784 | 756 | ||
785 | if (acpi_idle_fallback_to_c1(pr)) | 757 | if (cx->type != ACPI_STATE_C1 && acpi_idle_fallback_to_c1(pr)) { |
786 | return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START); | 758 | index = CPUIDLE_DRIVER_STATE_START; |
759 | cx = per_cpu(acpi_cstate[index], dev->cpu); | ||
760 | } | ||
787 | 761 | ||
788 | lapic_timer_state_broadcast(pr, cx, 1); | 762 | lapic_timer_state_broadcast(pr, cx, 1); |
789 | 763 | ||
@@ -819,7 +793,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
819 | return -EINVAL; | 793 | return -EINVAL; |
820 | 794 | ||
821 | if (acpi_idle_fallback_to_c1(pr)) | 795 | if (acpi_idle_fallback_to_c1(pr)) |
822 | return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START); | 796 | return acpi_idle_enter_simple(dev, drv, CPUIDLE_DRIVER_STATE_START); |
823 | 797 | ||
824 | if (!cx->bm_sts_skip && acpi_idle_bm_check()) { | 798 | if (!cx->bm_sts_skip && acpi_idle_bm_check()) { |
825 | if (drv->safe_state_index >= 0) { | 799 | if (drv->safe_state_index >= 0) { |
@@ -967,11 +941,6 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr) | |||
967 | switch (cx->type) { | 941 | switch (cx->type) { |
968 | 942 | ||
969 | case ACPI_STATE_C1: | 943 | case ACPI_STATE_C1: |
970 | state->enter = acpi_idle_enter_c1; | ||
971 | state->enter_dead = acpi_idle_play_dead; | ||
972 | drv->safe_state_index = count; | ||
973 | break; | ||
974 | |||
975 | case ACPI_STATE_C2: | 944 | case ACPI_STATE_C2: |
976 | state->enter = acpi_idle_enter_simple; | 945 | state->enter = acpi_idle_enter_simple; |
977 | state->enter_dead = acpi_idle_play_dead; | 946 | state->enter_dead = acpi_idle_play_dead; |