diff options
author | Hans de Goede <hdegoede@redhat.com> | 2022-08-26 14:14:52 +0300 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2022-08-26 14:16:19 +0300 |
commit | 57209ddd5be6c128cc18dad73c19d1b7f7cae6c1 (patch) | |
tree | 238f539214bf62fb847b312e689f0280b84c0747 /drivers/platform/x86/msi-laptop.c | |
parent | 5523632aa10f906dfe2eb714ee748590dc7fc6b1 (diff) | |
download | linux-57209ddd5be6c128cc18dad73c19d1b7f7cae6c1.tar.xz |
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: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220826111453.178962-1-hdegoede@redhat.com
Diffstat (limited to 'drivers/platform/x86/msi-laptop.c')
-rw-r--r-- | drivers/platform/x86/msi-laptop.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c index 5d4b10b8d771..74829f766b88 100644 --- a/drivers/platform/x86/msi-laptop.c +++ b/drivers/platform/x86/msi-laptop.c @@ -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); |