mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
mfd: macsmc: Fix key count endianness annotation
SMC firmware returns the value of the #KEY key in big-endian unlike most
other keys. Reading it through apple_smc_read_u32() into a plain u32
and then converting with be32_to_cpu() makes sparse complain:
drivers/mfd/macsmc.c:462:26: sparse: cast to restricted __be32
Read the raw value into a __be32 using apple_smc_read() instead.
Fixes: e038d985c9 ("mfd: Add Apple Silicon System Management Controller")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202607181046.OANjIoqR-lkp@intel.com/
Signed-off-by: Sven Peter <sven@kernel.org>
Reviewed-by: Janne Grunau <j@jannau.net>
Reviewed-by: Joshua Peisach <jpeisach@ubuntu.com>
Link: https://patch.msgid.link/20260719-b4-macsmc-be32-fix-v1-1-c7b1936307fa@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
f5071235a1
commit
0a29aa6052
|
|
@ -410,7 +410,7 @@ static int apple_smc_probe(struct platform_device *pdev)
|
|||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct apple_smc *smc;
|
||||
u32 count;
|
||||
__be32 count;
|
||||
int ret;
|
||||
|
||||
smc = devm_kzalloc(dev, sizeof(*smc), GFP_KERNEL);
|
||||
|
|
@ -461,8 +461,10 @@ static int apple_smc_probe(struct platform_device *pdev)
|
|||
dev_set_drvdata(&pdev->dev, smc);
|
||||
BLOCKING_INIT_NOTIFIER_HEAD(&smc->event_handlers);
|
||||
|
||||
ret = apple_smc_read_u32(smc, SMC_KEY(#KEY), &count);
|
||||
if (ret)
|
||||
ret = apple_smc_read(smc, SMC_KEY(#KEY), &count, sizeof(count));
|
||||
if (ret >= 0 && ret != sizeof(count))
|
||||
ret = -EINVAL;
|
||||
if (ret < 0)
|
||||
return dev_err_probe(smc->dev, ret, "Failed to get key count");
|
||||
smc->key_count = be32_to_cpu(count);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user