aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c99
1 files changed, 30 insertions, 69 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 10985573aaa7..ada0b4cf2ba5 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -193,7 +193,6 @@ static acpi_status acpi_bus_online_companions(acpi_handle handle, u32 lvl,
193static int acpi_scan_hot_remove(struct acpi_device *device) 193static int acpi_scan_hot_remove(struct acpi_device *device)
194{ 194{
195 acpi_handle handle = device->handle; 195 acpi_handle handle = device->handle;
196 acpi_handle not_used;
197 struct acpi_object_list arg_list; 196 struct acpi_object_list arg_list;
198 union acpi_object arg; 197 union acpi_object arg;
199 struct device *errdev; 198 struct device *errdev;
@@ -258,7 +257,7 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
258 put_device(&device->dev); 257 put_device(&device->dev);
259 device = NULL; 258 device = NULL;
260 259
261 if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", &not_used))) { 260 if (acpi_has_method(handle, "_LCK")) {
262 arg_list.count = 1; 261 arg_list.count = 1;
263 arg_list.pointer = &arg; 262 arg_list.pointer = &arg;
264 arg.type = ACPI_TYPE_INTEGER; 263 arg.type = ACPI_TYPE_INTEGER;
@@ -652,7 +651,6 @@ static int acpi_device_setup_files(struct acpi_device *dev)
652{ 651{
653 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 652 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
654 acpi_status status; 653 acpi_status status;
655 acpi_handle temp;
656 unsigned long long sun; 654 unsigned long long sun;
657 int result = 0; 655 int result = 0;
658 656
@@ -678,8 +676,7 @@ static int acpi_device_setup_files(struct acpi_device *dev)
678 /* 676 /*
679 * If device has _STR, 'description' file is created 677 * If device has _STR, 'description' file is created
680 */ 678 */
681 status = acpi_get_handle(dev->handle, "_STR", &temp); 679 if (acpi_has_method(dev->handle, "_STR")) {
682 if (ACPI_SUCCESS(status)) {
683 status = acpi_evaluate_object(dev->handle, "_STR", 680 status = acpi_evaluate_object(dev->handle, "_STR",
684 NULL, &buffer); 681 NULL, &buffer);
685 if (ACPI_FAILURE(status)) 682 if (ACPI_FAILURE(status))
@@ -709,8 +706,7 @@ static int acpi_device_setup_files(struct acpi_device *dev)
709 * If device has _EJ0, 'eject' file is created that is used to trigger 706 * If device has _EJ0, 'eject' file is created that is used to trigger
710 * hot-removal function from userland. 707 * hot-removal function from userland.
711 */ 708 */
712 status = acpi_get_handle(dev->handle, "_EJ0", &temp); 709 if (acpi_has_method(dev->handle, "_EJ0")) {
713 if (ACPI_SUCCESS(status)) {
714 result = device_create_file(&dev->dev, &dev_attr_eject); 710 result = device_create_file(&dev->dev, &dev_attr_eject);
715 if (result) 711 if (result)
716 return result; 712 return result;
@@ -732,9 +728,6 @@ end:
732 728
733static void acpi_device_remove_files(struct acpi_device *dev) 729static void acpi_device_remove_files(struct acpi_device *dev)
734{ 730{
735 acpi_status status;
736 acpi_handle temp;
737
738 if (dev->flags.power_manageable) { 731 if (dev->flags.power_manageable) {
739 device_remove_file(&dev->dev, &dev_attr_power_state); 732 device_remove_file(&dev->dev, &dev_attr_power_state);
740 if (dev->power.flags.power_resources) 733 if (dev->power.flags.power_resources)
@@ -745,20 +738,17 @@ static void acpi_device_remove_files(struct acpi_device *dev)
745 /* 738 /*
746 * If device has _STR, remove 'description' file 739 * If device has _STR, remove 'description' file
747 */ 740 */
748 status = acpi_get_handle(dev->handle, "_STR", &temp); 741 if (acpi_has_method(dev->handle, "_STR")) {
749 if (ACPI_SUCCESS(status)) {
750 kfree(dev->pnp.str_obj); 742 kfree(dev->pnp.str_obj);
751 device_remove_file(&dev->dev, &dev_attr_description); 743 device_remove_file(&dev->dev, &dev_attr_description);
752 } 744 }
753 /* 745 /*
754 * If device has _EJ0, remove 'eject' file. 746 * If device has _EJ0, remove 'eject' file.
755 */ 747 */
756 status = acpi_get_handle(dev->handle, "_EJ0", &temp); 748 if (acpi_has_method(dev->handle, "_EJ0"))
757 if (ACPI_SUCCESS(status))
758 device_remove_file(&dev->dev, &dev_attr_eject); 749 device_remove_file(&dev->dev, &dev_attr_eject);
759 750
760 status = acpi_get_handle(dev->handle, "_SUN", &temp); 751 if (acpi_has_method(dev->handle, "_SUN"))
761 if (ACPI_SUCCESS(status))
762 device_remove_file(&dev->dev, &dev_attr_sun); 752 device_remove_file(&dev->dev, &dev_attr_sun);
763 753
764 if (dev->pnp.unique_id) 754 if (dev->pnp.unique_id)
@@ -1334,13 +1324,10 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
1334 1324
1335static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device) 1325static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
1336{ 1326{
1337 acpi_handle temp;
1338 acpi_status status = 0;
1339 int err; 1327 int err;
1340 1328
1341 /* Presence of _PRW indicates wake capable */ 1329 /* Presence of _PRW indicates wake capable */
1342 status = acpi_get_handle(device->handle, "_PRW", &temp); 1330 if (!acpi_has_method(device->handle, "_PRW"))
1343 if (ACPI_FAILURE(status))
1344 return; 1331 return;
1345 1332
1346 err = acpi_bus_extract_wakeup_device_power_package(device->handle, 1333 err = acpi_bus_extract_wakeup_device_power_package(device->handle,
@@ -1370,7 +1357,6 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
1370 struct acpi_device_power_state *ps = &device->power.states[state]; 1357 struct acpi_device_power_state *ps = &device->power.states[state];
1371 char pathname[5] = { '_', 'P', 'R', '0' + state, '\0' }; 1358 char pathname[5] = { '_', 'P', 'R', '0' + state, '\0' };
1372 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 1359 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1373 acpi_handle handle;
1374 acpi_status status; 1360 acpi_status status;
1375 1361
1376 INIT_LIST_HEAD(&ps->resources); 1362 INIT_LIST_HEAD(&ps->resources);
@@ -1393,8 +1379,7 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
1393 1379
1394 /* Evaluate "_PSx" to see if we can do explicit sets */ 1380 /* Evaluate "_PSx" to see if we can do explicit sets */
1395 pathname[2] = 'S'; 1381 pathname[2] = 'S';
1396 status = acpi_get_handle(device->handle, pathname, &handle); 1382 if (acpi_has_method(device->handle, pathname))
1397 if (ACPI_SUCCESS(status))
1398 ps->flags.explicit_set = 1; 1383 ps->flags.explicit_set = 1;
1399 1384
1400 /* 1385 /*
@@ -1413,28 +1398,21 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
1413 1398
1414static void acpi_bus_get_power_flags(struct acpi_device *device) 1399static void acpi_bus_get_power_flags(struct acpi_device *device)
1415{ 1400{
1416 acpi_status status;
1417 acpi_handle handle;
1418 u32 i; 1401 u32 i;
1419 1402
1420 /* Presence of _PS0|_PR0 indicates 'power manageable' */ 1403 /* Presence of _PS0|_PR0 indicates 'power manageable' */
1421 status = acpi_get_handle(device->handle, "_PS0", &handle); 1404 if (!acpi_has_method(device->handle, "_PS0") &&
1422 if (ACPI_FAILURE(status)) { 1405 !acpi_has_method(device->handle, "_PR0"))
1423 status = acpi_get_handle(device->handle, "_PR0", &handle); 1406 return;
1424 if (ACPI_FAILURE(status))
1425 return;
1426 }
1427 1407
1428 device->flags.power_manageable = 1; 1408 device->flags.power_manageable = 1;
1429 1409
1430 /* 1410 /*
1431 * Power Management Flags 1411 * Power Management Flags
1432 */ 1412 */
1433 status = acpi_get_handle(device->handle, "_PSC", &handle); 1413 if (acpi_has_method(device->handle, "_PSC"))
1434 if (ACPI_SUCCESS(status))
1435 device->power.flags.explicit_get = 1; 1414 device->power.flags.explicit_get = 1;
1436 status = acpi_get_handle(device->handle, "_IRC", &handle); 1415 if (acpi_has_method(device->handle, "_IRC"))
1437 if (ACPI_SUCCESS(status))
1438 device->power.flags.inrush_current = 1; 1416 device->power.flags.inrush_current = 1;
1439 1417
1440 /* 1418 /*
@@ -1468,28 +1446,18 @@ static void acpi_bus_get_power_flags(struct acpi_device *device)
1468 1446
1469static void acpi_bus_get_flags(struct acpi_device *device) 1447static void acpi_bus_get_flags(struct acpi_device *device)
1470{ 1448{
1471 acpi_status status = AE_OK;
1472 acpi_handle temp = NULL;
1473
1474 /* Presence of _STA indicates 'dynamic_status' */ 1449 /* Presence of _STA indicates 'dynamic_status' */
1475 status = acpi_get_handle(device->handle, "_STA", &temp); 1450 if (acpi_has_method(device->handle, "_STA"))
1476 if (ACPI_SUCCESS(status))
1477 device->flags.dynamic_status = 1; 1451 device->flags.dynamic_status = 1;
1478 1452
1479 /* Presence of _RMV indicates 'removable' */ 1453 /* Presence of _RMV indicates 'removable' */
1480 status = acpi_get_handle(device->handle, "_RMV", &temp); 1454 if (acpi_has_method(device->handle, "_RMV"))
1481 if (ACPI_SUCCESS(status))
1482 device->flags.removable = 1; 1455 device->flags.removable = 1;
1483 1456
1484 /* Presence of _EJD|_EJ0 indicates 'ejectable' */ 1457 /* Presence of _EJD|_EJ0 indicates 'ejectable' */
1485 status = acpi_get_handle(device->handle, "_EJD", &temp); 1458 if (acpi_has_method(device->handle, "_EJD") ||
1486 if (ACPI_SUCCESS(status)) 1459 acpi_has_method(device->handle, "_EJ0"))
1487 device->flags.ejectable = 1; 1460 device->flags.ejectable = 1;
1488 else {
1489 status = acpi_get_handle(device->handle, "_EJ0", &temp);
1490 if (ACPI_SUCCESS(status))
1491 device->flags.ejectable = 1;
1492 }
1493} 1461}
1494 1462
1495static void acpi_device_get_busid(struct acpi_device *device) 1463static void acpi_device_get_busid(struct acpi_device *device)
@@ -1538,27 +1506,24 @@ static void acpi_device_get_busid(struct acpi_device *device)
1538 */ 1506 */
1539static int acpi_bay_match(acpi_handle handle) 1507static int acpi_bay_match(acpi_handle handle)
1540{ 1508{
1541 acpi_status status;
1542 acpi_handle tmp;
1543 acpi_handle phandle; 1509 acpi_handle phandle;
1544 1510
1545 status = acpi_get_handle(handle, "_EJ0", &tmp); 1511 if (!acpi_has_method(handle, "_EJ0"))
1546 if (ACPI_FAILURE(status))
1547 return -ENODEV; 1512 return -ENODEV;
1548 1513
1549 if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) || 1514 if (acpi_has_method(handle, "_GTF") ||
1550 (ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) || 1515 acpi_has_method(handle, "_GTM") ||
1551 (ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) || 1516 acpi_has_method(handle, "_STM") ||
1552 (ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp)))) 1517 acpi_has_method(handle, "_SDD"))
1553 return 0; 1518 return 0;
1554 1519
1555 if (acpi_get_parent(handle, &phandle)) 1520 if (acpi_get_parent(handle, &phandle))
1556 return -ENODEV; 1521 return -ENODEV;
1557 1522
1558 if ((ACPI_SUCCESS(acpi_get_handle(phandle, "_GTF", &tmp))) || 1523 if (acpi_has_method(phandle, "_GTF") ||
1559 (ACPI_SUCCESS(acpi_get_handle(phandle, "_GTM", &tmp))) || 1524 acpi_has_method(phandle, "_GTM") ||
1560 (ACPI_SUCCESS(acpi_get_handle(phandle, "_STM", &tmp))) || 1525 acpi_has_method(phandle, "_STM") ||
1561 (ACPI_SUCCESS(acpi_get_handle(phandle, "_SDD", &tmp)))) 1526 acpi_has_method(phandle, "_SDD"))
1562 return 0; 1527 return 0;
1563 1528
1564 return -ENODEV; 1529 return -ENODEV;
@@ -1610,7 +1575,6 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
1610 */ 1575 */
1611static int acpi_ibm_smbus_match(acpi_handle handle) 1576static int acpi_ibm_smbus_match(acpi_handle handle)
1612{ 1577{
1613 acpi_handle h_dummy;
1614 struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; 1578 struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
1615 int result; 1579 int result;
1616 1580
@@ -1629,9 +1593,9 @@ static int acpi_ibm_smbus_match(acpi_handle handle)
1629 1593
1630 /* Does it have the necessary (but misnamed) methods? */ 1594 /* Does it have the necessary (but misnamed) methods? */
1631 result = -ENODEV; 1595 result = -ENODEV;
1632 if (ACPI_SUCCESS(acpi_get_handle(handle, "SBI", &h_dummy)) && 1596 if (acpi_has_method(handle, "SBI") &&
1633 ACPI_SUCCESS(acpi_get_handle(handle, "SBR", &h_dummy)) && 1597 acpi_has_method(handle, "SBR") &&
1634 ACPI_SUCCESS(acpi_get_handle(handle, "SBW", &h_dummy))) 1598 acpi_has_method(handle, "SBW"))
1635 result = 0; 1599 result = 0;
1636out: 1600out:
1637 kfree(path.pointer); 1601 kfree(path.pointer);
@@ -1898,7 +1862,6 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1898 struct acpi_device *device = NULL; 1862 struct acpi_device *device = NULL;
1899 int type; 1863 int type;
1900 unsigned long long sta; 1864 unsigned long long sta;
1901 acpi_status status;
1902 int result; 1865 int result;
1903 1866
1904 acpi_bus_get_device(handle, &device); 1867 acpi_bus_get_device(handle, &device);
@@ -1919,10 +1882,8 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1919 if (!(sta & ACPI_STA_DEVICE_PRESENT) && 1882 if (!(sta & ACPI_STA_DEVICE_PRESENT) &&
1920 !(sta & ACPI_STA_DEVICE_FUNCTIONING)) { 1883 !(sta & ACPI_STA_DEVICE_FUNCTIONING)) {
1921 struct acpi_device_wakeup wakeup; 1884 struct acpi_device_wakeup wakeup;
1922 acpi_handle temp;
1923 1885
1924 status = acpi_get_handle(handle, "_PRW", &temp); 1886 if (acpi_has_method(handle, "_PRW")) {
1925 if (ACPI_SUCCESS(status)) {
1926 acpi_bus_extract_wakeup_device_power_package(handle, 1887 acpi_bus_extract_wakeup_device_power_package(handle,
1927 &wakeup); 1888 &wakeup);
1928 acpi_power_resources_list_free(&wakeup.resources); 1889 acpi_power_resources_list_free(&wakeup.resources);