Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: alienware-wmi-wmax: Improve ID processing

Rename AWCC_SENSOR_ID_MASK to AWCC_SENSOR_ID_FLAG and reorder the ID
processing defines in a more logical manner. Then replace their use in
bitwise operations with FIELD_GET().

The latter also involves dropping the AWCC_SENSOR_ID_FLAG check inside
is_awcc_thermal_mode() in favor of extracting the first byte out of IDs
obtained with AWCC_OP_GET_RESOURCE_ID. This is also a requirement to add
support for Alienware Aurora desktops.

While at it, also rename is_awcc_thermal_mode() to
is_awcc_thermal_profile_id().

Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Link: https://lore.kernel.org/r/20250329-hwm-v7-2-a14ea39d8a94@gmail.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Kurt Borja and committed by
Ilpo Järvinen
a000da9d 8a1a0fb5

+20 -18
+20 -18
drivers/platform/x86/dell/alienware-wmi-wmax.c
··· 32 32 #define AWCC_THERMAL_MODE_GMODE 0xAB 33 33 34 34 #define AWCC_FAILURE_CODE 0xFFFFFFFF 35 - #define AWCC_THERMAL_TABLE_MASK GENMASK(7, 4) 35 + 36 + #define AWCC_SENSOR_ID_FLAG BIT(8) 36 37 #define AWCC_THERMAL_MODE_MASK GENMASK(3, 0) 37 - #define AWCC_SENSOR_ID_MASK BIT(8) 38 + #define AWCC_THERMAL_TABLE_MASK GENMASK(7, 4) 39 + #define AWCC_RESOURCE_ID_MASK GENMASK(7, 0) 38 40 39 41 static bool force_platform_profile; 40 42 module_param_unsafe(force_platform_profile, bool, 0); ··· 170 168 }; 171 169 172 170 enum AWCC_THERMAL_TABLES { 173 - AWCC_THERMAL_TABLE_LEGACY = 0x90, 174 - AWCC_THERMAL_TABLE_USTT = 0xA0, 171 + AWCC_THERMAL_TABLE_LEGACY = 0x9, 172 + AWCC_THERMAL_TABLE_USTT = 0xA, 175 173 }; 176 174 177 175 enum awcc_thermal_profile { ··· 447 445 * Thermal Profile control 448 446 * - Provides thermal profile control through the Platform Profile API 449 447 */ 450 - static bool is_awcc_thermal_mode(u32 code) 448 + static bool is_awcc_thermal_profile_id(u8 code) 451 449 { 452 - if (code & AWCC_SENSOR_ID_MASK) 450 + u8 table = FIELD_GET(AWCC_THERMAL_TABLE_MASK, code); 451 + u8 mode = FIELD_GET(AWCC_THERMAL_MODE_MASK, code); 452 + 453 + if (mode >= AWCC_PROFILE_LAST) 453 454 return false; 454 455 455 - if ((code & AWCC_THERMAL_MODE_MASK) >= AWCC_PROFILE_LAST) 456 - return false; 457 - 458 - if ((code & AWCC_THERMAL_TABLE_MASK) == AWCC_THERMAL_TABLE_LEGACY && 459 - (code & AWCC_THERMAL_MODE_MASK) >= AWCC_PROFILE_LEGACY_QUIET) 456 + if (table == AWCC_THERMAL_TABLE_LEGACY && mode >= AWCC_PROFILE_LEGACY_QUIET) 460 457 return true; 461 458 462 - if ((code & AWCC_THERMAL_TABLE_MASK) == AWCC_THERMAL_TABLE_USTT && 463 - (code & AWCC_THERMAL_MODE_MASK) <= AWCC_PROFILE_USTT_LOW_POWER) 459 + if (table == AWCC_THERMAL_TABLE_USTT && mode <= AWCC_PROFILE_USTT_LOW_POWER) 464 460 return true; 465 461 466 462 return false; ··· 548 548 return 0; 549 549 } 550 550 551 - if (!is_awcc_thermal_mode(out_data)) 551 + if (!is_awcc_thermal_profile_id(out_data)) 552 552 return -ENODATA; 553 553 554 - out_data &= AWCC_THERMAL_MODE_MASK; 554 + out_data = FIELD_GET(AWCC_THERMAL_MODE_MASK, out_data); 555 555 *profile = awcc_mode_to_platform_profile[out_data]; 556 556 557 557 return 0; ··· 597 597 u32 first_mode; 598 598 u32 out_data; 599 599 int ret; 600 + u8 id; 600 601 601 602 ret = awcc_thermal_information(priv->wdev, AWCC_OP_GET_SYSTEM_DESCRIPTION, 602 603 0, (u32 *) &sys_desc); ··· 616 615 if (ret == -EBADRQC) 617 616 break; 618 617 619 - if (!is_awcc_thermal_mode(out_data)) 618 + id = FIELD_GET(AWCC_RESOURCE_ID_MASK, out_data); 619 + if (!is_awcc_thermal_profile_id(id)) 620 620 continue; 621 621 622 - mode = out_data & AWCC_THERMAL_MODE_MASK; 622 + mode = FIELD_GET(AWCC_THERMAL_MODE_MASK, id); 623 623 profile = awcc_mode_to_platform_profile[mode]; 624 - priv->supported_thermal_profiles[profile] = out_data; 624 + priv->supported_thermal_profiles[profile] = id; 625 625 626 626 set_bit(profile, choices); 627 627 }