ACPI / notify: Clean up handling of hotplug events
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 30 Apr 2014 23:16:06 +0000 (01:16 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 6 May 2014 23:00:19 +0000 (01:00 +0200)
Make the handling of hotplug events in acpi_bus_notify() slightly
cleaner by using an extra local variable to indicate when
acpi_hotplug_schedule() should be called.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/bus.c

index cf925c4f36b70ee173ad2ad5a688416cfdb31734..610261a1b6c86dc3e32d4160e87f91d0090f535e 100644 (file)
@@ -340,16 +340,18 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
 {
        struct acpi_device *adev;
        struct acpi_driver *driver;
-       acpi_status status;
        u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
+       bool hotplug_event = false;
 
        switch (type) {
        case ACPI_NOTIFY_BUS_CHECK:
                acpi_handle_debug(handle, "ACPI_NOTIFY_BUS_CHECK event\n");
+               hotplug_event = true;
                break;
 
        case ACPI_NOTIFY_DEVICE_CHECK:
                acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK event\n");
+               hotplug_event = true;
                break;
 
        case ACPI_NOTIFY_DEVICE_WAKE:
@@ -358,6 +360,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
 
        case ACPI_NOTIFY_EJECT_REQUEST:
                acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
+               hotplug_event = true;
                break;
 
        case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
@@ -393,16 +396,9 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
            (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
                driver->ops.notify(adev, type);
 
-       switch (type) {
-       case ACPI_NOTIFY_BUS_CHECK:
-       case ACPI_NOTIFY_DEVICE_CHECK:
-       case ACPI_NOTIFY_EJECT_REQUEST:
-               status = acpi_hotplug_schedule(adev, type);
-               if (ACPI_SUCCESS(status))
-                       return;
-       default:
-               break;
-       }
+       if (hotplug_event && ACPI_SUCCESS(acpi_hotplug_schedule(adev, type)))
+               return;
+
        acpi_bus_put_acpi_device(adev);
        return;