ACPI / battery: ensure acpi_battery_init() has finish
authorLuis Henriques <luis.henriques@canonical.com>
Mon, 11 May 2015 21:49:05 +0000 (22:49 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 13 May 2015 22:58:40 +0000 (00:58 +0200)
Make sure that async function scheduled with async_schedule() has already
been executed.

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/battery.c

index 9c676a6f32cef882feff6ffd34e848e64e4252de..547e627611e0bb7d784e85bf87278e4079bd5a6a 100644 (file)
@@ -70,6 +70,7 @@ MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>");
 MODULE_DESCRIPTION("ACPI Battery Driver");
 MODULE_LICENSE("GPL");
 
+static async_cookie_t async_cookie;
 static int battery_bix_broken_package;
 static int battery_notification_delay_ms;
 static unsigned int cache_time = 1000;
@@ -1313,12 +1314,13 @@ static int __init acpi_battery_init(void)
        if (acpi_disabled)
                return -ENODEV;
 
-       async_schedule(acpi_battery_init_async, NULL);
+       async_cookie = async_schedule(acpi_battery_init_async, NULL);
        return 0;
 }
 
 static void __exit acpi_battery_exit(void)
 {
+       async_synchronize_cookie(async_cookie);
        acpi_bus_unregister_driver(&acpi_battery_driver);
 #ifdef CONFIG_ACPI_PROCFS_POWER
        acpi_unlock_battery_dir(acpi_battery_dir);