ACPI / hotplug: Rework deferred execution of acpi_device_hotplug()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sun, 2 Mar 2014 23:40:38 +0000 (00:40 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 5 Mar 2014 00:26:35 +0000 (01:26 +0100)
Since the only function executed by acpi_hotplug_execute() is
acpi_device_hotplug() and it only is called by the ACPI core,
simplify its definition so that it only takes two arguments, the
ACPI device object pointer and event code, rename it to
acpi_hotplug_schedule() and move its header from acpi_bus.h to
the ACPI core's internal header file internal.h.  Modify the
definition of acpi_device_hotplug() so that its first argument is
an ACPI device object pointer and modify the definition of
struct acpi_hp_work accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
drivers/acpi/bus.c
drivers/acpi/internal.h
drivers/acpi/osl.c
drivers/acpi/scan.c
include/acpi/acpi_bus.h

index e61e7b8a2eaf129f6355b1d6f4cdbaf21329a5dc..afe6f9a919c111f39d4450582742bcddb248179d 100644 (file)
@@ -400,7 +400,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
        case ACPI_NOTIFY_BUS_CHECK:
        case ACPI_NOTIFY_DEVICE_CHECK:
        case ACPI_NOTIFY_EJECT_REQUEST:
-               status = acpi_hotplug_execute(acpi_device_hotplug, adev, type);
+               status = acpi_hotplug_schedule(adev, type);
                if (ACPI_SUCCESS(status))
                        return;
        default:
index 4d081fc1aa24c2ba3515bdbff7aab41fe3725e80..957391306cbf32953457b1e8a540a66b32bd253b 100644 (file)
@@ -78,8 +78,9 @@ void acpi_lpss_init(void);
 static inline void acpi_lpss_init(void) {}
 #endif
 
+acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
 bool acpi_queue_hotplug_work(struct work_struct *work);
-void acpi_device_hotplug(void *data, u32 src);
+void acpi_device_hotplug(struct acpi_device *adev, u32 src);
 bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
 
 /* --------------------------------------------------------------------------
index fc1aa7909690c3ef148930a4a96080d2bcaaa155..afb4be566940e0fe428176ff6200be3941dc74c8 100644 (file)
@@ -1168,8 +1168,7 @@ void acpi_os_wait_events_complete(void)
 
 struct acpi_hp_work {
        struct work_struct work;
-       acpi_hp_callback func;
-       void *data;
+       struct acpi_device *adev;
        u32 src;
 };
 
@@ -1178,25 +1177,24 @@ static void acpi_hotplug_work_fn(struct work_struct *work)
        struct acpi_hp_work *hpw = container_of(work, struct acpi_hp_work, work);
 
        acpi_os_wait_events_complete();
-       hpw->func(hpw->data, hpw->src);
+       acpi_device_hotplug(hpw->adev, hpw->src);
        kfree(hpw);
 }
 
-acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src)
+acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src)
 {
        struct acpi_hp_work *hpw;
 
        ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
-                 "Scheduling function [%p(%p, %u)] for deferred execution.\n",
-                 func, data, src));
+                 "Scheduling hotplug event (%p, %u) for deferred execution.\n",
+                 adev, src));
 
        hpw = kmalloc(sizeof(*hpw), GFP_KERNEL);
        if (!hpw)
                return AE_NO_MEMORY;
 
        INIT_WORK(&hpw->work, acpi_hotplug_work_fn);
-       hpw->func = func;
-       hpw->data = data;
+       hpw->adev = adev;
        hpw->src = src;
        /*
         * We can't run hotplug code in kacpid_wq/kacpid_notify_wq etc., because
index f6bcc24f73dca5730c6623e27ab3c671fe4d896d..eb7a1ff224e7afa03842322a5967fcd7042de1ff 100644 (file)
@@ -481,10 +481,9 @@ static int acpi_generic_hotplug_event(struct acpi_device *adev, u32 type)
        return -EINVAL;
 }
 
-void acpi_device_hotplug(void *data, u32 src)
+void acpi_device_hotplug(struct acpi_device *adev, u32 src)
 {
        u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
-       struct acpi_device *adev = data;
        int error = -ENODEV;
 
        lock_device_hotplug();
@@ -579,8 +578,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
                return -ENODEV;
 
        get_device(&acpi_device->dev);
-       status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device,
-                                     ACPI_OST_EC_OSPM_EJECT);
+       status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT);
        if (ACPI_SUCCESS(status))
                return count;
 
index fb23a7b6c91923939ea55e2b8fefe76da4b79323..660f5056a37fb30d214d320777cc49889d39b04d 100644 (file)
@@ -455,10 +455,6 @@ static inline bool acpi_device_enumerated(struct acpi_device *adev)
        return adev && adev->flags.initialized && adev->flags.visited;
 }
 
-typedef void (*acpi_hp_callback)(void *data, u32 src);
-
-acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src);
-
 /**
  * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver
  * @__acpi_driver: acpi_driver struct
This page took 0.044855 seconds and 5 git commands to generate.