All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI:add _STA evaluating at do_acpi_find_child()
@ 2013-05-21 11:19 jeff.wu
  2013-05-21  4:13 ` Jeff Wu
  2013-05-21 13:34 ` Lan Tianyu
  0 siblings, 2 replies; 13+ messages in thread
From: jeff.wu @ 2013-05-21 11:19 UTC (permalink / raw)
  To: lenb, rjw, linux-acpi
  Cc: zlinuxkernel, lekensteyn, dagobertstaler, shang.huang, aaron.lwe

From: Jeff Wu <zlinuxkernel@gmail.com>

Once do_acpi_find_child() found the first matching handle, it makes the acpi_get_child()
loop stop and return the matching handle. But, at some of the platforms, a "_ADR" is
with the multiple devices, and if one is enabled, the others will be disabled.
Just like a case:
Address : 0x1FFFF ; handle : SB_PCI0.SATA.DEV0
Address : 0x1FFFF ; handle : SB_PCI0.SATA.DEV1
Address : 0x1FFFF ; handle : SB_PCI0.SATA.DEV2

If DEV0 and DEV1 are disabled and DEV2 is enabled, the target is to get DEV2 handle, but
actually it always return the first disabled device DEV0 handle. So add a _STA evaluating
at do_acpi_find_child() to check the device status. If the object exists, but it is disabled,
acpi_get_child() will continue looping to get the correct handle that the object exists and
is enabled.
 

Signed-off-by: Jeff Wu <zlinuxkernel@gmail.com>
---
 drivers/acpi/glue.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 40a84cc..ace6c2e 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -81,11 +81,14 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
 static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used,
 				      void *addr_p, void **ret_p)
 {
-	unsigned long long addr;
 	acpi_status status;
+	unsigned long long addr = 0, sta = 0;
 
 	status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr);
 	if (ACPI_SUCCESS(status) && addr == *((u64 *)addr_p)) {
+		status = acpi_bus_get_status_handle(handle, &sta);
+		if (ACPI_SUCCESS(status) && !(sta & ACPI_STA_DEVICE_ENABLED))
+			return AE_CTRL_DEPTH;
 		*ret_p = handle;
 		return AE_CTRL_TERMINATE;
 	}
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-05-24 21:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21 11:19 [PATCH] ACPI:add _STA evaluating at do_acpi_find_child() jeff.wu
2013-05-21  4:13 ` Jeff Wu
2013-05-21 13:34 ` Lan Tianyu
2013-05-21 14:21   ` Lan Tianyu
2013-05-22  3:27   ` Jeff Wu
2013-05-22  6:41     ` Lan Tianyu
2013-05-22  7:42       ` Jeff Wu
2013-05-23  0:06         ` Rafael J. Wysocki
2013-05-23 12:56           ` Lan Tianyu
2013-05-23 22:00             ` Rafael J. Wysocki
2013-05-24  8:22               ` Jeff Wu
2013-05-24  8:21           ` Jeff Wu
2013-05-24 21:46             ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.