aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2013-01-25 13:26:36 -0500
committerBjorn Helgaas <bhelgaas@google.com>2013-01-25 13:26:36 -0500
commita2766602ac6885f9514abd97821984cd152cdad3 (patch)
tree8932650a9accababfcc37daf515aa75cb0df7749 /drivers/acpi
parent295a7f6235bfa21be3454aebc1bea1eaf0b74fb7 (diff)
parentb8bd759acd05281abf88cddef30c57313c109697 (diff)
Merge branch 'acpi-scan' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm into pci/acpi-scan2
* 'acpi-scan' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI / scan: Drop acpi_bus_add() and use acpi_bus_scan() instead ACPI: update ej_event interface to take acpi_device ACPI / scan: Add second pass to acpi_bus_trim() ACPI / scan: Change the implementation of acpi_bus_trim() ACPI / scan: Drop the second argument of acpi_bus_trim() ACPI / scan: Drop the second argument of acpi_device_unregister() ACPI: Remove the ops field from struct acpi_device ACPI: remove unused acpi_op_bind and acpi_op_unbind ACPI / scan: Fix check of device_attach() return value.
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_memhotplug.c4
-rw-r--r--drivers/acpi/container.c2
-rw-r--r--drivers/acpi/dock.c4
-rw-r--r--drivers/acpi/processor_driver.c4
-rw-r--r--drivers/acpi/scan.c168
5 files changed, 69 insertions, 113 deletions
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 327ab4459558..15ea22fc1f5e 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -167,7 +167,7 @@ acpi_memory_get_device(acpi_handle handle,
167 * Now add the notified device. This creates the acpi_device 167 * Now add the notified device. This creates the acpi_device
168 * and invokes .add function 168 * and invokes .add function
169 */ 169 */
170 result = acpi_bus_add(handle); 170 result = acpi_bus_scan(handle);
171 if (result) { 171 if (result) {
172 acpi_handle_warn(handle, "Cannot add acpi bus\n"); 172 acpi_handle_warn(handle, "Cannot add acpi bus\n");
173 return -EINVAL; 173 return -EINVAL;
@@ -361,7 +361,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
361 break; 361 break;
362 } 362 }
363 363
364 ej_event->handle = handle; 364 ej_event->device = device;
365 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 365 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
366 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, 366 acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
367 (void *)ej_event); 367 (void *)ej_event);
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index f8fb2281f34a..cc79d3e53a39 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -166,7 +166,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
166 if (!ACPI_FAILURE(status) || device) 166 if (!ACPI_FAILURE(status) || device)
167 break; 167 break;
168 168
169 result = acpi_bus_add(handle); 169 result = acpi_bus_scan(handle);
170 if (result) { 170 if (result) {
171 acpi_handle_warn(handle, "Failed to add container\n"); 171 acpi_handle_warn(handle, "Failed to add container\n");
172 break; 172 break;
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 9e31b2bd93d3..420d24fc9388 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -317,7 +317,7 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
317 * no device created for this object, 317 * no device created for this object,
318 * so we should create one. 318 * so we should create one.
319 */ 319 */
320 ret = acpi_bus_add(handle); 320 ret = acpi_bus_scan(handle);
321 if (ret) 321 if (ret)
322 pr_debug("error adding bus, %x\n", -ret); 322 pr_debug("error adding bus, %x\n", -ret);
323 323
@@ -339,7 +339,7 @@ static void dock_remove_acpi_device(acpi_handle handle)
339 int ret; 339 int ret;
340 340
341 if (!acpi_bus_get_device(handle, &device)) { 341 if (!acpi_bus_get_device(handle, &device)) {
342 ret = acpi_bus_trim(device, 1); 342 ret = acpi_bus_trim(device);
343 if (ret) 343 if (ret)
344 pr_debug("error removing bus, %x\n", -ret); 344 pr_debug("error removing bus, %x\n", -ret);
345 } 345 }
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 0777663f443e..9c5929a17d3a 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -699,7 +699,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
699 if (!acpi_bus_get_device(handle, &device)) 699 if (!acpi_bus_get_device(handle, &device))
700 break; 700 break;
701 701
702 result = acpi_bus_add(handle); 702 result = acpi_bus_scan(handle);
703 if (result) { 703 if (result) {
704 acpi_handle_err(handle, "Unable to add the device\n"); 704 acpi_handle_err(handle, "Unable to add the device\n");
705 break; 705 break;
@@ -733,7 +733,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
733 break; 733 break;
734 } 734 }
735 735
736 ej_event->handle = handle; 736 ej_event->device = device;
737 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 737 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
738 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, 738 acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
739 (void *)ej_event); 739 (void *)ej_event);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index e380345b643a..7c43bdc36abc 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -116,24 +116,18 @@ static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
116void acpi_bus_hot_remove_device(void *context) 116void acpi_bus_hot_remove_device(void *context)
117{ 117{
118 struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context; 118 struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context;
119 struct acpi_device *device; 119 struct acpi_device *device = ej_event->device;
120 acpi_handle handle = ej_event->handle; 120 acpi_handle handle = device->handle;
121 acpi_handle temp; 121 acpi_handle temp;
122 struct acpi_object_list arg_list; 122 struct acpi_object_list arg_list;
123 union acpi_object arg; 123 union acpi_object arg;
124 acpi_status status = AE_OK; 124 acpi_status status = AE_OK;
125 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ 125 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
126 126
127 if (acpi_bus_get_device(handle, &device))
128 goto err_out;
129
130 if (!device)
131 goto err_out;
132
133 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 127 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
134 "Hot-removing device %s...\n", dev_name(&device->dev))); 128 "Hot-removing device %s...\n", dev_name(&device->dev)));
135 129
136 if (acpi_bus_trim(device, 1)) { 130 if (acpi_bus_trim(device)) {
137 printk(KERN_ERR PREFIX 131 printk(KERN_ERR PREFIX
138 "Removing device failed\n"); 132 "Removing device failed\n");
139 goto err_out; 133 goto err_out;
@@ -215,7 +209,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
215 goto err; 209 goto err;
216 } 210 }
217 211
218 ej_event->handle = acpi_device->handle; 212 ej_event->device = acpi_device;
219 if (acpi_device->flags.eject_pending) { 213 if (acpi_device->flags.eject_pending) {
220 /* event originated from ACPI eject notification */ 214 /* event originated from ACPI eject notification */
221 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 215 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
@@ -223,7 +217,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
223 } else { 217 } else {
224 /* event originated from user */ 218 /* event originated from user */
225 ej_event->event = ACPI_OST_EC_OSPM_EJECT; 219 ej_event->event = ACPI_OST_EC_OSPM_EJECT;
226 (void) acpi_evaluate_hotplug_ost(ej_event->handle, 220 (void) acpi_evaluate_hotplug_ost(acpi_device->handle,
227 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 221 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
228 } 222 }
229 223
@@ -701,7 +695,7 @@ end:
701 return result; 695 return result;
702} 696}
703 697
704static void acpi_device_unregister(struct acpi_device *device, int type) 698static void acpi_device_unregister(struct acpi_device *device)
705{ 699{
706 mutex_lock(&acpi_device_lock); 700 mutex_lock(&acpi_device_lock);
707 if (device->parent) 701 if (device->parent)
@@ -1374,22 +1368,6 @@ static int acpi_device_set_context(struct acpi_device *device)
1374 return -ENODEV; 1368 return -ENODEV;
1375} 1369}
1376 1370
1377static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
1378{
1379 if (!dev)
1380 return -EINVAL;
1381
1382 dev->removal_type = ACPI_BUS_REMOVAL_EJECT;
1383 device_release_driver(&dev->dev);
1384
1385 if (!rmdevice)
1386 return 0;
1387
1388 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
1389
1390 return 0;
1391}
1392
1393static int acpi_add_single_object(struct acpi_device **child, 1371static int acpi_add_single_object(struct acpi_device **child,
1394 acpi_handle handle, int type, 1372 acpi_handle handle, int type,
1395 unsigned long long sta, bool match_driver) 1373 unsigned long long sta, bool match_driver)
@@ -1593,13 +1571,25 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1593 if (!acpi_match_device_ids(device, acpi_platform_device_ids)) { 1571 if (!acpi_match_device_ids(device, acpi_platform_device_ids)) {
1594 /* This is a known good platform device. */ 1572 /* This is a known good platform device. */
1595 acpi_create_platform_device(device); 1573 acpi_create_platform_device(device);
1596 } else if (device_attach(&device->dev)) { 1574 } else if (device_attach(&device->dev) < 0) {
1597 status = AE_CTRL_DEPTH; 1575 status = AE_CTRL_DEPTH;
1598 } 1576 }
1599 return status; 1577 return status;
1600} 1578}
1601 1579
1602static int acpi_bus_scan(acpi_handle handle) 1580/**
1581 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
1582 * @handle: Root of the namespace scope to scan.
1583 *
1584 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
1585 * found devices.
1586 *
1587 * If no devices were found, -ENODEV is returned, but it does not mean that
1588 * there has been a real error. There just have been no suitable ACPI objects
1589 * in the table trunk from which the kernel could create a device and add an
1590 * appropriate driver.
1591 */
1592int acpi_bus_scan(acpi_handle handle)
1603{ 1593{
1604 void *device = NULL; 1594 void *device = NULL;
1605 1595
@@ -1616,84 +1606,48 @@ static int acpi_bus_scan(acpi_handle handle)
1616 1606
1617 return 0; 1607 return 0;
1618} 1608}
1609EXPORT_SYMBOL(acpi_bus_scan);
1619 1610
1620/** 1611static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
1621 * acpi_bus_add - Add ACPI device node objects in a given namespace scope. 1612 void *not_used, void **ret_not_used)
1622 * @handle: Root of the namespace scope to scan.
1623 *
1624 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
1625 * found devices.
1626 *
1627 * If no devices were found, -ENODEV is returned, but it does not mean that
1628 * there has been a real error. There just have been no suitable ACPI objects
1629 * in the table trunk from which the kernel could create a device and add an
1630 * appropriate driver.
1631 */
1632int acpi_bus_add(acpi_handle handle)
1633{ 1613{
1634 int err; 1614 struct acpi_device *device = NULL;
1635
1636 err = acpi_bus_scan(handle);
1637 if (err)
1638 return err;
1639 1615
1640 acpi_update_all_gpes(); 1616 if (!acpi_bus_get_device(handle, &device)) {
1641 return 0; 1617 device->removal_type = ACPI_BUS_REMOVAL_EJECT;
1618 device_release_driver(&device->dev);
1619 }
1620 return AE_OK;
1642} 1621}
1643EXPORT_SYMBOL(acpi_bus_add);
1644 1622
1645int acpi_bus_trim(struct acpi_device *start, int rmdevice) 1623static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
1624 void *not_used, void **ret_not_used)
1646{ 1625{
1647 acpi_status status; 1626 struct acpi_device *device = NULL;
1648 struct acpi_device *parent, *child;
1649 acpi_handle phandle, chandle;
1650 acpi_object_type type;
1651 u32 level = 1;
1652 int err = 0;
1653
1654 parent = start;
1655 phandle = start->handle;
1656 child = chandle = NULL;
1657
1658 while ((level > 0) && parent && (!err)) {
1659 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
1660 chandle, &chandle);
1661 1627
1662 /* 1628 if (!acpi_bus_get_device(handle, &device))
1663 * If this scope is exhausted then move our way back up. 1629 acpi_device_unregister(device);
1664 */
1665 if (ACPI_FAILURE(status)) {
1666 level--;
1667 chandle = phandle;
1668 acpi_get_parent(phandle, &phandle);
1669 child = parent;
1670 parent = parent->parent;
1671
1672 if (level == 0)
1673 err = acpi_bus_remove(child, rmdevice);
1674 else
1675 err = acpi_bus_remove(child, 1);
1676 1630
1677 continue; 1631 return AE_OK;
1678 } 1632}
1679 1633
1680 status = acpi_get_type(chandle, &type); 1634int acpi_bus_trim(struct acpi_device *start)
1681 if (ACPI_FAILURE(status)) { 1635{
1682 continue; 1636 /*
1683 } 1637 * Execute acpi_bus_device_detach() as a post-order callback to detach
1684 /* 1638 * all ACPI drivers from the device nodes being removed.
1685 * If there is a device corresponding to chandle then 1639 */
1686 * parse it (depth-first). 1640 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
1687 */ 1641 acpi_bus_device_detach, NULL, NULL);
1688 if (acpi_bus_get_device(chandle, &child) == 0) { 1642 acpi_bus_device_detach(start->handle, 0, NULL, NULL);
1689 level++; 1643 /*
1690 phandle = chandle; 1644 * Execute acpi_bus_remove() as a post-order callback to remove device
1691 chandle = NULL; 1645 * nodes in the given namespace scope.
1692 parent = child; 1646 */
1693 } 1647 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
1694 continue; 1648 acpi_bus_remove, NULL, NULL);
1695 } 1649 acpi_bus_remove(start->handle, 0, NULL, NULL);
1696 return err; 1650 return 0;
1697} 1651}
1698EXPORT_SYMBOL_GPL(acpi_bus_trim); 1652EXPORT_SYMBOL_GPL(acpi_bus_trim);
1699 1653
@@ -1742,13 +1696,15 @@ int __init acpi_scan_init(void)
1742 return result; 1696 return result;
1743 1697
1744 result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root); 1698 result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
1745 if (!result)
1746 result = acpi_bus_scan_fixed();
1747
1748 if (result) 1699 if (result)
1749 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1700 return result;
1750 else
1751 acpi_update_all_gpes();
1752 1701
1753 return result; 1702 result = acpi_bus_scan_fixed();
1703 if (result) {
1704 acpi_device_unregister(acpi_root);
1705 return result;
1706 }
1707
1708 acpi_update_all_gpes();
1709 return 0;
1754} 1710}