Commit ebf4df8d authored by Jiang Liu's avatar Jiang Liu Committed by Rafael J. Wysocki

ACPI: Export acpi_(bay)|(dock)_match() from scan.c

Functions acpi_dock_match() and acpi_bay_match() in scan.c can be
shared with dock.c to reduce code duplication, so export them as
global functions.

Also add a new function acpi_ata_match() to check whether an ACPI
device object represents an ATA device.

[rjw: Changelog]
Signed-off-by: default avatarJiang Liu <jiang.liu@huawei.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 7d2421f8
...@@ -1479,44 +1479,46 @@ static void acpi_device_get_busid(struct acpi_device *device) ...@@ -1479,44 +1479,46 @@ static void acpi_device_get_busid(struct acpi_device *device)
} }
} }
/*
* acpi_ata_match - see if an acpi object is an ATA device
*
* If an acpi object has one of the ACPI ATA methods defined,
* then we can safely call it an ATA device.
*/
bool acpi_ata_match(acpi_handle handle)
{
return acpi_has_method(handle, "_GTF") ||
acpi_has_method(handle, "_GTM") ||
acpi_has_method(handle, "_STM") ||
acpi_has_method(handle, "_SDD");
}
/* /*
* acpi_bay_match - see if an acpi object is an ejectable driver bay * acpi_bay_match - see if an acpi object is an ejectable driver bay
* *
* If an acpi object is ejectable and has one of the ACPI ATA methods defined, * If an acpi object is ejectable and has one of the ACPI ATA methods defined,
* then we can safely call it an ejectable drive bay * then we can safely call it an ejectable drive bay
*/ */
static int acpi_bay_match(acpi_handle handle) bool acpi_bay_match(acpi_handle handle)
{ {
acpi_handle phandle; acpi_handle phandle;
if (!acpi_has_method(handle, "_EJ0")) if (!acpi_has_method(handle, "_EJ0"))
return -ENODEV; return false;
if (acpi_ata_match(handle))
if (acpi_has_method(handle, "_GTF") || return true;
acpi_has_method(handle, "_GTM") || if (ACPI_FAILURE(acpi_get_parent(handle, &phandle)))
acpi_has_method(handle, "_STM") || return false;
acpi_has_method(handle, "_SDD"))
return 0;
if (acpi_get_parent(handle, &phandle))
return -ENODEV;
if (acpi_has_method(phandle, "_GTF") ||
acpi_has_method(phandle, "_GTM") ||
acpi_has_method(phandle, "_STM") ||
acpi_has_method(phandle, "_SDD"))
return 0;
return -ENODEV; return acpi_ata_match(phandle);
} }
/* /*
* acpi_dock_match - see if an acpi object has a _DCK method * acpi_dock_match - see if an acpi object has a _DCK method
*/ */
static int acpi_dock_match(acpi_handle handle) bool acpi_dock_match(acpi_handle handle)
{ {
acpi_handle tmp; return acpi_has_method(handle, "_DCK");
return acpi_get_handle(handle, "_DCK", &tmp);
} }
const char *acpi_device_hid(struct acpi_device *device) const char *acpi_device_hid(struct acpi_device *device)
...@@ -1554,33 +1556,26 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id) ...@@ -1554,33 +1556,26 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
* lacks the SMBUS01 HID and the methods do not have the necessary "_" * lacks the SMBUS01 HID and the methods do not have the necessary "_"
* prefix. Work around this. * prefix. Work around this.
*/ */
static int acpi_ibm_smbus_match(acpi_handle handle) static bool acpi_ibm_smbus_match(acpi_handle handle)
{ {
struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; char node_name[ACPI_PATH_SEGMENT_LENGTH];
int result; struct acpi_buffer path = { sizeof(node_name), node_name };
if (!dmi_name_in_vendors("IBM")) if (!dmi_name_in_vendors("IBM"))
return -ENODEV; return false;
/* Look for SMBS object */ /* Look for SMBS object */
result = acpi_get_name(handle, ACPI_SINGLE_NAME, &path); if (ACPI_FAILURE(acpi_get_name(handle, ACPI_SINGLE_NAME, &path)) ||
if (result) strcmp("SMBS", path.pointer))
return result; return false;
if (strcmp("SMBS", path.pointer)) {
result = -ENODEV;
goto out;
}
/* Does it have the necessary (but misnamed) methods? */ /* Does it have the necessary (but misnamed) methods? */
result = -ENODEV;
if (acpi_has_method(handle, "SBI") && if (acpi_has_method(handle, "SBI") &&
acpi_has_method(handle, "SBR") && acpi_has_method(handle, "SBR") &&
acpi_has_method(handle, "SBW")) acpi_has_method(handle, "SBW"))
result = 0; return true;
out:
kfree(path.pointer); return false;
return result;
} }
static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
...@@ -1628,11 +1623,11 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, ...@@ -1628,11 +1623,11 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
*/ */
if (acpi_is_video_device(handle)) if (acpi_is_video_device(handle))
acpi_add_id(pnp, ACPI_VIDEO_HID); acpi_add_id(pnp, ACPI_VIDEO_HID);
else if (ACPI_SUCCESS(acpi_bay_match(handle))) else if (acpi_bay_match(handle))
acpi_add_id(pnp, ACPI_BAY_HID); acpi_add_id(pnp, ACPI_BAY_HID);
else if (ACPI_SUCCESS(acpi_dock_match(handle))) else if (acpi_dock_match(handle))
acpi_add_id(pnp, ACPI_DOCK_HID); acpi_add_id(pnp, ACPI_DOCK_HID);
else if (!acpi_ibm_smbus_match(handle)) else if (acpi_ibm_smbus_match(handle))
acpi_add_id(pnp, ACPI_SMBUS_IBM_HID); acpi_add_id(pnp, ACPI_SMBUS_IBM_HID);
else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) { else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) {
acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
......
...@@ -62,6 +62,9 @@ acpi_status acpi_execute_simple_method(acpi_handle handle, char *method, ...@@ -62,6 +62,9 @@ acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
u64 arg); u64 arg);
acpi_status acpi_evaluate_ej0(acpi_handle handle); acpi_status acpi_evaluate_ej0(acpi_handle handle);
acpi_status acpi_evaluate_lck(acpi_handle handle, int lock); acpi_status acpi_evaluate_lck(acpi_handle handle, int lock);
bool acpi_ata_match(acpi_handle handle);
bool acpi_bay_match(acpi_handle handle);
bool acpi_dock_match(acpi_handle handle);
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment