@@ -10300,21 +10300,15 @@ static struct ibm_struct proxsensor_driver_data = {
10300
10300
#define DYTC_DISABLE_CQL DYTC_SET_COMMAND(DYTC_FUNCTION_CQL, DYTC_MODE_MMC_BALANCE, 0)
10301
10301
#define DYTC_ENABLE_CQL DYTC_SET_COMMAND(DYTC_FUNCTION_CQL, DYTC_MODE_MMC_BALANCE, 1)
10302
10302
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 ;
10310
10303
static enum platform_profile_option dytc_current_profile ;
10311
10304
static atomic_t dytc_ignore_event = ATOMIC_INIT (0 );
10312
10305
static DEFINE_MUTEX (dytc_mutex );
10306
+ static int dytc_capabilities ;
10313
10307
static bool dytc_mmc_get_available ;
10314
10308
10315
10309
static int convert_dytc_to_profile (int dytcmode , enum platform_profile_option * profile )
10316
10310
{
10317
- if (dytc_profile_available == DYTC_FUNCMODE_MMC ) {
10311
+ if (dytc_capabilities & BIT ( DYTC_FC_MMC ) ) {
10318
10312
switch (dytcmode ) {
10319
10313
case DYTC_MODE_MMC_LOWPOWER :
10320
10314
* profile = PLATFORM_PROFILE_LOW_POWER ;
@@ -10331,7 +10325,7 @@ static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *p
10331
10325
}
10332
10326
return 0 ;
10333
10327
}
10334
- if (dytc_profile_available == DYTC_FUNCMODE_PSC ) {
10328
+ if (dytc_capabilities & BIT ( DYTC_FC_PSC ) ) {
10335
10329
switch (dytcmode ) {
10336
10330
case DYTC_MODE_PSC_LOWPOWER :
10337
10331
* profile = PLATFORM_PROFILE_LOW_POWER ;
@@ -10353,21 +10347,21 @@ static int convert_profile_to_dytc(enum platform_profile_option profile, int *pe
10353
10347
{
10354
10348
switch (profile ) {
10355
10349
case PLATFORM_PROFILE_LOW_POWER :
10356
- if (dytc_profile_available == DYTC_FUNCMODE_MMC )
10350
+ if (dytc_capabilities & BIT ( DYTC_FC_MMC ) )
10357
10351
* perfmode = DYTC_MODE_MMC_LOWPOWER ;
10358
- else if (dytc_profile_available == DYTC_FUNCMODE_PSC )
10352
+ else if (dytc_capabilities & BIT ( DYTC_FC_PSC ) )
10359
10353
* perfmode = DYTC_MODE_PSC_LOWPOWER ;
10360
10354
break ;
10361
10355
case PLATFORM_PROFILE_BALANCED :
10362
- if (dytc_profile_available == DYTC_FUNCMODE_MMC )
10356
+ if (dytc_capabilities & BIT ( DYTC_FC_MMC ) )
10363
10357
* perfmode = DYTC_MODE_MMC_BALANCE ;
10364
- else if (dytc_profile_available == DYTC_FUNCMODE_PSC )
10358
+ else if (dytc_capabilities & BIT ( DYTC_FC_PSC ) )
10365
10359
* perfmode = DYTC_MODE_PSC_BALANCE ;
10366
10360
break ;
10367
10361
case PLATFORM_PROFILE_PERFORMANCE :
10368
- if (dytc_profile_available == DYTC_FUNCMODE_MMC )
10362
+ if (dytc_capabilities & BIT ( DYTC_FC_MMC ) )
10369
10363
* perfmode = DYTC_MODE_MMC_PERFORM ;
10370
- else if (dytc_profile_available == DYTC_FUNCMODE_PSC )
10364
+ else if (dytc_capabilities & BIT ( DYTC_FC_PSC ) )
10371
10365
* perfmode = DYTC_MODE_PSC_PERFORM ;
10372
10366
break ;
10373
10367
default : /* Unknown profile */
@@ -10446,7 +10440,7 @@ static int dytc_profile_set(struct platform_profile_handler *pprof,
10446
10440
if (err )
10447
10441
goto unlock ;
10448
10442
10449
- if (dytc_profile_available == DYTC_FUNCMODE_MMC ) {
10443
+ if (dytc_capabilities & BIT ( DYTC_FC_MMC ) ) {
10450
10444
if (profile == PLATFORM_PROFILE_BALANCED ) {
10451
10445
/*
10452
10446
* 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,
10465
10459
goto unlock ;
10466
10460
}
10467
10461
}
10468
- if (dytc_profile_available == DYTC_FUNCMODE_PSC ) {
10462
+ if (dytc_capabilities & BIT ( DYTC_FC_PSC ) ) {
10469
10463
err = dytc_command (DYTC_SET_COMMAND (DYTC_FUNCTION_PSC , perfmode , 1 ), & output );
10470
10464
if (err )
10471
10465
goto unlock ;
@@ -10484,12 +10478,12 @@ static void dytc_profile_refresh(void)
10484
10478
int perfmode ;
10485
10479
10486
10480
mutex_lock (& dytc_mutex );
10487
- if (dytc_profile_available == DYTC_FUNCMODE_MMC ) {
10481
+ if (dytc_capabilities & BIT ( DYTC_FC_MMC ) ) {
10488
10482
if (dytc_mmc_get_available )
10489
10483
err = dytc_command (DYTC_CMD_MMC_GET , & output );
10490
10484
else
10491
10485
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 ) )
10493
10487
err = dytc_command (DYTC_CMD_GET , & output );
10494
10488
10495
10489
mutex_unlock (& dytc_mutex );
@@ -10518,7 +10512,6 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
10518
10512
set_bit (PLATFORM_PROFILE_BALANCED , dytc_profile .choices );
10519
10513
set_bit (PLATFORM_PROFILE_PERFORMANCE , dytc_profile .choices );
10520
10514
10521
- dytc_profile_available = DYTC_FUNCMODE_NONE ;
10522
10515
err = dytc_command (DYTC_CMD_QUERY , & output );
10523
10516
if (err )
10524
10517
return err ;
@@ -10531,13 +10524,12 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
10531
10524
return - ENODEV ;
10532
10525
10533
10526
/* Check what capabilities are supported */
10534
- err = dytc_command (DYTC_CMD_FUNC_CAP , & output );
10527
+ err = dytc_command (DYTC_CMD_FUNC_CAP , & dytc_capabilities );
10535
10528
if (err )
10536
10529
return err ;
10537
10530
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" );
10541
10533
/*
10542
10534
* Check if MMC_GET functionality available
10543
10535
* Version > 6 and return success from MMC_GET command
@@ -10548,8 +10540,8 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
10548
10540
if (!err && ((output & DYTC_ERR_MASK ) == DYTC_ERR_SUCCESS ))
10549
10541
dytc_mmc_get_available = true;
10550
10542
}
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" ) ;
10553
10545
} else {
10554
10546
dbg_printk (TPACPI_DBG_INIT , "No DYTC support available\n" );
10555
10547
return - ENODEV ;
@@ -10575,7 +10567,6 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
10575
10567
10576
10568
static void dytc_profile_exit (void )
10577
10569
{
10578
- dytc_profile_available = DYTC_FUNCMODE_NONE ;
10579
10570
platform_profile_remove ();
10580
10571
}
10581
10572
0 commit comments