Clean up all objects used by scm model when driver initial fail or exit
authorLee, Chun-Yi <jlee@novell.com>
Fri, 14 May 2010 22:18:54 +0000 (06:18 +0800)
committerMatthew Garrett <mjg@redhat.com>
Thu, 20 May 2010 13:46:12 +0000 (09:46 -0400)
Clean up i8042 filter, rfkill and cancel delayed work when msi-laptop driver initial fail or exit on MSI scm model.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
drivers/platform/x86/msi-laptop.c

index 5822d0ac68d210445c019e0772990bf08e9d6f2e..704b5faac599ecae7a03ee41867fc0f804ce4a7e 100644 (file)
@@ -859,6 +859,11 @@ static int __init msi_init(void)
 
 fail_platform_device2:
 
+       if (load_scm_model) {
+               i8042_remove_filter(msi_laptop_i8042_filter);
+               cancel_delayed_work_sync(&msi_rfkill_work);
+               rfkill_cleanup();
+       }
        platform_device_del(msipf_device);
 
 fail_platform_device1:
@@ -878,6 +883,11 @@ fail_backlight:
 
 static void __exit msi_cleanup(void)
 {
+       if (load_scm_model) {
+               i8042_remove_filter(msi_laptop_i8042_filter);
+               cancel_delayed_work_sync(&msi_rfkill_work);
+               rfkill_cleanup();
+       }
 
        sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group);
        if (!old_ec_model && threeg_exists)
@@ -886,9 +896,6 @@ static void __exit msi_cleanup(void)
        platform_driver_unregister(&msipf_driver);
        backlight_device_unregister(msibl_device);
 
-       i8042_remove_filter(msi_laptop_i8042_filter);
-       rfkill_cleanup();
-
        /* Enable automatic brightness control again */
        if (auto_brightness != 2)
                set_auto_brightness(1);