Skip to content

Commit 3845431

Browse files
committed
platform/apple: smc: Add apple_smc_read_ioft_scaled
"ioft" is a 48.16 fixed point type. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 1ff187a commit 3845431

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

drivers/platform/apple/smc_core.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,25 @@ int apple_smc_read_f32_scaled(struct apple_smc *smc, smc_key key, int *p, int sc
146146
}
147147
EXPORT_SYMBOL(apple_smc_read_f32_scaled);
148148

149+
/*
150+
* ioft is a 48.16 fixed point type
151+
*/
152+
int apple_smc_read_ioft_scaled(struct apple_smc *smc, smc_key key, u64 *p,
153+
int scale)
154+
{
155+
u64 val;
156+
int ret;
157+
158+
ret = apple_smc_read_u64(smc, key, &val);
159+
if (ret < 0)
160+
return ret;
161+
162+
*p = mult_frac(val, scale, 65536);
163+
164+
return 0;
165+
}
166+
EXPORT_SYMBOL(apple_smc_read_ioft_scaled);
167+
149168
int apple_smc_get_key_by_index(struct apple_smc *smc, int index, smc_key *key)
150169
{
151170
int ret;

include/linux/mfd/macsmc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static inline int apple_smc_read_flag(struct apple_smc *smc, smc_key key)
8383
#define apple_smc_write_flag apple_smc_write_u8
8484

8585
int apple_smc_read_f32_scaled(struct apple_smc *smc, smc_key key, int *p, int scale);
86+
int apple_smc_read_ioft_scaled(struct apple_smc *smc, smc_key key, u64 *p, int scale);
8687

8788
int apple_smc_register_notifier(struct apple_smc *smc, struct notifier_block *n);
8889
int apple_smc_unregister_notifier(struct apple_smc *smc, struct notifier_block *n);

0 commit comments

Comments
 (0)