Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 42504af

Browse files
mrhpearsonjwrdegoede
authored andcommitted
platform/x86: thinkpad-acpi: profile capabilities as integer
Currently the active mode (PSC/MMC) is stored in an enum and queried throughout the driver. Other driver changes will enumerate additional submodes that are relevant to be tracked, so instead track PSC/MMC in a single integer variable. Co-developed-by: Mario Limonciello <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Mark Pearson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent aacb455 commit 42504af

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10300,21 +10300,15 @@ static struct ibm_struct proxsensor_driver_data = {
1030010300
#define DYTC_DISABLE_CQL DYTC_SET_COMMAND(DYTC_FUNCTION_CQL, DYTC_MODE_MMC_BALANCE, 0)
1030110301
#define DYTC_ENABLE_CQL DYTC_SET_COMMAND(DYTC_FUNCTION_CQL, DYTC_MODE_MMC_BALANCE, 1)
1030210302

10303-
enum dytc_profile_funcmode {
10304-
DYTC_FUNCMODE_NONE = 0,
10305-
DYTC_FUNCMODE_MMC,
10306-
DYTC_FUNCMODE_PSC,
10307-
};
10308-
10309-
static enum dytc_profile_funcmode dytc_profile_available;
1031010303
static enum platform_profile_option dytc_current_profile;
1031110304
static atomic_t dytc_ignore_event = ATOMIC_INIT(0);
1031210305
static DEFINE_MUTEX(dytc_mutex);
10306+
static int dytc_capabilities;
1031310307
static bool dytc_mmc_get_available;
1031410308

1031510309
static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *profile)
1031610310
{
10317-
if (dytc_profile_available == DYTC_FUNCMODE_MMC) {
10311+
if (dytc_capabilities & BIT(DYTC_FC_MMC)) {
1031810312
switch (dytcmode) {
1031910313
case DYTC_MODE_MMC_LOWPOWER:
1032010314
*profile = PLATFORM_PROFILE_LOW_POWER;
@@ -10331,7 +10325,7 @@ static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *p
1033110325
}
1033210326
return 0;
1033310327
}
10334-
if (dytc_profile_available == DYTC_FUNCMODE_PSC) {
10328+
if (dytc_capabilities & BIT(DYTC_FC_PSC)) {
1033510329
switch (dytcmode) {
1033610330
case DYTC_MODE_PSC_LOWPOWER:
1033710331
*profile = PLATFORM_PROFILE_LOW_POWER;
@@ -10353,21 +10347,21 @@ static int convert_profile_to_dytc(enum platform_profile_option profile, int *pe
1035310347
{
1035410348
switch (profile) {
1035510349
case PLATFORM_PROFILE_LOW_POWER:
10356-
if (dytc_profile_available == DYTC_FUNCMODE_MMC)
10350+
if (dytc_capabilities & BIT(DYTC_FC_MMC))
1035710351
*perfmode = DYTC_MODE_MMC_LOWPOWER;
10358-
else if (dytc_profile_available == DYTC_FUNCMODE_PSC)
10352+
else if (dytc_capabilities & BIT(DYTC_FC_PSC))
1035910353
*perfmode = DYTC_MODE_PSC_LOWPOWER;
1036010354
break;
1036110355
case PLATFORM_PROFILE_BALANCED:
10362-
if (dytc_profile_available == DYTC_FUNCMODE_MMC)
10356+
if (dytc_capabilities & BIT(DYTC_FC_MMC))
1036310357
*perfmode = DYTC_MODE_MMC_BALANCE;
10364-
else if (dytc_profile_available == DYTC_FUNCMODE_PSC)
10358+
else if (dytc_capabilities & BIT(DYTC_FC_PSC))
1036510359
*perfmode = DYTC_MODE_PSC_BALANCE;
1036610360
break;
1036710361
case PLATFORM_PROFILE_PERFORMANCE:
10368-
if (dytc_profile_available == DYTC_FUNCMODE_MMC)
10362+
if (dytc_capabilities & BIT(DYTC_FC_MMC))
1036910363
*perfmode = DYTC_MODE_MMC_PERFORM;
10370-
else if (dytc_profile_available == DYTC_FUNCMODE_PSC)
10364+
else if (dytc_capabilities & BIT(DYTC_FC_PSC))
1037110365
*perfmode = DYTC_MODE_PSC_PERFORM;
1037210366
break;
1037310367
default: /* Unknown profile */
@@ -10446,7 +10440,7 @@ static int dytc_profile_set(struct platform_profile_handler *pprof,
1044610440
if (err)
1044710441
goto unlock;
1044810442

10449-
if (dytc_profile_available == DYTC_FUNCMODE_MMC) {
10443+
if (dytc_capabilities & BIT(DYTC_FC_MMC)) {
1045010444
if (profile == PLATFORM_PROFILE_BALANCED) {
1045110445
/*
1045210446
* To get back to balanced mode we need to issue a reset command.
@@ -10465,7 +10459,7 @@ static int dytc_profile_set(struct platform_profile_handler *pprof,
1046510459
goto unlock;
1046610460
}
1046710461
}
10468-
if (dytc_profile_available == DYTC_FUNCMODE_PSC) {
10462+
if (dytc_capabilities & BIT(DYTC_FC_PSC)) {
1046910463
err = dytc_command(DYTC_SET_COMMAND(DYTC_FUNCTION_PSC, perfmode, 1), &output);
1047010464
if (err)
1047110465
goto unlock;
@@ -10484,12 +10478,12 @@ static void dytc_profile_refresh(void)
1048410478
int perfmode;
1048510479

1048610480
mutex_lock(&dytc_mutex);
10487-
if (dytc_profile_available == DYTC_FUNCMODE_MMC) {
10481+
if (dytc_capabilities & BIT(DYTC_FC_MMC)) {
1048810482
if (dytc_mmc_get_available)
1048910483
err = dytc_command(DYTC_CMD_MMC_GET, &output);
1049010484
else
1049110485
err = dytc_cql_command(DYTC_CMD_GET, &output);
10492-
} else if (dytc_profile_available == DYTC_FUNCMODE_PSC)
10486+
} else if (dytc_capabilities & BIT(DYTC_FC_PSC))
1049310487
err = dytc_command(DYTC_CMD_GET, &output);
1049410488

1049510489
mutex_unlock(&dytc_mutex);
@@ -10518,7 +10512,6 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
1051810512
set_bit(PLATFORM_PROFILE_BALANCED, dytc_profile.choices);
1051910513
set_bit(PLATFORM_PROFILE_PERFORMANCE, dytc_profile.choices);
1052010514

10521-
dytc_profile_available = DYTC_FUNCMODE_NONE;
1052210515
err = dytc_command(DYTC_CMD_QUERY, &output);
1052310516
if (err)
1052410517
return err;
@@ -10531,13 +10524,12 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
1053110524
return -ENODEV;
1053210525

1053310526
/* Check what capabilities are supported */
10534-
err = dytc_command(DYTC_CMD_FUNC_CAP, &output);
10527+
err = dytc_command(DYTC_CMD_FUNC_CAP, &dytc_capabilities);
1053510528
if (err)
1053610529
return err;
1053710530

10538-
if (output & BIT(DYTC_FC_MMC)) { /* MMC MODE */
10539-
dytc_profile_available = DYTC_FUNCMODE_MMC;
10540-
10531+
if (dytc_capabilities & BIT(DYTC_FC_MMC)) { /* MMC MODE */
10532+
pr_debug("MMC is supported\n");
1054110533
/*
1054210534
* Check if MMC_GET functionality available
1054310535
* Version > 6 and return success from MMC_GET command
@@ -10548,8 +10540,8 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
1054810540
if (!err && ((output & DYTC_ERR_MASK) == DYTC_ERR_SUCCESS))
1054910541
dytc_mmc_get_available = true;
1055010542
}
10551-
} else if (output & BIT(DYTC_FC_PSC)) { /* PSC MODE */
10552-
dytc_profile_available = DYTC_FUNCMODE_PSC;
10543+
} else if (dytc_capabilities & BIT(DYTC_FC_PSC)) { /* PSC MODE */
10544+
pr_debug("PSC is supported\n");
1055310545
} else {
1055410546
dbg_printk(TPACPI_DBG_INIT, "No DYTC support available\n");
1055510547
return -ENODEV;
@@ -10575,7 +10567,6 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
1057510567

1057610568
static void dytc_profile_exit(void)
1057710569
{
10578-
dytc_profile_available = DYTC_FUNCMODE_NONE;
1057910570
platform_profile_remove();
1058010571
}
1058110572

0 commit comments

Comments
 (0)