[PATCH v2 2/2] acpiphp: Call _LCK method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Matthew Garrett <mjg@xxxxxxxxxx>

Removable ACPI devices may have _LCK methods to indicate a software 
controlled lock. These should be locked on device insertion and unlocked 
when the user requests the device be ejected. Add support for flagging 
devices with a _LCK method and then call appropriately on the add and 
eject paths.

Signed-off-by: Matthew Garrett <mjg@xxxxxxxxxx>
---
 drivers/pci/hotplug/acpiphp.h      |    1 +
 drivers/pci/hotplug/acpiphp_glue.c |   45 +++++++++++++++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index f9e244d..c07a4e8 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -194,6 +194,7 @@ struct acpiphp_ioapic {
 #define FUNC_HAS_PS2		(0x00000040)
 #define FUNC_HAS_PS3		(0x00000080)
 #define FUNC_HAS_DCK            (0x00000100)
+#define FUNC_HAS_LCK            (0x00000200)
 
 /* function prototypes */
 
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index e8cef99..a83788d 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -222,6 +222,9 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
 	if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp)))
 		newfunc->flags |= FUNC_HAS_DCK;
 
+	if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", &tmp)))
+		newfunc->flags |= FUNC_HAS_LCK;
+
 	status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
 	if (ACPI_FAILURE(status)) {
 		/*
@@ -1310,6 +1313,21 @@ int acpiphp_eject_slot(struct acpiphp_slot *slot)
 	list_for_each (l, &slot->funcs) {
 		func = list_entry(l, struct acpiphp_func, sibling);
 
+		if ((func->flags & FUNC_HAS_LCK)) {
+			arg_list.count = 1;
+			arg_list.pointer = &arg;
+			arg.type = ACPI_TYPE_INTEGER;
+			arg.integer.value = 0;
+
+			status = acpi_evaluate_object(func->handle, "_LCK",
+						      &arg_list, NULL);
+			if (ACPI_FAILURE(status)) {
+				warn("%s: _LCK failed\n", __func__);
+				return -1;
+			} else
+				break;
+		}
+
 		/* We don't want to call _EJ0 on non-existing functions. */
 		if ((func->flags & FUNC_HAS_EJ0)) {
 			/* _EJ0 method take one argument */
@@ -1318,7 +1336,8 @@ int acpiphp_eject_slot(struct acpiphp_slot *slot)
 			arg.type = ACPI_TYPE_INTEGER;
 			arg.integer.value = 1;
 
-			status = acpi_evaluate_object(func->handle, "_EJ0", &arg_list, NULL);
+			status = acpi_evaluate_object(func->handle, "_EJ0",
+						      &arg_list, NULL);
 			if (ACPI_FAILURE(status)) {
 				warn("%s: _EJ0 failed\n", __func__);
 				return -1;
@@ -1802,6 +1821,11 @@ static int acpiphp_for_each_slot(acpiphp_callback fn, void *data)
 int acpiphp_enable_slot(struct acpiphp_slot *slot)
 {
 	int retval;
+	acpi_status status;
+	struct acpiphp_func *func;
+	struct list_head *l;
+	struct acpi_object_list arg_list;
+	union acpi_object arg;
 
 	mutex_lock(&slot->crit_sect);
 
@@ -1810,6 +1834,25 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
 	if (retval)
 		goto err_exit;
 
+	list_for_each(l, &slot->funcs) {
+		func = list_entry(l, struct acpiphp_func, sibling);
+
+		if ((func->flags & FUNC_HAS_LCK)) {
+			arg_list.count = 1;
+			arg_list.pointer = &arg;
+			arg.type = ACPI_TYPE_INTEGER;
+			arg.integer.value = 1;
+
+			status = acpi_evaluate_object(func->handle, "_LCK",
+						      &arg_list, NULL);
+			if (ACPI_FAILURE(status)) {
+				warn("%s: _LCK failed\n", __func__);
+				return -1;
+			} else
+				break;
+		}
+	}
+
 	if (get_slot_status(slot) == ACPI_STA_ALL) {
 		/* configure all functions */
 		retval = enable_device(slot);
-- 
Matthew Garrett | mjg59@xxxxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux