|
@@ -83,19 +83,29 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha
|
|
}
|
|
}
|
|
static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
|
|
static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
|
|
|
|
|
|
-static void acpi_bus_hot_remove_device(void *context)
|
|
|
|
|
|
+/**
|
|
|
|
+ * acpi_bus_hot_remove_device: hot-remove a device and its children
|
|
|
|
+ * @context: struct acpi_eject_event pointer (freed in this func)
|
|
|
|
+ *
|
|
|
|
+ * Hot-remove a device and its children. This function frees up the
|
|
|
|
+ * memory space passed by arg context, so that the caller may call
|
|
|
|
+ * this function asynchronously through acpi_os_hotplug_execute().
|
|
|
|
+ */
|
|
|
|
+void acpi_bus_hot_remove_device(void *context)
|
|
{
|
|
{
|
|
|
|
+ struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context;
|
|
struct acpi_device *device;
|
|
struct acpi_device *device;
|
|
- acpi_handle handle = context;
|
|
|
|
|
|
+ acpi_handle handle = ej_event->handle;
|
|
struct acpi_object_list arg_list;
|
|
struct acpi_object_list arg_list;
|
|
union acpi_object arg;
|
|
union acpi_object arg;
|
|
acpi_status status = AE_OK;
|
|
acpi_status status = AE_OK;
|
|
|
|
+ u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
|
|
|
|
|
|
if (acpi_bus_get_device(handle, &device))
|
|
if (acpi_bus_get_device(handle, &device))
|
|
- return;
|
|
|
|
|
|
+ goto err_out;
|
|
|
|
|
|
if (!device)
|
|
if (!device)
|
|
- return;
|
|
|
|
|
|
+ goto err_out;
|
|
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
"Hot-removing device %s...\n", dev_name(&device->dev)));
|
|
"Hot-removing device %s...\n", dev_name(&device->dev)));
|
|
@@ -103,7 +113,7 @@ static void acpi_bus_hot_remove_device(void *context)
|
|
if (acpi_bus_trim(device, 1)) {
|
|
if (acpi_bus_trim(device, 1)) {
|
|
printk(KERN_ERR PREFIX
|
|
printk(KERN_ERR PREFIX
|
|
"Removing device failed\n");
|
|
"Removing device failed\n");
|
|
- return;
|
|
|
|
|
|
+ goto err_out;
|
|
}
|
|
}
|
|
|
|
|
|
/* power off device */
|
|
/* power off device */
|
|
@@ -129,10 +139,21 @@ static void acpi_bus_hot_remove_device(void *context)
|
|
* TBD: _EJD support.
|
|
* TBD: _EJD support.
|
|
*/
|
|
*/
|
|
status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
|
|
status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
|
|
- if (ACPI_FAILURE(status))
|
|
|
|
- printk(KERN_WARNING PREFIX
|
|
|
|
- "Eject device failed\n");
|
|
|
|
|
|
+ if (ACPI_FAILURE(status)) {
|
|
|
|
+ if (status != AE_NOT_FOUND)
|
|
|
|
+ printk(KERN_WARNING PREFIX
|
|
|
|
+ "Eject device failed\n");
|
|
|
|
+ goto err_out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ kfree(context);
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
+err_out:
|
|
|
|
+ /* Inform firmware the hot-remove operation has completed w/ error */
|
|
|
|
+ (void) acpi_evaluate_hotplug_ost(handle,
|
|
|
|
+ ej_event->event, ost_code, NULL);
|
|
|
|
+ kfree(context);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -144,6 +165,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
|
|
acpi_status status;
|
|
acpi_status status;
|
|
acpi_object_type type = 0;
|
|
acpi_object_type type = 0;
|
|
struct acpi_device *acpi_device = to_acpi_device(d);
|
|
struct acpi_device *acpi_device = to_acpi_device(d);
|
|
|
|
+ struct acpi_eject_event *ej_event;
|
|
|
|
|
|
if ((!count) || (buf[0] != '1')) {
|
|
if ((!count) || (buf[0] != '1')) {
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
@@ -160,7 +182,25 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
|
|
goto err;
|
|
goto err;
|
|
}
|
|
}
|
|
|
|
|
|
- acpi_os_hotplug_execute(acpi_bus_hot_remove_device, acpi_device->handle);
|
|
|
|
|
|
+ ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL);
|
|
|
|
+ if (!ej_event) {
|
|
|
|
+ ret = -ENOMEM;
|
|
|
|
+ goto err;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ej_event->handle = acpi_device->handle;
|
|
|
|
+ if (acpi_device->flags.eject_pending) {
|
|
|
|
+ /* event originated from ACPI eject notification */
|
|
|
|
+ ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
|
|
|
|
+ acpi_device->flags.eject_pending = 0;
|
|
|
|
+ } else {
|
|
|
|
+ /* event originated from user */
|
|
|
|
+ ej_event->event = ACPI_OST_EC_OSPM_EJECT;
|
|
|
|
+ (void) acpi_evaluate_hotplug_ost(ej_event->handle,
|
|
|
|
+ ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ acpi_os_hotplug_execute(acpi_bus_hot_remove_device, (void *)ej_event);
|
|
err:
|
|
err:
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|