Created
April 26, 2024 05:28
-
-
Save jannau/0c0b5d7b95ce00cd7c3a4f989ebccdd8 to your computer and use it in GitHub Desktop.
hwmom SMC_KEYS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/drivers/hwmon/macsmc-hwmon.c b/drivers/hwmon/macsmc-hwmon.c | |
index b740bb0b1273..d5b15bbf4cb0 100644 | |
--- a/drivers/hwmon/macsmc-hwmon.c | |
+++ b/drivers/hwmon/macsmc-hwmon.c | |
@@ -116,7 +116,8 @@ static int macsmc_hwmon_read_key(struct apple_smc *smc, struct macsmc_hwmon_key | |
int ret; | |
switch (k->info.type_code) { | |
- case _SMC_KEY("flt "): { | |
+ // case _SMC_KEY("flt "): { | |
+ case SMC_KEY_C('f', 'l', 't', ' '): { | |
u32 flt32; | |
ret = apple_smc_read_f32_scaled(smc, k->key, &flt32, scale); | |
if (ret < 0) | |
@@ -124,7 +125,7 @@ static int macsmc_hwmon_read_key(struct apple_smc *smc, struct macsmc_hwmon_key | |
*val = flt32; | |
return 0; | |
} | |
- case _SMC_KEY("ioft"): { | |
+ case SMC_KEY_C('i','o','f','t'): { | |
u64 ui64; | |
ret = apple_smc_read_ioft_scaled(smc, k->key, &ui64, scale); | |
if (ret) | |
@@ -141,10 +142,10 @@ static int macsmc_hwmon_write_key(struct apple_smc *smc, struct macsmc_hwmon_key | |
long val, int scale) | |
{ | |
switch (k->info.type_code) { | |
- case _SMC_KEY("flt "): { | |
+ case SMC_KEY_C('f','l','t',' '): { | |
return apple_smc_write_f32_scaled(smc, k->key, val, scale); | |
} | |
- case _SMC_KEY("ui8 "): { | |
+ case SMC_KEY_C('u','i','8',' '): { | |
return apple_smc_write_u8(smc, k->key, val); | |
} | |
default: | |
diff --git a/include/linux/mfd/macsmc.h b/include/linux/mfd/macsmc.h | |
index e6d7eb491ef4..a5be11856775 100644 | |
--- a/include/linux/mfd/macsmc.h | |
+++ b/include/linux/mfd/macsmc.h | |
@@ -13,6 +13,7 @@ typedef u32 smc_key; | |
#define SMC_KEY(s) (smc_key)(_SMC_KEY(#s)) | |
#define _SMC_KEY(s) (((s)[0] << 24) | ((s)[1] << 16) | ((s)[2] << 8) | (s)[3]) | |
+#define SMC_KEY_C(a, b, c, d) ( ((u32)(a) << 24) | ((u32)(b) << 16) | ((u32)(c) << 8) | (u32)(c)) | |
#define APPLE_SMC_READABLE BIT(7) | |
#define APPLE_SMC_WRITABLE BIT(6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment