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>
This commit is contained in:

committed by
Rafael J. Wysocki

parent
07bb735378
commit
ad21d2d046
@@ -188,8 +188,7 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
|
|||||||
typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
|
typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
|
||||||
|
|
||||||
int acpiphp_enable_slot(struct acpiphp_slot *slot);
|
int acpiphp_enable_slot(struct acpiphp_slot *slot);
|
||||||
int acpiphp_disable_slot(struct acpiphp_slot *slot);
|
int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot);
|
||||||
int acpiphp_eject_slot(struct acpiphp_slot *slot);
|
|
||||||
u8 acpiphp_get_power_status(struct acpiphp_slot *slot);
|
u8 acpiphp_get_power_status(struct acpiphp_slot *slot);
|
||||||
u8 acpiphp_get_attention_status(struct acpiphp_slot *slot);
|
u8 acpiphp_get_attention_status(struct acpiphp_slot *slot);
|
||||||
u8 acpiphp_get_latch_status(struct acpiphp_slot *slot);
|
u8 acpiphp_get_latch_status(struct acpiphp_slot *slot);
|
||||||
|
@@ -155,15 +155,11 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
|
|||||||
static int disable_slot(struct hotplug_slot *hotplug_slot)
|
static int disable_slot(struct hotplug_slot *hotplug_slot)
|
||||||
{
|
{
|
||||||
struct slot *slot = hotplug_slot->private;
|
struct slot *slot = hotplug_slot->private;
|
||||||
int retval;
|
|
||||||
|
|
||||||
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
|
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
|
||||||
|
|
||||||
/* disable the specified slot */
|
/* disable the specified slot */
|
||||||
retval = acpiphp_disable_slot(slot->acpi_slot);
|
return acpiphp_disable_and_eject_slot(slot->acpi_slot);
|
||||||
if (!retval)
|
|
||||||
retval = acpiphp_eject_slot(slot->acpi_slot);
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -764,27 +764,6 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot)
|
|||||||
return (unsigned int)sta;
|
return (unsigned int)sta;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* acpiphp_eject_slot - physically eject the slot
|
|
||||||
* @slot: ACPI PHP slot
|
|
||||||
*/
|
|
||||||
int acpiphp_eject_slot(struct acpiphp_slot *slot)
|
|
||||||
{
|
|
||||||
struct acpiphp_func *func;
|
|
||||||
|
|
||||||
list_for_each_entry(func, &slot->funcs, sibling) {
|
|
||||||
/* We don't want to call _EJ0 on non-existing functions. */
|
|
||||||
if (!(func->flags & FUNC_HAS_EJ0))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (ACPI_FAILURE(acpi_evaluate_ej0(func_to_handle(func))))
|
|
||||||
return -1;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acpiphp_check_bridge - re-enumerate devices
|
* acpiphp_check_bridge - re-enumerate devices
|
||||||
* @bridge: where to begin re-enumeration
|
* @bridge: where to begin re-enumeration
|
||||||
@@ -805,13 +784,11 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
|
|||||||
if (slot->flags & SLOT_ENABLED) {
|
if (slot->flags & SLOT_ENABLED) {
|
||||||
if (status == ACPI_STA_ALL)
|
if (status == ACPI_STA_ALL)
|
||||||
continue;
|
continue;
|
||||||
retval = acpiphp_disable_slot(slot);
|
|
||||||
if (retval) {
|
retval = acpiphp_disable_and_eject_slot(slot);
|
||||||
err("Error occurred in disabling\n");
|
if (retval)
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
} else {
|
|
||||||
acpiphp_eject_slot(slot);
|
|
||||||
}
|
|
||||||
disabled++;
|
disabled++;
|
||||||
} else {
|
} else {
|
||||||
if (status != ACPI_STA_ALL)
|
if (status != ACPI_STA_ALL)
|
||||||
@@ -951,9 +928,7 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
|
|||||||
case ACPI_NOTIFY_EJECT_REQUEST:
|
case ACPI_NOTIFY_EJECT_REQUEST:
|
||||||
/* request device eject */
|
/* request device eject */
|
||||||
dbg("%s: Device eject notify on %s\n", __func__, objname);
|
dbg("%s: Device eject notify on %s\n", __func__, objname);
|
||||||
if (!(acpiphp_disable_slot(func->slot)))
|
acpiphp_disable_and_eject_slot(func->slot);
|
||||||
acpiphp_eject_slot(func->slot);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACPI_NOTIFY_FREQUENCY_MISMATCH:
|
case ACPI_NOTIFY_FREQUENCY_MISMATCH:
|
||||||
@@ -1148,11 +1123,12 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acpiphp_disable_slot - power off slot
|
* acpiphp_disable_and_eject_slot - power off and eject slot
|
||||||
* @slot: ACPI PHP slot
|
* @slot: ACPI PHP slot
|
||||||
*/
|
*/
|
||||||
int acpiphp_disable_slot(struct acpiphp_slot *slot)
|
int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
|
||||||
{
|
{
|
||||||
|
struct acpiphp_func *func;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
mutex_lock(&slot->crit_sect);
|
mutex_lock(&slot->crit_sect);
|
||||||
@@ -1167,6 +1143,16 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot)
|
|||||||
if (retval)
|
if (retval)
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
|
|
||||||
|
list_for_each_entry(func, &slot->funcs, sibling)
|
||||||
|
if (func->flags & FUNC_HAS_EJ0) {
|
||||||
|
acpi_handle handle = func_to_handle(func);
|
||||||
|
|
||||||
|
if (ACPI_FAILURE(acpi_evaluate_ej0(handle)))
|
||||||
|
acpi_handle_err(handle, "_EJ0 failed\n");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
err_exit:
|
err_exit:
|
||||||
mutex_unlock(&slot->crit_sect);
|
mutex_unlock(&slot->crit_sect);
|
||||||
return retval;
|
return retval;
|
||||||
|
Reference in New Issue
Block a user