Commit 57209ddd authored by Hans de Goede's avatar Hans de Goede

platform/x86: msi-laptop: Add msi_scm_model_exit() helper

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: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220826111453.178962-1-hdegoede@redhat.com
parent 5523632a
......@@ -1014,9 +1014,19 @@ static int __init load_scm_model_init(struct platform_device *sdev)
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 @@ static int __init msi_init(void)
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment