diff options
| -rw-r--r-- | drivers/acpi/battery.c | 4 | ||||
| -rw-r--r-- | drivers/acpi/scan.c | 85 | ||||
| -rw-r--r-- | drivers/i2c/i2c-core.c | 1 | ||||
| -rw-r--r-- | include/acpi/acpi_bus.h | 1 | ||||
| -rw-r--r-- | include/linux/acpi.h | 1 |
5 files changed, 92 insertions, 0 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 8ec8a89a20ab..d98ba4355819 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
| @@ -1180,6 +1180,10 @@ static int acpi_battery_add(struct acpi_device *device) | |||
| 1180 | 1180 | ||
| 1181 | if (!device) | 1181 | if (!device) |
| 1182 | return -EINVAL; | 1182 | return -EINVAL; |
| 1183 | |||
| 1184 | if (device->dep_unmet) | ||
| 1185 | return -EPROBE_DEFER; | ||
| 1186 | |||
| 1183 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); | 1187 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); |
| 1184 | if (!battery) | 1188 | if (!battery) |
| 1185 | return -ENOMEM; | 1189 | return -ENOMEM; |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 0476e90b2091..00189ad63c8f 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
| @@ -36,6 +36,8 @@ bool acpi_force_hot_remove; | |||
| 36 | 36 | ||
| 37 | static const char *dummy_hid = "device"; | 37 | static const char *dummy_hid = "device"; |
| 38 | 38 | ||
| 39 | static LIST_HEAD(acpi_dep_list); | ||
| 40 | static DEFINE_MUTEX(acpi_dep_list_lock); | ||
| 39 | static LIST_HEAD(acpi_bus_id_list); | 41 | static LIST_HEAD(acpi_bus_id_list); |
| 40 | static DEFINE_MUTEX(acpi_scan_lock); | 42 | static DEFINE_MUTEX(acpi_scan_lock); |
| 41 | static LIST_HEAD(acpi_scan_handlers_list); | 43 | static LIST_HEAD(acpi_scan_handlers_list); |
| @@ -43,6 +45,12 @@ DEFINE_MUTEX(acpi_device_lock); | |||
| 43 | LIST_HEAD(acpi_wakeup_device_list); | 45 | LIST_HEAD(acpi_wakeup_device_list); |
| 44 | static DEFINE_MUTEX(acpi_hp_context_lock); | 46 | static DEFINE_MUTEX(acpi_hp_context_lock); |
| 45 | 47 | ||
| 48 | struct acpi_dep_data { | ||
| 49 | struct list_head node; | ||
| 50 | acpi_handle master; | ||
| 51 | acpi_handle slave; | ||
| 52 | }; | ||
| 53 | |||
| 46 | struct acpi_device_bus_id{ | 54 | struct acpi_device_bus_id{ |
| 47 | char bus_id[15]; | 55 | char bus_id[15]; |
| 48 | unsigned int instance_no; | 56 | unsigned int instance_no; |
| @@ -2086,6 +2094,59 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) | |||
| 2086 | } | 2094 | } |
| 2087 | } | 2095 | } |
| 2088 | 2096 | ||
| 2097 | static void acpi_device_dep_initialize(struct acpi_device *adev) | ||
| 2098 | { | ||
| 2099 | struct acpi_dep_data *dep; | ||
| 2100 | struct acpi_handle_list dep_devices; | ||
| 2101 | acpi_status status; | ||
| 2102 | int i; | ||
| 2103 | |||
| 2104 | if (!acpi_has_method(adev->handle, "_DEP")) | ||
| 2105 | return; | ||
| 2106 | |||
| 2107 | status = acpi_evaluate_reference(adev->handle, "_DEP", NULL, | ||
| 2108 | &dep_devices); | ||
| 2109 | if (ACPI_FAILURE(status)) { | ||
| 2110 | dev_err(&adev->dev, "Failed to evaluate _DEP.\n"); | ||
| 2111 | return; | ||
| 2112 | } | ||
| 2113 | |||
| 2114 | for (i = 0; i < dep_devices.count; i++) { | ||
| 2115 | struct acpi_device_info *info; | ||
| 2116 | int skip; | ||
| 2117 | |||
| 2118 | status = acpi_get_object_info(dep_devices.handles[i], &info); | ||
| 2119 | if (ACPI_FAILURE(status)) { | ||
| 2120 | dev_err(&adev->dev, "Error reading device info\n"); | ||
| 2121 | continue; | ||
| 2122 | } | ||
| 2123 | |||
| 2124 | /* | ||
| 2125 | * Skip the dependency of Windows System Power | ||
| 2126 | * Management Controller | ||
| 2127 | */ | ||
| 2128 | skip = info->valid & ACPI_VALID_HID && | ||
| 2129 | !strcmp(info->hardware_id.string, "INT3396"); | ||
| 2130 | |||
| 2131 | kfree(info); | ||
| 2132 | |||
| 2133 | if (skip) | ||
| 2134 | continue; | ||
| 2135 | |||
| 2136 | dep = kzalloc(sizeof(struct acpi_dep_data), GFP_KERNEL); | ||
| 2137 | if (!dep) | ||
| 2138 | return; | ||
| 2139 | |||
| 2140 | dep->master = dep_devices.handles[i]; | ||
| 2141 | dep->slave = adev->handle; | ||
| 2142 | adev->dep_unmet++; | ||
| 2143 | |||
| 2144 | mutex_lock(&acpi_dep_list_lock); | ||
| 2145 | list_add_tail(&dep->node , &acpi_dep_list); | ||
| 2146 | mutex_unlock(&acpi_dep_list_lock); | ||
| 2147 | } | ||
| 2148 | } | ||
| 2149 | |||
| 2089 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | 2150 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, |
| 2090 | void *not_used, void **return_value) | 2151 | void *not_used, void **return_value) |
| 2091 | { | 2152 | { |
| @@ -2112,6 +2173,7 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | |||
| 2112 | return AE_CTRL_DEPTH; | 2173 | return AE_CTRL_DEPTH; |
| 2113 | 2174 | ||
| 2114 | acpi_scan_init_hotplug(device); | 2175 | acpi_scan_init_hotplug(device); |
| 2176 | acpi_device_dep_initialize(device); | ||
| 2115 | 2177 | ||
| 2116 | out: | 2178 | out: |
| 2117 | if (!*return_value) | 2179 | if (!*return_value) |
| @@ -2232,6 +2294,29 @@ static void acpi_bus_attach(struct acpi_device *device) | |||
| 2232 | device->handler->hotplug.notify_online(device); | 2294 | device->handler->hotplug.notify_online(device); |
| 2233 | } | 2295 | } |
| 2234 | 2296 | ||
| 2297 | void acpi_walk_dep_device_list(acpi_handle handle) | ||
| 2298 | { | ||
| 2299 | struct acpi_dep_data *dep, *tmp; | ||
| 2300 | struct acpi_device *adev; | ||
| 2301 | |||
| 2302 | mutex_lock(&acpi_dep_list_lock); | ||
| 2303 | list_for_each_entry_safe(dep, tmp, &acpi_dep_list, node) { | ||
| 2304 | if (dep->master == handle) { | ||
| 2305 | acpi_bus_get_device(dep->slave, &adev); | ||
| 2306 | if (!adev) | ||
| 2307 | continue; | ||
| 2308 | |||
| 2309 | adev->dep_unmet--; | ||
| 2310 | if (!adev->dep_unmet) | ||
| 2311 | acpi_bus_attach(adev); | ||
| 2312 | list_del(&dep->node); | ||
| 2313 | kfree(dep); | ||
| 2314 | } | ||
| 2315 | } | ||
| 2316 | mutex_unlock(&acpi_dep_list_lock); | ||
| 2317 | } | ||
| 2318 | EXPORT_SYMBOL_GPL(acpi_walk_dep_device_list); | ||
| 2319 | |||
| 2235 | /** | 2320 | /** |
| 2236 | * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. | 2321 | * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. |
| 2237 | * @handle: Root of the namespace scope to scan. | 2322 | * @handle: Root of the namespace scope to scan. |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index f43b4e11647a..68aeb8eedae0 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
| @@ -403,6 +403,7 @@ static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter) | |||
| 403 | return -ENOMEM; | 403 | return -ENOMEM; |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | acpi_walk_dep_device_list(handle); | ||
| 406 | return 0; | 407 | return 0; |
| 407 | } | 408 | } |
| 408 | 409 | ||
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index f34a0835aa4f..ea3697dc7046 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
| @@ -359,6 +359,7 @@ struct acpi_device { | |||
| 359 | void *driver_data; | 359 | void *driver_data; |
| 360 | struct device dev; | 360 | struct device dev; |
| 361 | unsigned int physical_node_count; | 361 | unsigned int physical_node_count; |
| 362 | unsigned int dep_unmet; | ||
| 362 | struct list_head physical_node_list; | 363 | struct list_head physical_node_list; |
| 363 | struct mutex physical_node_lock; | 364 | struct mutex physical_node_lock; |
| 364 | void (*remove)(struct acpi_device *); | 365 | void (*remove)(struct acpi_device *); |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 407a12f663eb..6cb310388c88 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
| @@ -431,6 +431,7 @@ static inline bool acpi_driver_match_device(struct device *dev, | |||
| 431 | 431 | ||
| 432 | int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *); | 432 | int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *); |
| 433 | int acpi_device_modalias(struct device *, char *, int); | 433 | int acpi_device_modalias(struct device *, char *, int); |
| 434 | void acpi_walk_dep_device_list(acpi_handle handle); | ||
| 434 | 435 | ||
| 435 | struct platform_device *acpi_create_platform_device(struct acpi_device *); | 436 | struct platform_device *acpi_create_platform_device(struct acpi_device *); |
| 436 | #define ACPI_PTR(_ptr) (_ptr) | 437 | #define ACPI_PTR(_ptr) (_ptr) |
