ACPI: Implement acpi_get_device_handle copied from thinkpad_acpi.c
Subsystems (2)
PATCH 1/2 ACPI: Implement acpi_get_device_handle copied from thinkpad_acpi.c
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 <[email protected]>
CC Matthew Garrett <[email protected]>
CC Len Brown <[email protected]>
CC Azael Avalos <[email protected]>
CC Henrique de Moraes Holschuh <[email protected]>
--- drivers/acpi/osl.c | 25 +++++++++++++++++++++++++ include/linux/acpi.h | 2 ++ 2 files changed, 27 insertions(+), 0 deletions(-)
drivers/acpi/osl.c +25 -0
@@ -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);
include/linux/acpi.h +2 -0
@@ -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,
Signature · 1 line
1.7.6.1
PATCH 2/2 ACPI: Remove tpacpi_acpi_handle_locate_callback and make use of the global implementation
Signed-off-by Thomas Renninger <[email protected]>
CC Matthew Garrett <[email protected]>
CC Len Brown <[email protected]>
CC Azael Avalos <[email protected]>
CC Henrique de Moraes Holschuh <[email protected]>
--- drivers/platform/x86/thinkpad_acpi.c | 48 ++++----------------------------- 1 files changed, 6 insertions(+), 42 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +6 -42
@@ -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 ;
Signature · 1 line
1.7.6.1