diff options
author | Jiang Liu <jiang.liu@huawei.com> | 2013-06-28 12:24:41 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-07-14 19:33:10 -0400 |
commit | ebf4df8db0e7e5db9f7fca5fcd0c2b90ac954385 (patch) | |
tree | a48d19b61780fe028d710e7210c5059a56739d3f /drivers/acpi/scan.c | |
parent | 7d2421f84b445dc48c68d33911f1fd6ce6853ee3 (diff) |
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: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 77 |
1 files changed, 36 insertions, 41 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 4c25c3b7ef81..62e2055e8806 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -1480,43 +1480,45 @@ static void acpi_device_get_busid(struct acpi_device *device) | |||
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | /* | 1482 | /* |
1483 | * acpi_ata_match - see if an acpi object is an ATA device | ||
1484 | * | ||
1485 | * If an acpi object has one of the ACPI ATA methods defined, | ||
1486 | * then we can safely call it an ATA device. | ||
1487 | */ | ||
1488 | bool acpi_ata_match(acpi_handle handle) | ||
1489 | { | ||
1490 | return acpi_has_method(handle, "_GTF") || | ||
1491 | acpi_has_method(handle, "_GTM") || | ||
1492 | acpi_has_method(handle, "_STM") || | ||
1493 | acpi_has_method(handle, "_SDD"); | ||
1494 | } | ||
1495 | |||
1496 | /* | ||
1483 | * acpi_bay_match - see if an acpi object is an ejectable driver bay | 1497 | * acpi_bay_match - see if an acpi object is an ejectable driver bay |
1484 | * | 1498 | * |
1485 | * If an acpi object is ejectable and has one of the ACPI ATA methods defined, | 1499 | * If an acpi object is ejectable and has one of the ACPI ATA methods defined, |
1486 | * then we can safely call it an ejectable drive bay | 1500 | * then we can safely call it an ejectable drive bay |
1487 | */ | 1501 | */ |
1488 | static int acpi_bay_match(acpi_handle handle) | 1502 | bool acpi_bay_match(acpi_handle handle) |
1489 | { | 1503 | { |
1490 | acpi_handle phandle; | 1504 | acpi_handle phandle; |
1491 | 1505 | ||
1492 | if (!acpi_has_method(handle, "_EJ0")) | 1506 | if (!acpi_has_method(handle, "_EJ0")) |
1493 | return -ENODEV; | 1507 | return false; |
1508 | if (acpi_ata_match(handle)) | ||
1509 | return true; | ||
1510 | if (ACPI_FAILURE(acpi_get_parent(handle, &phandle))) | ||
1511 | return false; | ||
1494 | 1512 | ||
1495 | if (acpi_has_method(handle, "_GTF") || | 1513 | return acpi_ata_match(phandle); |
1496 | acpi_has_method(handle, "_GTM") || | ||
1497 | acpi_has_method(handle, "_STM") || | ||
1498 | acpi_has_method(handle, "_SDD")) | ||
1499 | return 0; | ||
1500 | |||
1501 | if (acpi_get_parent(handle, &phandle)) | ||
1502 | return -ENODEV; | ||
1503 | |||
1504 | if (acpi_has_method(phandle, "_GTF") || | ||
1505 | acpi_has_method(phandle, "_GTM") || | ||
1506 | acpi_has_method(phandle, "_STM") || | ||
1507 | acpi_has_method(phandle, "_SDD")) | ||
1508 | return 0; | ||
1509 | |||
1510 | return -ENODEV; | ||
1511 | } | 1514 | } |
1512 | 1515 | ||
1513 | /* | 1516 | /* |
1514 | * acpi_dock_match - see if an acpi object has a _DCK method | 1517 | * acpi_dock_match - see if an acpi object has a _DCK method |
1515 | */ | 1518 | */ |
1516 | static int acpi_dock_match(acpi_handle handle) | 1519 | bool acpi_dock_match(acpi_handle handle) |
1517 | { | 1520 | { |
1518 | acpi_handle tmp; | 1521 | return acpi_has_method(handle, "_DCK"); |
1519 | return acpi_get_handle(handle, "_DCK", &tmp); | ||
1520 | } | 1522 | } |
1521 | 1523 | ||
1522 | const char *acpi_device_hid(struct acpi_device *device) | 1524 | 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 | * lacks the SMBUS01 HID and the methods do not have the necessary "_" | 1556 | * lacks the SMBUS01 HID and the methods do not have the necessary "_" |
1555 | * prefix. Work around this. | 1557 | * prefix. Work around this. |
1556 | */ | 1558 | */ |
1557 | static int acpi_ibm_smbus_match(acpi_handle handle) | 1559 | static bool acpi_ibm_smbus_match(acpi_handle handle) |
1558 | { | 1560 | { |
1559 | struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; | 1561 | char node_name[ACPI_PATH_SEGMENT_LENGTH]; |
1560 | int result; | 1562 | struct acpi_buffer path = { sizeof(node_name), node_name }; |
1561 | 1563 | ||
1562 | if (!dmi_name_in_vendors("IBM")) | 1564 | if (!dmi_name_in_vendors("IBM")) |
1563 | return -ENODEV; | 1565 | return false; |
1564 | 1566 | ||
1565 | /* Look for SMBS object */ | 1567 | /* Look for SMBS object */ |
1566 | result = acpi_get_name(handle, ACPI_SINGLE_NAME, &path); | 1568 | if (ACPI_FAILURE(acpi_get_name(handle, ACPI_SINGLE_NAME, &path)) || |
1567 | if (result) | 1569 | strcmp("SMBS", path.pointer)) |
1568 | return result; | 1570 | return false; |
1569 | |||
1570 | if (strcmp("SMBS", path.pointer)) { | ||
1571 | result = -ENODEV; | ||
1572 | goto out; | ||
1573 | } | ||
1574 | 1571 | ||
1575 | /* Does it have the necessary (but misnamed) methods? */ | 1572 | /* Does it have the necessary (but misnamed) methods? */ |
1576 | result = -ENODEV; | ||
1577 | if (acpi_has_method(handle, "SBI") && | 1573 | if (acpi_has_method(handle, "SBI") && |
1578 | acpi_has_method(handle, "SBR") && | 1574 | acpi_has_method(handle, "SBR") && |
1579 | acpi_has_method(handle, "SBW")) | 1575 | acpi_has_method(handle, "SBW")) |
1580 | result = 0; | 1576 | return true; |
1581 | out: | 1577 | |
1582 | kfree(path.pointer); | 1578 | return false; |
1583 | return result; | ||
1584 | } | 1579 | } |
1585 | 1580 | ||
1586 | static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, | 1581 | 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 | */ | 1623 | */ |
1629 | if (acpi_is_video_device(handle)) | 1624 | if (acpi_is_video_device(handle)) |
1630 | acpi_add_id(pnp, ACPI_VIDEO_HID); | 1625 | acpi_add_id(pnp, ACPI_VIDEO_HID); |
1631 | else if (ACPI_SUCCESS(acpi_bay_match(handle))) | 1626 | else if (acpi_bay_match(handle)) |
1632 | acpi_add_id(pnp, ACPI_BAY_HID); | 1627 | acpi_add_id(pnp, ACPI_BAY_HID); |
1633 | else if (ACPI_SUCCESS(acpi_dock_match(handle))) | 1628 | else if (acpi_dock_match(handle)) |
1634 | acpi_add_id(pnp, ACPI_DOCK_HID); | 1629 | acpi_add_id(pnp, ACPI_DOCK_HID); |
1635 | else if (!acpi_ibm_smbus_match(handle)) | 1630 | else if (acpi_ibm_smbus_match(handle)) |
1636 | acpi_add_id(pnp, ACPI_SMBUS_IBM_HID); | 1631 | acpi_add_id(pnp, ACPI_SMBUS_IBM_HID); |
1637 | else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) { | 1632 | else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) { |
1638 | acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ | 1633 | acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ |