diff options
author | Hans de Goede <hdegoede@redhat.com> | 2021-11-21 20:11:26 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2021-11-25 16:18:48 +0100 |
commit | 0b0d2fba4f3302b601c429c9286e66b3af2d29cb (patch) | |
tree | 8e12b10a573d85f1ba7cf2b7f6b653507b28ae92 /drivers | |
parent | 5a47ac0041678d3d610b3ac724bca8c4bda2ddff (diff) | |
download | linux-0b0d2fba4f3302b601c429c9286e66b3af2d29cb.tar.gz |
platform/x86: thinkpad_acpi: Cleanup dytc_profile_available
Remove the dytc_profile_available check from dytc_profile_set(),
that function only gets called if the platform_profile_handler was
registered, so the check is not necessary.
Make tpacpi_dytc_profile_init() return -ENODEV when it does not register
the platform_profile() handler this will cause
dytc_profile_driver_data.flags.init to not get set, which in turn will
cause the dytc_profile_exit() call to get skipped.
Together this avoids the need to have the dytc_profile_available
variable at all, since the information is now duplicated in the
dytc_profile_driver_data.flags.init flag.
Note this leaves a weirdly indented code-block behind, this is
deliberately done to make what actually changes in this commit clear.
This will be fixed-up in the next commit.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Mark Pearson <mpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211121191129.256713-5-hdegoede@redhat.com
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 724a0e966c58..7b7667b1a6fb 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -9911,7 +9911,6 @@ static struct ibm_struct proxsensor_driver_data = { #define DYTC_ENABLE_CQL DYTC_SET_COMMAND(DYTC_FUNCTION_CQL, DYTC_MODE_BALANCE, 1) -static bool dytc_profile_available; static enum platform_profile_option dytc_current_profile; static atomic_t dytc_ignore_event = ATOMIC_INIT(0); static DEFINE_MUTEX(dytc_mutex); @@ -10015,9 +10014,6 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, int output; int err; - if (!dytc_profile_available) - return -ENODEV; - err = mutex_lock_interruptible(&dytc_mutex); if (err) return err; @@ -10088,7 +10084,6 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) set_bit(PLATFORM_PROFILE_BALANCED, dytc_profile.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, dytc_profile.choices); - dytc_profile_available = false; err = dytc_command(DYTC_CMD_QUERY, &output); if (err) return err; @@ -10097,7 +10092,10 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dytc_version = (output >> DYTC_QUERY_REV_BIT) & 0xF; /* Check DYTC is enabled and supports mode setting */ - if (dytc_version >= 5) { + if (dytc_version < 5) + return -ENODEV; + + { dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); /* @@ -10117,9 +10115,8 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) * don't quit terminally. */ if (err) - return 0; + return -ENODEV; - dytc_profile_available = true; /* Ensure initial values are correct */ dytc_profile_refresh(); } @@ -10128,10 +10125,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) static void dytc_profile_exit(void) { - if (dytc_profile_available) { - dytc_profile_available = false; - platform_profile_remove(); - } + platform_profile_remove(); } static struct ibm_struct dytc_profile_driver_data = { |