ACPI: support ejecting device in userspace
PATCH 4/4 ACPI: support ejecting device in userspace
From: Zhang Rui <[email protected]>
"/sys/devices/LNXSYSTM:00/.../eject" is used to evaluate _EJx method and eject a device in user space.
But "echo 1 > eject" causes deadlock because
the device hot-removal code will try to remove the "eject" file as a result. Queues the hot-removal function for deferred execution in this patch.
http://bugzilla.kernel.org/show_bug.cgi?id=9731
Signed-off-by Zhang Rui <[email protected]>
--- drivers/acpi/scan.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/acpi/scan.c +6 -12
@@ -151,15 +151,13 @@ acpi_bus_eject_device(acpi_handle handlereturn 0 ; } +void acpi_bus_hot_remove_device (void *context);static ssize_t acpi_eject_store (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -int result;int ret = count; -int islockable;acpi_status status; -acpi_handle handle;acpi_object_type type =0 ;struct acpi_device *acpi_device =to_acpi_device (d);
@@ -178,17 +176,13 @@ acpi_eject_store(struct device *d, struc goto err; } - islockable = acpi_device->flags.lockable; - handle = acpi_device->handle; + status =acpi_os_execute (OSL_DEVICE_HOTPLUG_HANDLER , + acpi_bus_hot_remove_device, + acpi_device->handle); - result =acpi_bus_trim (acpi_device,1 ); - -if (!result) - result =acpi_bus_eject_device (handle, islockable); +if (status) + ret = -ENODEV ; -if (result) { - ret = -EBUSY ; - } err:return ret; }