aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2013-07-13 17:27:26 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-22 22:00:25 -0400
commitad21d2d046a8a6bbf1b10c04770ec835a4e379e6 (patch)
tree79e2a6d6dfa85660cfd520e60c578859b3a1179d /drivers
parent07bb735378919e4b5863077f5c1b4037b6ca1a99 (diff)
ACPI / hotplug / PCI: Consolidate slot disabling and ejecting
Both acpiphp_disable_slot() and acpiphp_eject_slot() are always called together so instead of calling each separately we can consolidate them into one function acpiphp_disable_and_eject_slot() that does both (but it will return success on _EJ0 failures that were ignored in the majority of call sites anyway). [rjw: Rebased plus minor tweaks] Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/hotplug/acpiphp.h3
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c6
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c50
3 files changed, 20 insertions, 39 deletions
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 7d3251d2f4ad..fe6c79bb8eed 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -188,8 +188,7 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
188typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); 188typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
189 189
190int acpiphp_enable_slot(struct acpiphp_slot *slot); 190int acpiphp_enable_slot(struct acpiphp_slot *slot);
191int acpiphp_disable_slot(struct acpiphp_slot *slot); 191int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot);
192int acpiphp_eject_slot(struct acpiphp_slot *slot);
193u8 acpiphp_get_power_status(struct acpiphp_slot *slot); 192u8 acpiphp_get_power_status(struct acpiphp_slot *slot);
194u8 acpiphp_get_attention_status(struct acpiphp_slot *slot); 193u8 acpiphp_get_attention_status(struct acpiphp_slot *slot);
195u8 acpiphp_get_latch_status(struct acpiphp_slot *slot); 194u8 acpiphp_get_latch_status(struct acpiphp_slot *slot);
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 8f20e6021611..bf2203ef1308 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -155,15 +155,11 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
155static int disable_slot(struct hotplug_slot *hotplug_slot) 155static int disable_slot(struct hotplug_slot *hotplug_slot)
156{ 156{
157 struct slot *slot = hotplug_slot->private; 157 struct slot *slot = hotplug_slot->private;
158 int retval;
159 158
160 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 159 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
161 160
162 /* disable the specified slot */ 161 /* disable the specified slot */
163 retval = acpiphp_disable_slot(slot->acpi_slot); 162 return acpiphp_disable_and_eject_slot(slot->acpi_slot);
164 if (!retval)
165 retval = acpiphp_eject_slot(slot->acpi_slot);
166 return retval;
167} 163}
168 164
169 165
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index f131512b7bba..6db790ebd1eb 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -765,27 +765,6 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot)
765} 765}
766 766
767/** 767/**
768 * acpiphp_eject_slot - physically eject the slot
769 * @slot: ACPI PHP slot
770 */
771int acpiphp_eject_slot(struct acpiphp_slot *slot)
772{
773 struct acpiphp_func *func;
774
775 list_for_each_entry(func, &slot->funcs, sibling) {
776 /* We don't want to call _EJ0 on non-existing functions. */
777 if (!(func->flags & FUNC_HAS_EJ0))
778 continue;
779
780 if (ACPI_FAILURE(acpi_evaluate_ej0(func_to_handle(func))))
781 return -1;
782 else
783 break;
784 }
785 return 0;
786}
787
788/**
789 * acpiphp_check_bridge - re-enumerate devices 768 * acpiphp_check_bridge - re-enumerate devices
790 * @bridge: where to begin re-enumeration 769 * @bridge: where to begin re-enumeration
791 * 770 *
@@ -805,13 +784,11 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
805 if (slot->flags & SLOT_ENABLED) { 784 if (slot->flags & SLOT_ENABLED) {
806 if (status == ACPI_STA_ALL) 785 if (status == ACPI_STA_ALL)
807 continue; 786 continue;
808 retval = acpiphp_disable_slot(slot); 787
809 if (retval) { 788 retval = acpiphp_disable_and_eject_slot(slot);
810 err("Error occurred in disabling\n"); 789 if (retval)
811 goto err_exit; 790 goto err_exit;
812 } else { 791
813 acpiphp_eject_slot(slot);
814 }
815 disabled++; 792 disabled++;
816 } else { 793 } else {
817 if (status != ACPI_STA_ALL) 794 if (status != ACPI_STA_ALL)
@@ -951,9 +928,7 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
951 case ACPI_NOTIFY_EJECT_REQUEST: 928 case ACPI_NOTIFY_EJECT_REQUEST:
952 /* request device eject */ 929 /* request device eject */
953 dbg("%s: Device eject notify on %s\n", __func__, objname); 930 dbg("%s: Device eject notify on %s\n", __func__, objname);
954 if (!(acpiphp_disable_slot(func->slot))) 931 acpiphp_disable_and_eject_slot(func->slot);
955 acpiphp_eject_slot(func->slot);
956
957 break; 932 break;
958 933
959 case ACPI_NOTIFY_FREQUENCY_MISMATCH: 934 case ACPI_NOTIFY_FREQUENCY_MISMATCH:
@@ -1148,11 +1123,12 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
1148} 1123}
1149 1124
1150/** 1125/**
1151 * acpiphp_disable_slot - power off slot 1126 * acpiphp_disable_and_eject_slot - power off and eject slot
1152 * @slot: ACPI PHP slot 1127 * @slot: ACPI PHP slot
1153 */ 1128 */
1154int acpiphp_disable_slot(struct acpiphp_slot *slot) 1129int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
1155{ 1130{
1131 struct acpiphp_func *func;
1156 int retval = 0; 1132 int retval = 0;
1157 1133
1158 mutex_lock(&slot->crit_sect); 1134 mutex_lock(&slot->crit_sect);
@@ -1167,6 +1143,16 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot)
1167 if (retval) 1143 if (retval)
1168 goto err_exit; 1144 goto err_exit;
1169 1145
1146 list_for_each_entry(func, &slot->funcs, sibling)
1147 if (func->flags & FUNC_HAS_EJ0) {
1148 acpi_handle handle = func_to_handle(func);
1149
1150 if (ACPI_FAILURE(acpi_evaluate_ej0(handle)))
1151 acpi_handle_err(handle, "_EJ0 failed\n");
1152
1153 break;
1154 }
1155
1170 err_exit: 1156 err_exit:
1171 mutex_unlock(&slot->crit_sect); 1157 mutex_unlock(&slot->crit_sect);
1172 return retval; 1158 return retval;