Skip to content

Commit a5fa95a

Browse files
committed
macsmc: power: ac: Report only supported properties
The SMC firmware in macOS 15.4 dropped "AC-i" and "AC-n" (and all keys with lower case last letter) without obvious replacement. Stop reporting VOLTAGE_NOW / INPUT_CURRENT_LIMIT if "AC-n" is not present. Signed-off-by: Janne Grunau <[email protected]>
1 parent b7cbf3a commit a5fa95a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/power/supply/macsmc_power.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
struct macsmc_power {
3232
struct device *dev;
3333
struct apple_smc *smc;
34+
struct power_supply_desc ac_desc;
3435
struct power_supply_desc batt_desc;
3536

3637
struct power_supply *batt;
@@ -638,9 +639,9 @@ static int macsmc_ac_get_property(struct power_supply *psy,
638639

639640
static enum power_supply_property macsmc_ac_props[] = {
640641
POWER_SUPPLY_PROP_ONLINE,
642+
POWER_SUPPLY_PROP_INPUT_POWER_LIMIT,
641643
POWER_SUPPLY_PROP_VOLTAGE_NOW,
642644
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
643-
POWER_SUPPLY_PROP_INPUT_POWER_LIMIT,
644645
};
645646

646647
static const struct power_supply_desc macsmc_ac_desc = {
@@ -789,6 +790,7 @@ static int macsmc_power_probe(struct platform_device *pdev)
789790

790791
power->dev = &pdev->dev;
791792
power->smc = smc;
793+
power->ac_desc = macsmc_ac_desc;
792794
power->batt_desc = macsmc_battery_desc;
793795
dev_set_drvdata(&pdev->dev, power);
794796

@@ -832,7 +834,12 @@ static int macsmc_power_probe(struct platform_device *pdev)
832834
return ret;
833835
}
834836

835-
power->ac = devm_power_supply_register(&pdev->dev, &macsmc_ac_desc, &psy_cfg);
837+
/* SMC firmware in macOS 15.4 dropped "AC-i" and "AC-n" (and all keys
838+
* with lower case last letter) without obvious replacement. */
839+
if (apple_smc_read_u16(power->smc, SMC_KEY(AC-n), &vu16) < 0)
840+
power->ac_desc.num_properties -= 2;
841+
842+
power->ac = devm_power_supply_register(&pdev->dev, &power->ac_desc, &psy_cfg);
836843
if (IS_ERR(power->ac)) {
837844
dev_err(&pdev->dev, "Failed to register AC adapter\n");
838845
ret = PTR_ERR(power->ac);

0 commit comments

Comments
 (0)