diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-06-28 06:58:21 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-06-28 06:58:21 -0400 |
commit | 8e9914d5efe460600f5948da7ae4c1b6c038a4c0 (patch) | |
tree | 2a6ed5d7ba447f2288f05f9b8d54db92b8b28139 /drivers/acpi/scan.c | |
parent | 80338681bbc5786fa1342d3b7f021c1d8974ac62 (diff) | |
parent | 24071f472d813fccacc1ef7356b1f41422a1b968 (diff) |
Merge branch 'acpi-scan'
* acpi-scan:
ACPI / scan: Do not bind ACPI drivers to objects with scan handlers
ACPI / ia64 / sba_iommu: Use ACPI scan handler for device discovery
ACPI / scan: Simplify ACPI driver probing
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 84 |
1 files changed, 30 insertions, 54 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index db118b1ad3e8..e0db2dc42370 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -933,32 +933,43 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device) | |||
933 | acpi_device_notify); | 933 | acpi_device_notify); |
934 | } | 934 | } |
935 | 935 | ||
936 | static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); | 936 | static int acpi_device_probe(struct device *dev) |
937 | static int acpi_device_probe(struct device * dev) | ||
938 | { | 937 | { |
939 | struct acpi_device *acpi_dev = to_acpi_device(dev); | 938 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
940 | struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver); | 939 | struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver); |
941 | int ret; | 940 | int ret; |
942 | 941 | ||
943 | ret = acpi_bus_driver_init(acpi_dev, acpi_drv); | 942 | if (acpi_dev->handler) |
944 | if (!ret) { | 943 | return -EINVAL; |
945 | if (acpi_drv->ops.notify) { | ||
946 | ret = acpi_device_install_notify_handler(acpi_dev); | ||
947 | if (ret) { | ||
948 | if (acpi_drv->ops.remove) | ||
949 | acpi_drv->ops.remove(acpi_dev); | ||
950 | acpi_dev->driver = NULL; | ||
951 | acpi_dev->driver_data = NULL; | ||
952 | return ret; | ||
953 | } | ||
954 | } | ||
955 | 944 | ||
956 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 945 | if (!acpi_drv->ops.add) |
957 | "Found driver [%s] for device [%s]\n", | 946 | return -ENOSYS; |
958 | acpi_drv->name, acpi_dev->pnp.bus_id)); | 947 | |
959 | get_device(dev); | 948 | ret = acpi_drv->ops.add(acpi_dev); |
949 | if (ret) | ||
950 | return ret; | ||
951 | |||
952 | acpi_dev->driver = acpi_drv; | ||
953 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
954 | "Driver [%s] successfully bound to device [%s]\n", | ||
955 | acpi_drv->name, acpi_dev->pnp.bus_id)); | ||
956 | |||
957 | if (acpi_drv->ops.notify) { | ||
958 | ret = acpi_device_install_notify_handler(acpi_dev); | ||
959 | if (ret) { | ||
960 | if (acpi_drv->ops.remove) | ||
961 | acpi_drv->ops.remove(acpi_dev); | ||
962 | |||
963 | acpi_dev->driver = NULL; | ||
964 | acpi_dev->driver_data = NULL; | ||
965 | return ret; | ||
966 | } | ||
960 | } | 967 | } |
961 | return ret; | 968 | |
969 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", | ||
970 | acpi_drv->name, acpi_dev->pnp.bus_id)); | ||
971 | get_device(dev); | ||
972 | return 0; | ||
962 | } | 973 | } |
963 | 974 | ||
964 | static int acpi_device_remove(struct device * dev) | 975 | static int acpi_device_remove(struct device * dev) |
@@ -1114,41 +1125,6 @@ static void acpi_device_unregister(struct acpi_device *device) | |||
1114 | Driver Management | 1125 | Driver Management |
1115 | -------------------------------------------------------------------------- */ | 1126 | -------------------------------------------------------------------------- */ |
1116 | /** | 1127 | /** |
1117 | * acpi_bus_driver_init - add a device to a driver | ||
1118 | * @device: the device to add and initialize | ||
1119 | * @driver: driver for the device | ||
1120 | * | ||
1121 | * Used to initialize a device via its device driver. Called whenever a | ||
1122 | * driver is bound to a device. Invokes the driver's add() ops. | ||
1123 | */ | ||
1124 | static int | ||
1125 | acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver) | ||
1126 | { | ||
1127 | int result = 0; | ||
1128 | |||
1129 | if (!device || !driver) | ||
1130 | return -EINVAL; | ||
1131 | |||
1132 | if (!driver->ops.add) | ||
1133 | return -ENOSYS; | ||
1134 | |||
1135 | result = driver->ops.add(device); | ||
1136 | if (result) | ||
1137 | return result; | ||
1138 | |||
1139 | device->driver = driver; | ||
1140 | |||
1141 | /* | ||
1142 | * TBD - Configuration Management: Assign resources to device based | ||
1143 | * upon possible configuration and currently allocated resources. | ||
1144 | */ | ||
1145 | |||
1146 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
1147 | "Driver successfully bound to device\n")); | ||
1148 | return 0; | ||
1149 | } | ||
1150 | |||
1151 | /** | ||
1152 | * acpi_bus_register_driver - register a driver with the ACPI bus | 1128 | * acpi_bus_register_driver - register a driver with the ACPI bus |
1153 | * @driver: driver being registered | 1129 | * @driver: driver being registered |
1154 | * | 1130 | * |