From: Zhang Rui "/sys/devices/LNXSYSTM:00/.../eject" is used to evaluate _EJx method and eject a device in user space. But system hangs when poking the "eject" file because that the device hot-removal code invoke the driver .remove method which will try to remove the "eject" file as a result. Queues the hot-removal function for deferred execution in this patch. Signed-off-by: Zhang Rui --- drivers/acpi/scan.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) Index: linux-2.6/drivers/acpi/scan.c =================================================================== --- linux-2.6.orig/drivers/acpi/scan.c +++ linux-2.6/drivers/acpi/scan.c @@ -151,15 +151,13 @@ acpi_bus_eject_device(acpi_handle handle return 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; }