summaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-07 01:41:39 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-07 01:41:39 +0100
commit5add99cfef416487d32b4b7075fe1a409f3a5e82 (patch)
tree29553178aac29acea786fa36576c8b6e0f536623 /drivers/acpi
parent2441191a19039002b2c454a261fb45986df15184 (diff)
downloadtalos-obmc-linux-5add99cfef416487d32b4b7075fe1a409f3a5e82.tar.gz
talos-obmc-linux-5add99cfef416487d32b4b7075fe1a409f3a5e82.zip
ACPI / hotplug: Simplify device ejection routines
Simplify handle_root_bridge_removal() and acpi_eject_store() by getting rid of struct acpi_eject_event and passing device objects directly to async routines executed via acpi_os_hotplug_execute(). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Toshi Kani <toshi.kani@hp.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/pci_root.c20
-rw-r--r--drivers/acpi/scan.c46
2 files changed, 20 insertions, 46 deletions
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index d7e53ea53d6c..2c03aaee1006 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -593,27 +593,11 @@ static void handle_root_bridge_insertion(acpi_handle handle)
static void handle_root_bridge_removal(struct acpi_device *device)
{
acpi_status status;
- struct acpi_eject_event *ej_event;
-
- ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL);
- if (!ej_event) {
- /* Inform firmware the hot-remove operation has error */
- (void) acpi_evaluate_hotplug_ost(device->handle,
- ACPI_NOTIFY_EJECT_REQUEST,
- ACPI_OST_SC_NON_SPECIFIC_FAILURE,
- NULL);
- return;
- }
-
- ej_event->device = device;
- ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
get_device(&device->dev);
- status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, ej_event);
- if (ACPI_FAILURE(status)) {
+ status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, device);
+ if (ACPI_FAILURE(status))
put_device(&device->dev);
- kfree(ej_event);
- }
}
static void _handle_hotplug_event_root(struct work_struct *work)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 9bdcc187bf4b..cc19d623a18f 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -441,18 +441,8 @@ static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data)
NULL);
}
-/**
- * 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)
+void __acpi_bus_hot_remove_device(struct acpi_device *device, u32 ost_src)
{
- struct acpi_eject_event *ej_event = context;
- struct acpi_device *device = ej_event->device;
acpi_handle handle = device->handle;
int error;
@@ -461,13 +451,21 @@ void acpi_bus_hot_remove_device(void *context)
error = acpi_scan_hot_remove(device);
if (error && handle)
- acpi_evaluate_hotplug_ost(handle, ej_event->event,
+ acpi_evaluate_hotplug_ost(handle, ost_src,
ACPI_OST_SC_NON_SPECIFIC_FAILURE,
NULL);
mutex_unlock(&acpi_scan_lock);
unlock_device_hotplug();
- kfree(context);
+}
+
+/**
+ * acpi_bus_hot_remove_device: Hot-remove a device and its children.
+ * @context: Address of the ACPI device object to hot-remove.
+ */
+void acpi_bus_hot_remove_device(void *context)
+{
+ __acpi_bus_hot_remove_device(context, ACPI_NOTIFY_EJECT_REQUEST);
}
EXPORT_SYMBOL(acpi_bus_hot_remove_device);
@@ -497,15 +495,18 @@ static ssize_t power_state_show(struct device *dev,
static DEVICE_ATTR(power_state, 0444, power_state_show, NULL);
+static void acpi_eject_store_work(void *context)
+{
+ __acpi_bus_hot_remove_device(context, ACPI_OST_EC_OSPM_EJECT);
+}
+
static ssize_t
acpi_eject_store(struct device *d, struct device_attribute *attr,
const char *buf, size_t count)
{
struct acpi_device *acpi_device = to_acpi_device(d);
- struct acpi_eject_event *ej_event;
acpi_object_type not_used;
acpi_status status;
- int ret;
if (!count || buf[0] != '1')
return -EINVAL;
@@ -518,28 +519,17 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable)
return -ENODEV;
- ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL);
- if (!ej_event) {
- ret = -ENOMEM;
- goto err_out;
- }
acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
- ej_event->device = acpi_device;
- ej_event->event = ACPI_OST_EC_OSPM_EJECT;
get_device(&acpi_device->dev);
- status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, ej_event);
+ status = acpi_os_hotplug_execute(acpi_eject_store_work, acpi_device);
if (ACPI_SUCCESS(status))
return count;
put_device(&acpi_device->dev);
- kfree(ej_event);
- ret = status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
-
- err_out:
acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
- return ret;
+ return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
}
static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
OpenPOWER on IntegriCloud