OSDN Git Service

platform/x86: thinkpad_acpi: Cleanup dytc_profile_available
authorHans de Goede <hdegoede@redhat.com>
Sun, 21 Nov 2021 19:11:26 +0000 (20:11 +0100)
committerHans de Goede <hdegoede@redhat.com>
Thu, 25 Nov 2021 15:18:48 +0000 (16:18 +0100)
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
drivers/platform/x86/thinkpad_acpi.c

index 724a0e9..7b7667b 100644 (file)
@@ -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 = {