diff options
author | Toshi Kani <toshi.kani@hp.com> | 2013-03-04 16:30:42 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-24 18:49:38 -0400 |
commit | c0af41757f406651cdd32de3e915753746c2948a (patch) | |
tree | 858ef62a6236395d0e77e8ce1a66556c8ba6b950 | |
parent | d4e1a692e9e85f9cbee090ea8d6158b133d32157 (diff) |
ACPI: Update PNPID set/free interfaces
This patch introduces acpi_set_pnp_ids() and acpi_free_pnp_ids(),
which are updated from acpi_device_set_id() and acpi_free_ids(),
to setup and free acpi_device_pnp for a given acpi_handle. They
can be called without acpi_device.
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/internal.h | 2 | ||||
-rw-r--r-- | drivers/acpi/power.c | 2 | ||||
-rw-r--r-- | drivers/acpi/scan.c | 85 |
3 files changed, 45 insertions, 44 deletions
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 7215821ccb25..7f094adfe05a 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h | |||
@@ -71,7 +71,7 @@ int acpi_device_add(struct acpi_device *device, | |||
71 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | 71 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, |
72 | int type, unsigned long long sta); | 72 | int type, unsigned long long sta); |
73 | void acpi_device_add_finalize(struct acpi_device *device); | 73 | void acpi_device_add_finalize(struct acpi_device *device); |
74 | void acpi_free_ids(struct acpi_device *device); | 74 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); |
75 | 75 | ||
76 | /* -------------------------------------------------------------------------- | 76 | /* -------------------------------------------------------------------------- |
77 | Power Resource | 77 | Power Resource |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 34f5ef11d427..0481b1b1d2aa 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -824,7 +824,7 @@ static void acpi_release_power_resource(struct device *dev) | |||
824 | list_del(&resource->list_node); | 824 | list_del(&resource->list_node); |
825 | mutex_unlock(&power_resource_list_lock); | 825 | mutex_unlock(&power_resource_list_lock); |
826 | 826 | ||
827 | acpi_free_ids(device); | 827 | acpi_free_pnp_ids(&device->pnp); |
828 | kfree(resource); | 828 | kfree(resource); |
829 | } | 829 | } |
830 | 830 | ||
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index f9c698d766f1..e9a71ed9954a 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -662,17 +662,6 @@ int acpi_match_device_ids(struct acpi_device *device, | |||
662 | } | 662 | } |
663 | EXPORT_SYMBOL(acpi_match_device_ids); | 663 | EXPORT_SYMBOL(acpi_match_device_ids); |
664 | 664 | ||
665 | void acpi_free_ids(struct acpi_device *device) | ||
666 | { | ||
667 | struct acpi_hardware_id *id, *tmp; | ||
668 | |||
669 | list_for_each_entry_safe(id, tmp, &device->pnp.ids, list) { | ||
670 | kfree(id->id); | ||
671 | kfree(id); | ||
672 | } | ||
673 | kfree(device->pnp.unique_id); | ||
674 | } | ||
675 | |||
676 | static void acpi_free_power_resources_lists(struct acpi_device *device) | 665 | static void acpi_free_power_resources_lists(struct acpi_device *device) |
677 | { | 666 | { |
678 | int i; | 667 | int i; |
@@ -693,7 +682,7 @@ static void acpi_device_release(struct device *dev) | |||
693 | { | 682 | { |
694 | struct acpi_device *acpi_dev = to_acpi_device(dev); | 683 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
695 | 684 | ||
696 | acpi_free_ids(acpi_dev); | 685 | acpi_free_pnp_ids(&acpi_dev->pnp); |
697 | acpi_free_power_resources_lists(acpi_dev); | 686 | acpi_free_power_resources_lists(acpi_dev); |
698 | kfree(acpi_dev); | 687 | kfree(acpi_dev); |
699 | } | 688 | } |
@@ -1513,39 +1502,41 @@ out: | |||
1513 | return result; | 1502 | return result; |
1514 | } | 1503 | } |
1515 | 1504 | ||
1516 | static void acpi_device_set_id(struct acpi_device *device) | 1505 | static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, |
1506 | int device_type) | ||
1517 | { | 1507 | { |
1518 | acpi_status status; | 1508 | acpi_status status; |
1519 | struct acpi_device_info *info; | 1509 | struct acpi_device_info *info; |
1520 | struct acpi_pnp_device_id_list *cid_list; | 1510 | struct acpi_pnp_device_id_list *cid_list; |
1521 | int i; | 1511 | int i; |
1522 | 1512 | ||
1523 | switch (device->device_type) { | 1513 | switch (device_type) { |
1524 | case ACPI_BUS_TYPE_DEVICE: | 1514 | case ACPI_BUS_TYPE_DEVICE: |
1525 | if (ACPI_IS_ROOT_DEVICE(device)) { | 1515 | if (handle == ACPI_ROOT_OBJECT) { |
1526 | acpi_add_id(&device->pnp, ACPI_SYSTEM_HID); | 1516 | acpi_add_id(pnp, ACPI_SYSTEM_HID); |
1527 | break; | 1517 | break; |
1528 | } | 1518 | } |
1529 | 1519 | ||
1530 | status = acpi_get_object_info(device->handle, &info); | 1520 | status = acpi_get_object_info(handle, &info); |
1531 | if (ACPI_FAILURE(status)) { | 1521 | if (ACPI_FAILURE(status)) { |
1532 | printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__); | 1522 | pr_err(PREFIX "%s: Error reading device info\n", |
1523 | __func__); | ||
1533 | return; | 1524 | return; |
1534 | } | 1525 | } |
1535 | 1526 | ||
1536 | if (info->valid & ACPI_VALID_HID) | 1527 | if (info->valid & ACPI_VALID_HID) |
1537 | acpi_add_id(&device->pnp, info->hardware_id.string); | 1528 | acpi_add_id(pnp, info->hardware_id.string); |
1538 | if (info->valid & ACPI_VALID_CID) { | 1529 | if (info->valid & ACPI_VALID_CID) { |
1539 | cid_list = &info->compatible_id_list; | 1530 | cid_list = &info->compatible_id_list; |
1540 | for (i = 0; i < cid_list->count; i++) | 1531 | for (i = 0; i < cid_list->count; i++) |
1541 | acpi_add_id(&device->pnp, cid_list->ids[i].string); | 1532 | acpi_add_id(pnp, cid_list->ids[i].string); |
1542 | } | 1533 | } |
1543 | if (info->valid & ACPI_VALID_ADR) { | 1534 | if (info->valid & ACPI_VALID_ADR) { |
1544 | device->pnp.bus_address = info->address; | 1535 | pnp->bus_address = info->address; |
1545 | device->pnp.type.bus_address = 1; | 1536 | pnp->type.bus_address = 1; |
1546 | } | 1537 | } |
1547 | if (info->valid & ACPI_VALID_UID) | 1538 | if (info->valid & ACPI_VALID_UID) |
1548 | device->pnp.unique_id = kstrdup(info->unique_id.string, | 1539 | pnp->unique_id = kstrdup(info->unique_id.string, |
1549 | GFP_KERNEL); | 1540 | GFP_KERNEL); |
1550 | 1541 | ||
1551 | kfree(info); | 1542 | kfree(info); |
@@ -1554,40 +1545,50 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
1554 | * Some devices don't reliably have _HIDs & _CIDs, so add | 1545 | * Some devices don't reliably have _HIDs & _CIDs, so add |
1555 | * synthetic HIDs to make sure drivers can find them. | 1546 | * synthetic HIDs to make sure drivers can find them. |
1556 | */ | 1547 | */ |
1557 | if (acpi_is_video_device(device->handle)) | 1548 | if (acpi_is_video_device(handle)) |
1558 | acpi_add_id(&device->pnp, ACPI_VIDEO_HID); | 1549 | acpi_add_id(pnp, ACPI_VIDEO_HID); |
1559 | else if (ACPI_SUCCESS(acpi_bay_match(device->handle))) | 1550 | else if (ACPI_SUCCESS(acpi_bay_match(handle))) |
1560 | acpi_add_id(&device->pnp, ACPI_BAY_HID); | 1551 | acpi_add_id(pnp, ACPI_BAY_HID); |
1561 | else if (ACPI_SUCCESS(acpi_dock_match(device->handle))) | 1552 | else if (ACPI_SUCCESS(acpi_dock_match(handle))) |
1562 | acpi_add_id(&device->pnp, ACPI_DOCK_HID); | 1553 | acpi_add_id(pnp, ACPI_DOCK_HID); |
1563 | else if (!acpi_ibm_smbus_match(device->handle)) | 1554 | else if (!acpi_ibm_smbus_match(handle)) |
1564 | acpi_add_id(&device->pnp, ACPI_SMBUS_IBM_HID); | 1555 | acpi_add_id(pnp, ACPI_SMBUS_IBM_HID); |
1565 | else if (list_empty(&device->pnp.ids) && | 1556 | else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) { |
1566 | ACPI_IS_ROOT_DEVICE(device->parent)) { | 1557 | acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ |
1567 | acpi_add_id(&device->pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ | 1558 | strcpy(pnp->device_name, ACPI_BUS_DEVICE_NAME); |
1568 | strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); | 1559 | strcpy(pnp->device_class, ACPI_BUS_CLASS); |
1569 | strcpy(device->pnp.device_class, ACPI_BUS_CLASS); | ||
1570 | } | 1560 | } |
1571 | 1561 | ||
1572 | break; | 1562 | break; |
1573 | case ACPI_BUS_TYPE_POWER: | 1563 | case ACPI_BUS_TYPE_POWER: |
1574 | acpi_add_id(&device->pnp, ACPI_POWER_HID); | 1564 | acpi_add_id(pnp, ACPI_POWER_HID); |
1575 | break; | 1565 | break; |
1576 | case ACPI_BUS_TYPE_PROCESSOR: | 1566 | case ACPI_BUS_TYPE_PROCESSOR: |
1577 | acpi_add_id(&device->pnp, ACPI_PROCESSOR_OBJECT_HID); | 1567 | acpi_add_id(pnp, ACPI_PROCESSOR_OBJECT_HID); |
1578 | break; | 1568 | break; |
1579 | case ACPI_BUS_TYPE_THERMAL: | 1569 | case ACPI_BUS_TYPE_THERMAL: |
1580 | acpi_add_id(&device->pnp, ACPI_THERMAL_HID); | 1570 | acpi_add_id(pnp, ACPI_THERMAL_HID); |
1581 | break; | 1571 | break; |
1582 | case ACPI_BUS_TYPE_POWER_BUTTON: | 1572 | case ACPI_BUS_TYPE_POWER_BUTTON: |
1583 | acpi_add_id(&device->pnp, ACPI_BUTTON_HID_POWERF); | 1573 | acpi_add_id(pnp, ACPI_BUTTON_HID_POWERF); |
1584 | break; | 1574 | break; |
1585 | case ACPI_BUS_TYPE_SLEEP_BUTTON: | 1575 | case ACPI_BUS_TYPE_SLEEP_BUTTON: |
1586 | acpi_add_id(&device->pnp, ACPI_BUTTON_HID_SLEEPF); | 1576 | acpi_add_id(pnp, ACPI_BUTTON_HID_SLEEPF); |
1587 | break; | 1577 | break; |
1588 | } | 1578 | } |
1589 | } | 1579 | } |
1590 | 1580 | ||
1581 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp) | ||
1582 | { | ||
1583 | struct acpi_hardware_id *id, *tmp; | ||
1584 | |||
1585 | list_for_each_entry_safe(id, tmp, &pnp->ids, list) { | ||
1586 | kfree(id->id); | ||
1587 | kfree(id); | ||
1588 | } | ||
1589 | kfree(pnp->unique_id); | ||
1590 | } | ||
1591 | |||
1591 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | 1592 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, |
1592 | int type, unsigned long long sta) | 1593 | int type, unsigned long long sta) |
1593 | { | 1594 | { |
@@ -1597,7 +1598,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
1597 | device->parent = acpi_bus_get_parent(handle); | 1598 | device->parent = acpi_bus_get_parent(handle); |
1598 | STRUCT_TO_INT(device->status) = sta; | 1599 | STRUCT_TO_INT(device->status) = sta; |
1599 | acpi_device_get_busid(device); | 1600 | acpi_device_get_busid(device); |
1600 | acpi_device_set_id(device); | 1601 | acpi_set_pnp_ids(handle, &device->pnp, type); |
1601 | acpi_bus_get_flags(device); | 1602 | acpi_bus_get_flags(device); |
1602 | device->flags.match_driver = false; | 1603 | device->flags.match_driver = false; |
1603 | device_initialize(&device->dev); | 1604 | device_initialize(&device->dev); |