linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ACPI: Implement acpi_get_device_handle copied from thinkpad_acpi.c
@ 2011-12-16  0:26 Thomas Renninger
  2011-12-16  0:26 ` [PATCH 2/2] ACPI: Remove tpacpi_acpi_handle_locate_callback and make use of the global implementation Thomas Renninger
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Renninger @ 2011-12-16  0:26 UTC (permalink / raw)
  To: lenb
  Cc: Thomas Renninger, Matthew Garrett, linux-acpi, seth.forshee,
	Azael Avalos, Henrique de Moraes Holschuh

The toshiba_acpi driver needs it and others might as well.
Removing the thinkpad_acpi.c implementation will follow in a separate
patch.

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: Matthew Garrett <mjg@redhat.com>
CC: Len Brown <lenb@kernel.org>
CC: linux-acpi@vger.kernel.org
CC: seth.forshee@canonical.com
CC: Azael Avalos <coproscefalo@gmail.com>
CC: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
 drivers/acpi/osl.c   |   25 +++++++++++++++++++++++++
 include/linux/acpi.h |    2 ++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index f31c5c5..4f9f7f5 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1659,3 +1659,28 @@ acpi_status acpi_os_terminate(void)
 
 	return AE_OK;
 }
+
+static acpi_status acpi_handle_locate_callback(acpi_handle handle,
+			       u32 level, void *context, void **return_value)
+{
+	*(acpi_handle *)return_value = handle;
+	return AE_CTRL_TERMINATE;
+}
+
+int acpi_handle_locate(const char *hid, acpi_handle *handle)
+{
+	acpi_status status;
+
+	if (!hid || !handle)
+		return -EINVAL;
+
+	memset(handle, 0, sizeof(acpi_handle));
+	status = acpi_get_devices(hid, acpi_handle_locate_callback, NULL,
+				  handle);
+
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+
+	return 0;		
+}
+EXPORT_SYMBOL_GPL(acpi_handle_locate);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 6001b4da..d09aca3 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -146,6 +146,8 @@ struct acpi_pci_driver {
 int acpi_pci_register_driver(struct acpi_pci_driver *driver);
 void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
 
+extern int acpi_get_device_handle(const char *hid, acpi_handle *handle);
+
 extern int ec_read(u8 addr, u8 *val);
 extern int ec_write(u8 addr, u8 val);
 extern int ec_transaction(u8 command,
-- 
1.7.6.1


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

* [PATCH 2/2] ACPI: Remove tpacpi_acpi_handle_locate_callback and make use of the global implementation
  2011-12-16  0:26 [PATCH 1/2] ACPI: Implement acpi_get_device_handle copied from thinkpad_acpi.c Thomas Renninger
@ 2011-12-16  0:26 ` Thomas Renninger
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Renninger @ 2011-12-16  0:26 UTC (permalink / raw)
  To: lenb
  Cc: Thomas Renninger, Matthew Garrett, linux-acpi, seth.forshee,
	Azael Avalos, Henrique de Moraes Holschuh

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: Matthew Garrett <mjg@redhat.com>
CC: Len Brown <lenb@kernel.org>
CC: linux-acpi@vger.kernel.org
CC: seth.forshee@canonical.com
CC: Azael Avalos <coproscefalo@gmail.com>
CC: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
 drivers/platform/x86/thinkpad_acpi.c |   48 ++++-----------------------------
 1 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 7b82868..c95a3af 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -698,43 +698,6 @@ static void __init drv_acpi_handle_init(const char *name,
 	*handle = NULL;
 }
 
-static acpi_status __init tpacpi_acpi_handle_locate_callback(acpi_handle handle,
-			u32 level, void *context, void **return_value)
-{
-	*(acpi_handle *)return_value = handle;
-
-	return AE_CTRL_TERMINATE;
-}
-
-static void __init tpacpi_acpi_handle_locate(const char *name,
-		const char *hid,
-		acpi_handle *handle)
-{
-	acpi_status status;
-	acpi_handle device_found;
-
-	BUG_ON(!name || !hid || !handle);
-	vdbg_printk(TPACPI_DBG_INIT,
-			"trying to locate ACPI handle for %s, using HID %s\n",
-			name, hid);
-
-	memset(&device_found, 0, sizeof(device_found));
-	status = acpi_get_devices(hid, tpacpi_acpi_handle_locate_callback,
-				  (void *)name, &device_found);
-
-	*handle = NULL;
-
-	if (ACPI_SUCCESS(status)) {
-		*handle = device_found;
-		dbg_printk(TPACPI_DBG_INIT,
-			   "Found ACPI handle for %s\n", name);
-	} else {
-		vdbg_printk(TPACPI_DBG_INIT,
-			    "Could not locate an ACPI handle for %s: %s\n",
-			    name, acpi_format_exception(status));
-	}
-}
-
 static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
 	struct ibm_struct *ibm = data;
@@ -6142,9 +6105,10 @@ static unsigned int __init tpacpi_check_std_acpi_brightness_support(void)
 {
 	acpi_handle video_device;
 	int bcl_levels = 0;
+	int ret;
 
-	tpacpi_acpi_handle_locate("video", ACPI_VIDEO_HID, &video_device);
-	if (video_device)
+	ret = acpi_get_device_handle(ACPI_VIDEO_HID, &video_device);
+	if (!ret)
 		bcl_levels = tpacpi_query_bcl_levels(video_device);
 
 	tp_features.bright_acpimode = (bcl_levels > 0);
@@ -8677,7 +8641,7 @@ static int __must_check __init get_thinkpad_model_data(
 
 static int __init probe_for_thinkpad(void)
 {
-	int is_thinkpad;
+	int is_thinkpad, ret;
 
 	if (acpi_disabled)
 		return -ENODEV;
@@ -8695,8 +8659,8 @@ static int __init probe_for_thinkpad(void)
 		      tpacpi_is_fw_known();
 
 	/* The EC handler is required */
-	tpacpi_acpi_handle_locate("ec", TPACPI_ACPI_EC_HID, &ec_handle);
-	if (!ec_handle) {
+	ret = acpi_get_device_handle(TPACPI_ACPI_EC_HID, &ec_handle);
+	if (ret) {
 		if (is_thinkpad)
 			pr_err("Not yet supported ThinkPad detected!\n");
 		return -ENODEV;
-- 
1.7.6.1


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

end of thread, other threads:[~2011-12-16  0:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-16  0:26 [PATCH 1/2] ACPI: Implement acpi_get_device_handle copied from thinkpad_acpi.c Thomas Renninger
2011-12-16  0:26 ` [PATCH 2/2] ACPI: Remove tpacpi_acpi_handle_locate_callback and make use of the global implementation Thomas Renninger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).