platform/x86: msi-laptop: Add msi_scm_model_exit() helper
authorHans de Goede <hdegoede@redhat.com>
Fri, 26 Aug 2022 11:14:52 +0000 (13:14 +0200)
committerHans de Goede <hdegoede@redhat.com>
Fri, 26 Aug 2022 11:16:19 +0000 (13:16 +0200)
The probe-error-exit and remove paths both duplicate the exact same code
to undo load_scm_model_init(). Add a helper for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220826111453.178962-1-hdegoede@redhat.com
drivers/platform/x86/msi-laptop.c

index 5d4b10b8d7719fea4acc04dd00b0634c451d4770..74829f766b889aadfbcb2d0352268d46b2389e95 100644 (file)
@@ -1014,9 +1014,19 @@ fail_input:
        rfkill_cleanup();
 
 fail_rfkill:
-
        return result;
+}
+
+static void msi_scm_model_exit(void)
+{
+       if (!quirks->load_scm_model)
+               return;
 
+       i8042_remove_filter(msi_laptop_i8042_filter);
+       cancel_delayed_work_sync(&msi_touchpad_dwork);
+       input_unregister_device(msi_laptop_input_dev);
+       cancel_delayed_work_sync(&msi_rfkill_dwork);
+       rfkill_cleanup();
 }
 
 static int __init msi_init(void)
@@ -1104,13 +1114,7 @@ static int __init msi_init(void)
 fail_create_attr:
        sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group);
 fail_create_group:
-       if (quirks->load_scm_model) {
-               i8042_remove_filter(msi_laptop_i8042_filter);
-               cancel_delayed_work_sync(&msi_touchpad_dwork);
-               input_unregister_device(msi_laptop_input_dev);
-               cancel_delayed_work_sync(&msi_rfkill_dwork);
-               rfkill_cleanup();
-       }
+       msi_scm_model_exit();
 fail_scm_model_init:
        platform_device_del(msipf_device);
 fail_device_add:
@@ -1125,14 +1129,7 @@ fail_backlight:
 
 static void __exit msi_cleanup(void)
 {
-       if (quirks->load_scm_model) {
-               i8042_remove_filter(msi_laptop_i8042_filter);
-               cancel_delayed_work_sync(&msi_touchpad_dwork);
-               input_unregister_device(msi_laptop_input_dev);
-               cancel_delayed_work_sync(&msi_rfkill_dwork);
-               rfkill_cleanup();
-       }
-
+       msi_scm_model_exit();
        sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group);
        if (!quirks->old_ec_model && threeg_exists)
                device_remove_file(&msipf_device->dev, &dev_attr_threeg);