From: Matthew Garrett <mjg59@srcf.ucam.org>
To: linux-pci@vger.kernel.org
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/2] acpiphp: Call _LCK method
Date: Thu, 13 Nov 2008 23:53:54 +0000 [thread overview]
Message-ID: <20081113235354.GB17709@srcf.ucam.org> (raw)
In-Reply-To: <20081113235255.GA17709@srcf.ucam.org>
From: Matthew Garrett <mjg@redhat.com>
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@redhat.com>
---
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@srcf.ucam.org
next prev parent reply other threads:[~2008-11-13 23:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-13 23:52 [PATCH v2 1/2] acpiphp: Identify more removable slots Matthew Garrett
2008-11-13 23:53 ` Matthew Garrett [this message]
2008-11-14 0:20 ` [PATCH v2 2/2] acpiphp: Call _LCK method Matthew Garrett
2008-11-17 13:49 ` [PATCH] acpiphp: Identify more removable slots Matthew Garrett
2008-11-25 21:48 ` [PATCH (resend)] " Matthew Garrett
2008-11-25 22:02 ` Kristen Carlson Accardi
2008-12-01 20:40 ` Jesse Barnes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081113235354.GB17709@srcf.ucam.org \
--to=mjg59@srcf.ucam.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox