diff options
author | Toshi Kani <toshi.kani@hp.com> | 2013-03-04 16:30:41 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-24 18:49:38 -0400 |
commit | d4e1a692e9e85f9cbee090ea8d6158b133d32157 (patch) | |
tree | d6b76ddfc967c7631f0c192af06fb3b7b70047c6 /drivers | |
parent | b09753ec80914424527955147c359e9ac3a87682 (diff) |
ACPI: Remove acpi_device dependency in acpi_device_set_id()
This patch updates the internal operations of acpi_device_set_id()
to setup acpi_device_pnp without using acpi_device. There is no
functional change to acpi_device_set_id() in this patch.
acpi_pnp_type is added to acpi_device_pnp, so that PNPID type is
self-contained within acpi_device_pnp. acpi_add_id(), acpi_bay_match(),
acpi_dock_match(), acpi_ibm_smbus_match() and acpi_is_video_device()
are changed to take acpi_handle as an argument, instead of acpi_device.
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/acpi/scan.c | 69 | ||||
-rw-r--r-- | drivers/acpi/video_detect.c | 25 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_opregion.c | 4 |
3 files changed, 47 insertions, 51 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index d69d77ab9c7e..f9c698d766f1 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -526,7 +526,7 @@ static int acpi_device_setup_files(struct acpi_device *dev) | |||
526 | goto end; | 526 | goto end; |
527 | } | 527 | } |
528 | 528 | ||
529 | if (dev->flags.bus_address) | 529 | if (dev->pnp.type.bus_address) |
530 | result = device_create_file(&dev->dev, &dev_attr_adr); | 530 | result = device_create_file(&dev->dev, &dev_attr_adr); |
531 | if (dev->pnp.unique_id) | 531 | if (dev->pnp.unique_id) |
532 | result = device_create_file(&dev->dev, &dev_attr_uid); | 532 | result = device_create_file(&dev->dev, &dev_attr_uid); |
@@ -599,7 +599,7 @@ static void acpi_device_remove_files(struct acpi_device *dev) | |||
599 | 599 | ||
600 | if (dev->pnp.unique_id) | 600 | if (dev->pnp.unique_id) |
601 | device_remove_file(&dev->dev, &dev_attr_uid); | 601 | device_remove_file(&dev->dev, &dev_attr_uid); |
602 | if (dev->flags.bus_address) | 602 | if (dev->pnp.type.bus_address) |
603 | device_remove_file(&dev->dev, &dev_attr_adr); | 603 | device_remove_file(&dev->dev, &dev_attr_adr); |
604 | device_remove_file(&dev->dev, &dev_attr_modalias); | 604 | device_remove_file(&dev->dev, &dev_attr_modalias); |
605 | device_remove_file(&dev->dev, &dev_attr_hid); | 605 | device_remove_file(&dev->dev, &dev_attr_hid); |
@@ -1406,19 +1406,17 @@ static void acpi_device_get_busid(struct acpi_device *device) | |||
1406 | } | 1406 | } |
1407 | 1407 | ||
1408 | /* | 1408 | /* |
1409 | * acpi_bay_match - see if a device is an ejectable driver bay | 1409 | * acpi_bay_match - see if an acpi object is an ejectable driver bay |
1410 | * | 1410 | * |
1411 | * If an acpi object is ejectable and has one of the ACPI ATA methods defined, | 1411 | * If an acpi object is ejectable and has one of the ACPI ATA methods defined, |
1412 | * then we can safely call it an ejectable drive bay | 1412 | * then we can safely call it an ejectable drive bay |
1413 | */ | 1413 | */ |
1414 | static int acpi_bay_match(struct acpi_device *device){ | 1414 | static int acpi_bay_match(acpi_handle handle) |
1415 | { | ||
1415 | acpi_status status; | 1416 | acpi_status status; |
1416 | acpi_handle handle; | ||
1417 | acpi_handle tmp; | 1417 | acpi_handle tmp; |
1418 | acpi_handle phandle; | 1418 | acpi_handle phandle; |
1419 | 1419 | ||
1420 | handle = device->handle; | ||
1421 | |||
1422 | status = acpi_get_handle(handle, "_EJ0", &tmp); | 1420 | status = acpi_get_handle(handle, "_EJ0", &tmp); |
1423 | if (ACPI_FAILURE(status)) | 1421 | if (ACPI_FAILURE(status)) |
1424 | return -ENODEV; | 1422 | return -ENODEV; |
@@ -1442,12 +1440,12 @@ static int acpi_bay_match(struct acpi_device *device){ | |||
1442 | } | 1440 | } |
1443 | 1441 | ||
1444 | /* | 1442 | /* |
1445 | * acpi_dock_match - see if a device has a _DCK method | 1443 | * acpi_dock_match - see if an acpi object has a _DCK method |
1446 | */ | 1444 | */ |
1447 | static int acpi_dock_match(struct acpi_device *device) | 1445 | static int acpi_dock_match(acpi_handle handle) |
1448 | { | 1446 | { |
1449 | acpi_handle tmp; | 1447 | acpi_handle tmp; |
1450 | return acpi_get_handle(device->handle, "_DCK", &tmp); | 1448 | return acpi_get_handle(handle, "_DCK", &tmp); |
1451 | } | 1449 | } |
1452 | 1450 | ||
1453 | const char *acpi_device_hid(struct acpi_device *device) | 1451 | const char *acpi_device_hid(struct acpi_device *device) |
@@ -1462,7 +1460,7 @@ const char *acpi_device_hid(struct acpi_device *device) | |||
1462 | } | 1460 | } |
1463 | EXPORT_SYMBOL(acpi_device_hid); | 1461 | EXPORT_SYMBOL(acpi_device_hid); |
1464 | 1462 | ||
1465 | static void acpi_add_id(struct acpi_device *device, const char *dev_id) | 1463 | static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id) |
1466 | { | 1464 | { |
1467 | struct acpi_hardware_id *id; | 1465 | struct acpi_hardware_id *id; |
1468 | 1466 | ||
@@ -1476,7 +1474,8 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id) | |||
1476 | return; | 1474 | return; |
1477 | } | 1475 | } |
1478 | 1476 | ||
1479 | list_add_tail(&id->list, &device->pnp.ids); | 1477 | list_add_tail(&id->list, &pnp->ids); |
1478 | pnp->type.hardware_id = 1; | ||
1480 | } | 1479 | } |
1481 | 1480 | ||
1482 | /* | 1481 | /* |
@@ -1484,7 +1483,7 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id) | |||
1484 | * lacks the SMBUS01 HID and the methods do not have the necessary "_" | 1483 | * lacks the SMBUS01 HID and the methods do not have the necessary "_" |
1485 | * prefix. Work around this. | 1484 | * prefix. Work around this. |
1486 | */ | 1485 | */ |
1487 | static int acpi_ibm_smbus_match(struct acpi_device *device) | 1486 | static int acpi_ibm_smbus_match(acpi_handle handle) |
1488 | { | 1487 | { |
1489 | acpi_handle h_dummy; | 1488 | acpi_handle h_dummy; |
1490 | struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; | 1489 | struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; |
@@ -1494,7 +1493,7 @@ static int acpi_ibm_smbus_match(struct acpi_device *device) | |||
1494 | return -ENODEV; | 1493 | return -ENODEV; |
1495 | 1494 | ||
1496 | /* Look for SMBS object */ | 1495 | /* Look for SMBS object */ |
1497 | result = acpi_get_name(device->handle, ACPI_SINGLE_NAME, &path); | 1496 | result = acpi_get_name(handle, ACPI_SINGLE_NAME, &path); |
1498 | if (result) | 1497 | if (result) |
1499 | return result; | 1498 | return result; |
1500 | 1499 | ||
@@ -1505,9 +1504,9 @@ static int acpi_ibm_smbus_match(struct acpi_device *device) | |||
1505 | 1504 | ||
1506 | /* Does it have the necessary (but misnamed) methods? */ | 1505 | /* Does it have the necessary (but misnamed) methods? */ |
1507 | result = -ENODEV; | 1506 | result = -ENODEV; |
1508 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "SBI", &h_dummy)) && | 1507 | if (ACPI_SUCCESS(acpi_get_handle(handle, "SBI", &h_dummy)) && |
1509 | ACPI_SUCCESS(acpi_get_handle(device->handle, "SBR", &h_dummy)) && | 1508 | ACPI_SUCCESS(acpi_get_handle(handle, "SBR", &h_dummy)) && |
1510 | ACPI_SUCCESS(acpi_get_handle(device->handle, "SBW", &h_dummy))) | 1509 | ACPI_SUCCESS(acpi_get_handle(handle, "SBW", &h_dummy))) |
1511 | result = 0; | 1510 | result = 0; |
1512 | out: | 1511 | out: |
1513 | kfree(path.pointer); | 1512 | kfree(path.pointer); |
@@ -1524,7 +1523,7 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
1524 | switch (device->device_type) { | 1523 | switch (device->device_type) { |
1525 | case ACPI_BUS_TYPE_DEVICE: | 1524 | case ACPI_BUS_TYPE_DEVICE: |
1526 | if (ACPI_IS_ROOT_DEVICE(device)) { | 1525 | if (ACPI_IS_ROOT_DEVICE(device)) { |
1527 | acpi_add_id(device, ACPI_SYSTEM_HID); | 1526 | acpi_add_id(&device->pnp, ACPI_SYSTEM_HID); |
1528 | break; | 1527 | break; |
1529 | } | 1528 | } |
1530 | 1529 | ||
@@ -1535,15 +1534,15 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
1535 | } | 1534 | } |
1536 | 1535 | ||
1537 | if (info->valid & ACPI_VALID_HID) | 1536 | if (info->valid & ACPI_VALID_HID) |
1538 | acpi_add_id(device, info->hardware_id.string); | 1537 | acpi_add_id(&device->pnp, info->hardware_id.string); |
1539 | if (info->valid & ACPI_VALID_CID) { | 1538 | if (info->valid & ACPI_VALID_CID) { |
1540 | cid_list = &info->compatible_id_list; | 1539 | cid_list = &info->compatible_id_list; |
1541 | for (i = 0; i < cid_list->count; i++) | 1540 | for (i = 0; i < cid_list->count; i++) |
1542 | acpi_add_id(device, cid_list->ids[i].string); | 1541 | acpi_add_id(&device->pnp, cid_list->ids[i].string); |
1543 | } | 1542 | } |
1544 | if (info->valid & ACPI_VALID_ADR) { | 1543 | if (info->valid & ACPI_VALID_ADR) { |
1545 | device->pnp.bus_address = info->address; | 1544 | device->pnp.bus_address = info->address; |
1546 | device->flags.bus_address = 1; | 1545 | device->pnp.type.bus_address = 1; |
1547 | } | 1546 | } |
1548 | if (info->valid & ACPI_VALID_UID) | 1547 | if (info->valid & ACPI_VALID_UID) |
1549 | device->pnp.unique_id = kstrdup(info->unique_id.string, | 1548 | device->pnp.unique_id = kstrdup(info->unique_id.string, |
@@ -1555,36 +1554,36 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
1555 | * Some devices don't reliably have _HIDs & _CIDs, so add | 1554 | * Some devices don't reliably have _HIDs & _CIDs, so add |
1556 | * synthetic HIDs to make sure drivers can find them. | 1555 | * synthetic HIDs to make sure drivers can find them. |
1557 | */ | 1556 | */ |
1558 | if (acpi_is_video_device(device)) | 1557 | if (acpi_is_video_device(device->handle)) |
1559 | acpi_add_id(device, ACPI_VIDEO_HID); | 1558 | acpi_add_id(&device->pnp, ACPI_VIDEO_HID); |
1560 | else if (ACPI_SUCCESS(acpi_bay_match(device))) | 1559 | else if (ACPI_SUCCESS(acpi_bay_match(device->handle))) |
1561 | acpi_add_id(device, ACPI_BAY_HID); | 1560 | acpi_add_id(&device->pnp, ACPI_BAY_HID); |
1562 | else if (ACPI_SUCCESS(acpi_dock_match(device))) | 1561 | else if (ACPI_SUCCESS(acpi_dock_match(device->handle))) |
1563 | acpi_add_id(device, ACPI_DOCK_HID); | 1562 | acpi_add_id(&device->pnp, ACPI_DOCK_HID); |
1564 | else if (!acpi_ibm_smbus_match(device)) | 1563 | else if (!acpi_ibm_smbus_match(device->handle)) |
1565 | acpi_add_id(device, ACPI_SMBUS_IBM_HID); | 1564 | acpi_add_id(&device->pnp, ACPI_SMBUS_IBM_HID); |
1566 | else if (list_empty(&device->pnp.ids) && | 1565 | else if (list_empty(&device->pnp.ids) && |
1567 | ACPI_IS_ROOT_DEVICE(device->parent)) { | 1566 | ACPI_IS_ROOT_DEVICE(device->parent)) { |
1568 | acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ | 1567 | acpi_add_id(&device->pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ |
1569 | strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); | 1568 | strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); |
1570 | strcpy(device->pnp.device_class, ACPI_BUS_CLASS); | 1569 | strcpy(device->pnp.device_class, ACPI_BUS_CLASS); |
1571 | } | 1570 | } |
1572 | 1571 | ||
1573 | break; | 1572 | break; |
1574 | case ACPI_BUS_TYPE_POWER: | 1573 | case ACPI_BUS_TYPE_POWER: |
1575 | acpi_add_id(device, ACPI_POWER_HID); | 1574 | acpi_add_id(&device->pnp, ACPI_POWER_HID); |
1576 | break; | 1575 | break; |
1577 | case ACPI_BUS_TYPE_PROCESSOR: | 1576 | case ACPI_BUS_TYPE_PROCESSOR: |
1578 | acpi_add_id(device, ACPI_PROCESSOR_OBJECT_HID); | 1577 | acpi_add_id(&device->pnp, ACPI_PROCESSOR_OBJECT_HID); |
1579 | break; | 1578 | break; |
1580 | case ACPI_BUS_TYPE_THERMAL: | 1579 | case ACPI_BUS_TYPE_THERMAL: |
1581 | acpi_add_id(device, ACPI_THERMAL_HID); | 1580 | acpi_add_id(&device->pnp, ACPI_THERMAL_HID); |
1582 | break; | 1581 | break; |
1583 | case ACPI_BUS_TYPE_POWER_BUTTON: | 1582 | case ACPI_BUS_TYPE_POWER_BUTTON: |
1584 | acpi_add_id(device, ACPI_BUTTON_HID_POWERF); | 1583 | acpi_add_id(&device->pnp, ACPI_BUTTON_HID_POWERF); |
1585 | break; | 1584 | break; |
1586 | case ACPI_BUS_TYPE_SLEEP_BUTTON: | 1585 | case ACPI_BUS_TYPE_SLEEP_BUTTON: |
1587 | acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF); | 1586 | acpi_add_id(&device->pnp, ACPI_BUTTON_HID_SLEEPF); |
1588 | break; | 1587 | break; |
1589 | } | 1588 | } |
1590 | } | 1589 | } |
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index 4ac2593234e7..66f67626f02e 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c | |||
@@ -67,40 +67,37 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, | |||
67 | return 0; | 67 | return 0; |
68 | } | 68 | } |
69 | 69 | ||
70 | /* Returns true if the device is a video device which can be handled by | 70 | /* Returns true if the ACPI object is a video device which can be |
71 | * video.ko. | 71 | * handled by video.ko. |
72 | * The device will get a Linux specific CID added in scan.c to | 72 | * The device will get a Linux specific CID added in scan.c to |
73 | * identify the device as an ACPI graphics device | 73 | * identify the device as an ACPI graphics device |
74 | * Be aware that the graphics device may not be physically present | 74 | * Be aware that the graphics device may not be physically present |
75 | * Use acpi_video_get_capabilities() to detect general ACPI video | 75 | * Use acpi_video_get_capabilities() to detect general ACPI video |
76 | * capabilities of present cards | 76 | * capabilities of present cards |
77 | */ | 77 | */ |
78 | long acpi_is_video_device(struct acpi_device *device) | 78 | long acpi_is_video_device(acpi_handle handle) |
79 | { | 79 | { |
80 | acpi_handle h_dummy; | 80 | acpi_handle h_dummy; |
81 | long video_caps = 0; | 81 | long video_caps = 0; |
82 | 82 | ||
83 | if (!device) | ||
84 | return 0; | ||
85 | |||
86 | /* Is this device able to support video switching ? */ | 83 | /* Is this device able to support video switching ? */ |
87 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) || | 84 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_DOD", &h_dummy)) || |
88 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy))) | 85 | ACPI_SUCCESS(acpi_get_handle(handle, "_DOS", &h_dummy))) |
89 | video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; | 86 | video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; |
90 | 87 | ||
91 | /* Is this device able to retrieve a video ROM ? */ | 88 | /* Is this device able to retrieve a video ROM ? */ |
92 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy))) | 89 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_ROM", &h_dummy))) |
93 | video_caps |= ACPI_VIDEO_ROM_AVAILABLE; | 90 | video_caps |= ACPI_VIDEO_ROM_AVAILABLE; |
94 | 91 | ||
95 | /* Is this device able to configure which video head to be POSTed ? */ | 92 | /* Is this device able to configure which video head to be POSTed ? */ |
96 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) && | 93 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_VPO", &h_dummy)) && |
97 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) && | 94 | ACPI_SUCCESS(acpi_get_handle(handle, "_GPD", &h_dummy)) && |
98 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy))) | 95 | ACPI_SUCCESS(acpi_get_handle(handle, "_SPD", &h_dummy))) |
99 | video_caps |= ACPI_VIDEO_DEVICE_POSTING; | 96 | video_caps |= ACPI_VIDEO_DEVICE_POSTING; |
100 | 97 | ||
101 | /* Only check for backlight functionality if one of the above hit. */ | 98 | /* Only check for backlight functionality if one of the above hit. */ |
102 | if (video_caps) | 99 | if (video_caps) |
103 | acpi_walk_namespace(ACPI_TYPE_DEVICE, device->handle, | 100 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, |
104 | ACPI_UINT32_MAX, acpi_backlight_cap_match, NULL, | 101 | ACPI_UINT32_MAX, acpi_backlight_cap_match, NULL, |
105 | &video_caps, NULL); | 102 | &video_caps, NULL); |
106 | 103 | ||
@@ -127,7 +124,7 @@ find_video(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
127 | if (!dev) | 124 | if (!dev) |
128 | return AE_OK; | 125 | return AE_OK; |
129 | pci_dev_put(dev); | 126 | pci_dev_put(dev); |
130 | *cap |= acpi_is_video_device(acpi_dev); | 127 | *cap |= acpi_is_video_device(handle); |
131 | } | 128 | } |
132 | return AE_OK; | 129 | return AE_OK; |
133 | } | 130 | } |
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c index 4d338740f2cb..a8117e614009 100644 --- a/drivers/gpu/drm/i915/intel_opregion.c +++ b/drivers/gpu/drm/i915/intel_opregion.c | |||
@@ -350,11 +350,11 @@ static void intel_didl_outputs(struct drm_device *dev) | |||
350 | if (!handle || acpi_bus_get_device(handle, &acpi_dev)) | 350 | if (!handle || acpi_bus_get_device(handle, &acpi_dev)) |
351 | return; | 351 | return; |
352 | 352 | ||
353 | if (acpi_is_video_device(acpi_dev)) | 353 | if (acpi_is_video_device(handle)) |
354 | acpi_video_bus = acpi_dev; | 354 | acpi_video_bus = acpi_dev; |
355 | else { | 355 | else { |
356 | list_for_each_entry(acpi_cdev, &acpi_dev->children, node) { | 356 | list_for_each_entry(acpi_cdev, &acpi_dev->children, node) { |
357 | if (acpi_is_video_device(acpi_cdev)) { | 357 | if (acpi_is_video_device(acpi_cdev->handle)) { |
358 | acpi_video_bus = acpi_cdev; | 358 | acpi_video_bus = acpi_cdev; |
359 | break; | 359 | break; |
360 | } | 360 | } |