diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/scan.c | 31 | ||||
-rw-r--r-- | drivers/acpi/utils.c | 43 |
2 files changed, 49 insertions, 25 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index ada0b4cf2ba5..4c25c3b7ef81 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -193,8 +193,6 @@ static acpi_status acpi_bus_online_companions(acpi_handle handle, u32 lvl, | |||
193 | static int acpi_scan_hot_remove(struct acpi_device *device) | 193 | static int acpi_scan_hot_remove(struct acpi_device *device) |
194 | { | 194 | { |
195 | acpi_handle handle = device->handle; | 195 | acpi_handle handle = device->handle; |
196 | struct acpi_object_list arg_list; | ||
197 | union acpi_object arg; | ||
198 | struct device *errdev; | 196 | struct device *errdev; |
199 | acpi_status status; | 197 | acpi_status status; |
200 | unsigned long long sta; | 198 | unsigned long long sta; |
@@ -257,32 +255,15 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
257 | put_device(&device->dev); | 255 | put_device(&device->dev); |
258 | device = NULL; | 256 | device = NULL; |
259 | 257 | ||
260 | if (acpi_has_method(handle, "_LCK")) { | 258 | acpi_evaluate_lck(handle, 0); |
261 | arg_list.count = 1; | ||
262 | arg_list.pointer = &arg; | ||
263 | arg.type = ACPI_TYPE_INTEGER; | ||
264 | arg.integer.value = 0; | ||
265 | acpi_evaluate_object(handle, "_LCK", &arg_list, NULL); | ||
266 | } | ||
267 | |||
268 | arg_list.count = 1; | ||
269 | arg_list.pointer = &arg; | ||
270 | arg.type = ACPI_TYPE_INTEGER; | ||
271 | arg.integer.value = 1; | ||
272 | |||
273 | /* | 259 | /* |
274 | * TBD: _EJD support. | 260 | * TBD: _EJD support. |
275 | */ | 261 | */ |
276 | status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); | 262 | status = acpi_evaluate_ej0(handle); |
277 | if (ACPI_FAILURE(status)) { | 263 | if (status == AE_NOT_FOUND) |
278 | if (status == AE_NOT_FOUND) { | 264 | return -ENODEV; |
279 | return -ENODEV; | 265 | else if (ACPI_FAILURE(status)) |
280 | } else { | 266 | return -EIO; |
281 | acpi_handle_warn(handle, "Eject failed (0x%x)\n", | ||
282 | status); | ||
283 | return -EIO; | ||
284 | } | ||
285 | } | ||
286 | 267 | ||
287 | /* | 268 | /* |
288 | * Verify if eject was indeed successful. If not, log an error | 269 | * Verify if eject was indeed successful. If not, log an error |
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 87b85882b5df..552248b0005b 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
@@ -522,3 +522,46 @@ acpi_status acpi_execute_simple_method(acpi_handle handle, char *method, | |||
522 | return acpi_evaluate_object(handle, method, &arg_list, NULL); | 522 | return acpi_evaluate_object(handle, method, &arg_list, NULL); |
523 | } | 523 | } |
524 | EXPORT_SYMBOL(acpi_execute_simple_method); | 524 | EXPORT_SYMBOL(acpi_execute_simple_method); |
525 | |||
526 | /** | ||
527 | * acpi_evaluate_ej0: Evaluate _EJ0 method for hotplug operations | ||
528 | * @handle: ACPI device handle | ||
529 | * | ||
530 | * Evaluate device's _EJ0 method for hotplug operations. | ||
531 | */ | ||
532 | acpi_status acpi_evaluate_ej0(acpi_handle handle) | ||
533 | { | ||
534 | acpi_status status; | ||
535 | |||
536 | status = acpi_execute_simple_method(handle, "_EJ0", 1); | ||
537 | if (status == AE_NOT_FOUND) | ||
538 | acpi_handle_warn(handle, "No _EJ0 support for device\n"); | ||
539 | else if (ACPI_FAILURE(status)) | ||
540 | acpi_handle_warn(handle, "Eject failed (0x%x)\n", status); | ||
541 | |||
542 | return status; | ||
543 | } | ||
544 | |||
545 | /** | ||
546 | * acpi_evaluate_lck: Evaluate _LCK method to lock/unlock device | ||
547 | * @handle: ACPI device handle | ||
548 | * @lock: lock device if non-zero, otherwise unlock device | ||
549 | * | ||
550 | * Evaluate device's _LCK method if present to lock/unlock device | ||
551 | */ | ||
552 | acpi_status acpi_evaluate_lck(acpi_handle handle, int lock) | ||
553 | { | ||
554 | acpi_status status; | ||
555 | |||
556 | status = acpi_execute_simple_method(handle, "_LCK", !!lock); | ||
557 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
558 | if (lock) | ||
559 | acpi_handle_warn(handle, | ||
560 | "Locking device failed (0x%x)\n", status); | ||
561 | else | ||
562 | acpi_handle_warn(handle, | ||
563 | "Unlocking device failed (0x%x)\n", status); | ||
564 | } | ||
565 | |||
566 | return status; | ||
567 | } | ||