aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-29 07:57:20 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-29 07:57:20 -0500
commit2c0d4fe0189ae5e29fd9602d5b83f3b2b169bd1b (patch)
tree0ab0707d11728e9622b63b4caca8d911a896babc /drivers
parent8a78cf70fae587b0691b4b982bc69c1261e05e76 (diff)
ACPI / scan: Make scanning of fixed devices follow the general scheme
Make acpi_bus_scan_fixed() use device_attach() directly to attach drivers, if any, to the fixed devices in analogy with how acpi_bus_scan() works, which allows the last argument of acpi_add_single_object() to be dropped and the manipulation of the flags.match_driver bit to be moved to acpi_init_device_object() and acpi_device_add_finalize(). After these changes all of the functions for the initialization and registration of struct acpi_device objects work in the same way for all of them. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Yinghai Lu <yinghai@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/scan.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index a4a2595b6d88..b206ce5e1faf 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1441,19 +1441,21 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1441 acpi_device_get_busid(device); 1441 acpi_device_get_busid(device);
1442 acpi_device_set_id(device); 1442 acpi_device_set_id(device);
1443 acpi_bus_get_flags(device); 1443 acpi_bus_get_flags(device);
1444 device->flags.match_driver = false;
1444 device_initialize(&device->dev); 1445 device_initialize(&device->dev);
1445 dev_set_uevent_suppress(&device->dev, true); 1446 dev_set_uevent_suppress(&device->dev, true);
1446} 1447}
1447 1448
1448void acpi_device_add_finalize(struct acpi_device *device) 1449void acpi_device_add_finalize(struct acpi_device *device)
1449{ 1450{
1451 device->flags.match_driver = true;
1450 dev_set_uevent_suppress(&device->dev, false); 1452 dev_set_uevent_suppress(&device->dev, false);
1451 kobject_uevent(&device->dev.kobj, KOBJ_ADD); 1453 kobject_uevent(&device->dev.kobj, KOBJ_ADD);
1452} 1454}
1453 1455
1454static int acpi_add_single_object(struct acpi_device **child, 1456static int acpi_add_single_object(struct acpi_device **child,
1455 acpi_handle handle, int type, 1457 acpi_handle handle, int type,
1456 unsigned long long sta, bool match_driver) 1458 unsigned long long sta)
1457{ 1459{
1458 int result; 1460 int result;
1459 struct acpi_device *device; 1461 struct acpi_device *device;
@@ -1469,7 +1471,6 @@ static int acpi_add_single_object(struct acpi_device **child,
1469 acpi_bus_get_power_flags(device); 1471 acpi_bus_get_power_flags(device);
1470 acpi_bus_get_wakeup_device_flags(device); 1472 acpi_bus_get_wakeup_device_flags(device);
1471 1473
1472 device->flags.match_driver = match_driver;
1473 result = acpi_device_add(device, acpi_device_release); 1474 result = acpi_device_add(device, acpi_device_release);
1474 if (result) { 1475 if (result) {
1475 acpi_device_release(&device->dev); 1476 acpi_device_release(&device->dev);
@@ -1562,12 +1563,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1562 return AE_CTRL_DEPTH; 1563 return AE_CTRL_DEPTH;
1563 } 1564 }
1564 1565
1565 acpi_add_single_object(&device, handle, type, sta, false); 1566 acpi_add_single_object(&device, handle, type, sta);
1566 if (!device) 1567 if (!device)
1567 return AE_CTRL_DEPTH; 1568 return AE_CTRL_DEPTH;
1568 1569
1569 device->flags.match_driver = true;
1570
1571 out: 1570 out:
1572 if (!*return_value) 1571 if (!*return_value)
1573 *return_value = device; 1572 *return_value = device;
@@ -1679,25 +1678,39 @@ EXPORT_SYMBOL_GPL(acpi_bus_trim);
1679static int acpi_bus_scan_fixed(void) 1678static int acpi_bus_scan_fixed(void)
1680{ 1679{
1681 int result = 0; 1680 int result = 0;
1682 struct acpi_device *device = NULL;
1683 1681
1684 /* 1682 /*
1685 * Enumerate all fixed-feature devices. 1683 * Enumerate all fixed-feature devices.
1686 */ 1684 */
1687 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { 1685 if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) {
1686 struct acpi_device *device = NULL;
1687
1688 result = acpi_add_single_object(&device, NULL, 1688 result = acpi_add_single_object(&device, NULL,
1689 ACPI_BUS_TYPE_POWER_BUTTON, 1689 ACPI_BUS_TYPE_POWER_BUTTON,
1690 ACPI_STA_DEFAULT, true); 1690 ACPI_STA_DEFAULT);
1691 if (result)
1692 return result;
1693
1694 result = device_attach(&device->dev);
1695 if (result < 0)
1696 return result;
1697
1691 device_init_wakeup(&device->dev, true); 1698 device_init_wakeup(&device->dev, true);
1692 } 1699 }
1693 1700
1694 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1701 if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON)) {
1702 struct acpi_device *device = NULL;
1703
1695 result = acpi_add_single_object(&device, NULL, 1704 result = acpi_add_single_object(&device, NULL,
1696 ACPI_BUS_TYPE_SLEEP_BUTTON, 1705 ACPI_BUS_TYPE_SLEEP_BUTTON,
1697 ACPI_STA_DEFAULT, true); 1706 ACPI_STA_DEFAULT);
1707 if (result)
1708 return result;
1709
1710 result = device_attach(&device->dev);
1698 } 1711 }
1699 1712
1700 return result; 1713 return result < 0 ? result : 0;
1701} 1714}
1702 1715
1703int __init acpi_scan_init(void) 1716int __init acpi_scan_init(void)