scan.c (2bd74d91b1217d84d08db57b860d056d130248d3) scan.c (be27b3dcb02335ec093b81053fc8c84b32d3106e)
1/*
2 * scan.c - support for transforming the ACPI namespace into individual objects
3 */
4
5#include <linux/module.h>
6#include <linux/init.h>
7#include <linux/slab.h>
8#include <linux/kernel.h>

--- 473 unchanged lines hidden (view full) ---

482 /*
483 * The device object's ACPI handle cannot become invalid as long as we
484 * are holding acpi_scan_lock, but it might have become invalid before
485 * that lock was acquired.
486 */
487 if (adev->handle == INVALID_ACPI_HANDLE)
488 goto err_out;
489
1/*
2 * scan.c - support for transforming the ACPI namespace into individual objects
3 */
4
5#include <linux/module.h>
6#include <linux/init.h>
7#include <linux/slab.h>
8#include <linux/kernel.h>

--- 473 unchanged lines hidden (view full) ---

482 /*
483 * The device object's ACPI handle cannot become invalid as long as we
484 * are holding acpi_scan_lock, but it might have become invalid before
485 * that lock was acquired.
486 */
487 if (adev->handle == INVALID_ACPI_HANDLE)
488 goto err_out;
489
490 if (adev->flags.hotplug_notify) {
490 if (adev->flags.is_dock_station) {
491 error = dock_notify(adev, src);
492 } else if (adev->flags.hotplug_notify) {
491 error = acpi_generic_hotplug_event(adev, src);
492 if (error == -EPERM) {
493 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
494 goto err_out;
495 }
496 } else {
493 error = acpi_generic_hotplug_event(adev, src);
494 if (error == -EPERM) {
495 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
496 goto err_out;
497 }
498 } else {
497 int (*event)(struct acpi_device *, u32);
499 int (*notify)(struct acpi_device *, u32);
498
499 acpi_lock_hp_context();
500
501 acpi_lock_hp_context();
500 event = adev->hp ? adev->hp->event : NULL;
502 notify = adev->hp ? adev->hp->notify : NULL;
501 acpi_unlock_hp_context();
502 /*
503 * There may be additional notify handlers for device objects
504 * without the .event() callback, so ignore them here.
505 */
503 acpi_unlock_hp_context();
504 /*
505 * There may be additional notify handlers for device objects
506 * without the .event() callback, so ignore them here.
507 */
506 if (event)
507 error = event(adev, src);
508 if (notify)
509 error = notify(adev, src);
508 else
509 goto out;
510 }
511 if (!error)
512 ost_code = ACPI_OST_SC_SUCCESS;
513
514 err_out:
515 acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL);

--- 1139 unchanged lines hidden (view full) ---

1655 if (acpi_ata_match(handle))
1656 return true;
1657 if (ACPI_FAILURE(acpi_get_parent(handle, &phandle)))
1658 return false;
1659
1660 return acpi_ata_match(phandle);
1661}
1662
510 else
511 goto out;
512 }
513 if (!error)
514 ost_code = ACPI_OST_SC_SUCCESS;
515
516 err_out:
517 acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL);

--- 1139 unchanged lines hidden (view full) ---

1657 if (acpi_ata_match(handle))
1658 return true;
1659 if (ACPI_FAILURE(acpi_get_parent(handle, &phandle)))
1660 return false;
1661
1662 return acpi_ata_match(phandle);
1663}
1664
1665bool acpi_device_is_battery(struct acpi_device *adev)
1666{
1667 struct acpi_hardware_id *hwid;
1668
1669 list_for_each_entry(hwid, &adev->pnp.ids, list)
1670 if (!strcmp("PNP0C0A", hwid->id))
1671 return true;
1672
1673 return false;
1674}
1675
1676static bool is_ejectable_bay(struct acpi_device *adev)
1677{
1678 acpi_handle handle = adev->handle;
1679
1680 if (acpi_has_method(handle, "_EJ0") && acpi_device_is_battery(adev))
1681 return true;
1682
1683 return acpi_bay_match(handle);
1684}
1685
1663/*
1664 * acpi_dock_match - see if an acpi object has a _DCK method
1665 */
1666bool acpi_dock_match(acpi_handle handle)
1667{
1668 return acpi_has_method(handle, "_DCK");
1669}
1670

--- 49 unchanged lines hidden (view full) ---

1720 if (acpi_has_method(handle, "SBI") &&
1721 acpi_has_method(handle, "SBR") &&
1722 acpi_has_method(handle, "SBW"))
1723 return true;
1724
1725 return false;
1726}
1727
1686/*
1687 * acpi_dock_match - see if an acpi object has a _DCK method
1688 */
1689bool acpi_dock_match(acpi_handle handle)
1690{
1691 return acpi_has_method(handle, "_DCK");
1692}
1693

--- 49 unchanged lines hidden (view full) ---

1743 if (acpi_has_method(handle, "SBI") &&
1744 acpi_has_method(handle, "SBR") &&
1745 acpi_has_method(handle, "SBW"))
1746 return true;
1747
1748 return false;
1749}
1750
1728static bool acpi_object_is_system_bus(acpi_handle handle)
1729{
1730 acpi_handle tmp;
1731
1732 if (ACPI_SUCCESS(acpi_get_handle(NULL, "\\_SB", &tmp)) &&
1733 tmp == handle)
1734 return true;
1735 if (ACPI_SUCCESS(acpi_get_handle(NULL, "\\_TZ", &tmp)) &&
1736 tmp == handle)
1737 return true;
1738
1739 return false;
1740}
1741
1742static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
1743 int device_type)
1744{
1745 acpi_status status;
1746 struct acpi_device_info *info;
1747 struct acpi_pnp_device_id_list *cid_list;
1748 int i;
1749

--- 35 unchanged lines hidden (view full) ---

1785 if (acpi_is_video_device(handle))
1786 acpi_add_id(pnp, ACPI_VIDEO_HID);
1787 else if (acpi_bay_match(handle))
1788 acpi_add_id(pnp, ACPI_BAY_HID);
1789 else if (acpi_dock_match(handle))
1790 acpi_add_id(pnp, ACPI_DOCK_HID);
1791 else if (acpi_ibm_smbus_match(handle))
1792 acpi_add_id(pnp, ACPI_SMBUS_IBM_HID);
1751static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
1752 int device_type)
1753{
1754 acpi_status status;
1755 struct acpi_device_info *info;
1756 struct acpi_pnp_device_id_list *cid_list;
1757 int i;
1758

--- 35 unchanged lines hidden (view full) ---

1794 if (acpi_is_video_device(handle))
1795 acpi_add_id(pnp, ACPI_VIDEO_HID);
1796 else if (acpi_bay_match(handle))
1797 acpi_add_id(pnp, ACPI_BAY_HID);
1798 else if (acpi_dock_match(handle))
1799 acpi_add_id(pnp, ACPI_DOCK_HID);
1800 else if (acpi_ibm_smbus_match(handle))
1801 acpi_add_id(pnp, ACPI_SMBUS_IBM_HID);
1793 else if (list_empty(&pnp->ids) &&
1794 acpi_object_is_system_bus(handle)) {
1795 /* \_SB, \_TZ, LNXSYBUS */
1796 acpi_add_id(pnp, ACPI_BUS_HID);
1802 else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) {
1803 acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
1797 strcpy(pnp->device_name, ACPI_BUS_DEVICE_NAME);
1798 strcpy(pnp->device_class, ACPI_BUS_CLASS);
1799 }
1800
1801 break;
1802 case ACPI_BUS_TYPE_POWER:
1803 acpi_add_id(pnp, ACPI_POWER_HID);
1804 break;

--- 170 unchanged lines hidden (view full) ---

1975
1976 mutex_unlock(&acpi_scan_lock);
1977}
1978
1979static void acpi_scan_init_hotplug(struct acpi_device *adev)
1980{
1981 struct acpi_hardware_id *hwid;
1982
1804 strcpy(pnp->device_name, ACPI_BUS_DEVICE_NAME);
1805 strcpy(pnp->device_class, ACPI_BUS_CLASS);
1806 }
1807
1808 break;
1809 case ACPI_BUS_TYPE_POWER:
1810 acpi_add_id(pnp, ACPI_POWER_HID);
1811 break;

--- 170 unchanged lines hidden (view full) ---

1982
1983 mutex_unlock(&acpi_scan_lock);
1984}
1985
1986static void acpi_scan_init_hotplug(struct acpi_device *adev)
1987{
1988 struct acpi_hardware_id *hwid;
1989
1990 if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev)) {
1991 acpi_dock_add(adev);
1992 return;
1993 }
1983 list_for_each_entry(hwid, &adev->pnp.ids, list) {
1984 struct acpi_scan_handler *handler;
1985
1986 handler = acpi_scan_match_handler(hwid->id, NULL);
1987 if (handler) {
1988 adev->flags.hotplug_notify = true;
1989 break;
1990 }

--- 55 unchanged lines hidden (view full) ---

2046 }
2047 }
2048 return ret;
2049}
2050
2051static void acpi_bus_attach(struct acpi_device *device)
2052{
2053 struct acpi_device *child;
1994 list_for_each_entry(hwid, &adev->pnp.ids, list) {
1995 struct acpi_scan_handler *handler;
1996
1997 handler = acpi_scan_match_handler(hwid->id, NULL);
1998 if (handler) {
1999 adev->flags.hotplug_notify = true;
2000 break;
2001 }

--- 55 unchanged lines hidden (view full) ---

2057 }
2058 }
2059 return ret;
2060}
2061
2062static void acpi_bus_attach(struct acpi_device *device)
2063{
2064 struct acpi_device *child;
2065 acpi_handle ejd;
2054 int ret;
2055
2066 int ret;
2067
2068 if (ACPI_SUCCESS(acpi_bus_get_ejd(device->handle, &ejd)))
2069 register_dock_dependent_device(device, ejd);
2070
2056 acpi_bus_get_status(device);
2057 /* Skip devices that are not present. */
2058 if (!acpi_device_is_present(device)) {
2059 device->flags.visited = false;
2060 return;
2061 }
2062 if (device->handler)
2063 goto ok;

--- 136 unchanged lines hidden (view full) ---

2200 acpi_pci_root_init();
2201 acpi_pci_link_init();
2202 acpi_processor_init();
2203 acpi_platform_init();
2204 acpi_lpss_init();
2205 acpi_cmos_rtc_init();
2206 acpi_container_init();
2207 acpi_memory_hotplug_init();
2071 acpi_bus_get_status(device);
2072 /* Skip devices that are not present. */
2073 if (!acpi_device_is_present(device)) {
2074 device->flags.visited = false;
2075 return;
2076 }
2077 if (device->handler)
2078 goto ok;

--- 136 unchanged lines hidden (view full) ---

2215 acpi_pci_root_init();
2216 acpi_pci_link_init();
2217 acpi_processor_init();
2218 acpi_platform_init();
2219 acpi_lpss_init();
2220 acpi_cmos_rtc_init();
2221 acpi_container_init();
2222 acpi_memory_hotplug_init();
2208 acpi_dock_init();
2209
2210 mutex_lock(&acpi_scan_lock);
2211 /*
2212 * Enumerate devices in the ACPI namespace.
2213 */
2214 result = acpi_bus_scan(ACPI_ROOT_OBJECT);
2215 if (result)
2216 goto out;

--- 19 unchanged lines hidden ---
2223
2224 mutex_lock(&acpi_scan_lock);
2225 /*
2226 * Enumerate devices in the ACPI namespace.
2227 */
2228 result = acpi_bus_scan(ACPI_ROOT_OBJECT);
2229 if (result)
2230 goto out;

--- 19 unchanged lines hidden ---