@@ -634,6 +634,86 @@ int acpihp_remove_device_list(struct klist *dev_list)
}
EXPORT_SYMBOL_GPL(acpihp_remove_device_list);
+bool acpihp_slot_present(struct acpihp_slot *slot)
+{
+ acpi_status status;
+ unsigned long long sta;
+
+ /* A hotplug slot must implement ACPI _STA method */
+ status = acpi_evaluate_integer(slot->handle,
+ METHOD_NAME__STA, NULL, &sta);
+ if (ACPI_FAILURE(status)) {
+ ACPIHP_WARN("fails to evaluate _STA for %p.\n", slot->name);
+ return false;
+ }
+
+ return !!(sta & ACPI_STA_DEVICE_PRESENT);
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_present);
+
+bool acpihp_slot_powered(struct acpihp_slot *slot)
+{
+ acpi_status status;
+ unsigned long long sta;
+
+ /* hotplug slot must implement _STA method */
+ status = acpi_evaluate_integer(slot->handle,
+ METHOD_NAME__STA, NULL, &sta);
+ if (ACPI_FAILURE(status)) {
+ ACPIHP_WARN("fails to evaluate _STA for %p.\n", slot->name);
+ return false;
+ }
+
+ if ((sta & ACPI_STA_DEVICE_PRESENT) &&
+ ((sta & ACPI_STA_DEVICE_ENABLED) ||
+ (sta & ACPI_STA_DEVICE_FUNCTIONING)))
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_powered);
+
+void acpihp_slot_set_flag(struct acpihp_slot *slot, u32 flags)
+{
+ mutex_lock(&slot->slot_mutex);
+ slot->flags |= flags;
+ mutex_unlock(&slot->slot_mutex);
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_set_flag);
+
+void acpihp_slot_clear_flag(struct acpihp_slot *slot, u32 flags)
+{
+ mutex_lock(&slot->slot_mutex);
+ slot->flags &= ~flags;
+ mutex_unlock(&slot->slot_mutex);
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_clear_flag);
+
+u32 acpihp_slot_get_flag(struct acpihp_slot *slot, u32 flags)
+{
+ mutex_lock(&slot->slot_mutex);
+ flags &= slot->flags;
+ mutex_unlock(&slot->slot_mutex);
+
+ return flags;
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_get_flag);
+
+void acpihp_slot_change_state(struct acpihp_slot *slot,
+ enum acpihp_slot_state state)
+{
+ if (state < ACPIHP_SLOT_STATE_UNKNOWN ||
+ state > ACPIHP_SLOT_STATE_MAX) {
+ ACPIHP_WARN("slot state %d is invalid.\n", state);
+ BUG_ON(state);
+ }
+
+ mutex_lock(&slot->slot_mutex);
+ slot->state = state;
+ mutex_unlock(&slot->slot_mutex);
+}
+EXPORT_SYMBOL_GPL(acpihp_slot_change_state);
+
/* SYSFS interfaces */
static ssize_t acpihp_slot_object_show(struct device *d,
struct device_attribute *attr, char *buf)
@@ -289,6 +289,15 @@ extern int acpihp_slot_remove_device(struct acpihp_slot *slot,
struct device *dev);
extern int acpihp_remove_device_list(struct klist *dev_list);
+/* Utility Functions */
+extern bool acpihp_slot_present(struct acpihp_slot *slot);
+extern bool acpihp_slot_powered(struct acpihp_slot *slot);
+extern void acpihp_slot_set_flag(struct acpihp_slot *slot, u32 flags);
+extern void acpihp_slot_clear_flag(struct acpihp_slot *slot, u32 flags);
+extern u32 acpihp_slot_get_flag(struct acpihp_slot *slot, u32 flags);
+extern void acpihp_slot_change_state(struct acpihp_slot *slot,
+ enum acpihp_slot_state state);
+
extern int acpihp_debug;
#define ACPIHP_DEBUG(fmt, ...) \