From 04d6f72f68eac61abbdaf56dcbfcc8382542f07e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 18 Apr 2018 14:08:21 +0200 Subject: power: supply: axp288_fuelguage: Do not bind when the fg function is not used Some devices with an AXP288 PMIC do not have a battery at all, or use external charger and fuelgauge ICs instead of the AXP288 builtin functionality. On such devices we should not bind to the fuelgauge function to avoid exporting a non working power_supply class device. This also avoids the following errors repeating over and over again in dmesg: axp288_fuel_gauge axp288_fuel_gauge: capacity measurement not valid axp288_fuel_gauge axp288_fuel_gauge: Error 0xe2 contents not valid power_supply axp288_fuel_gauge: driver failed to report 'charge_now' property: -6 Cc: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Sebastian Reichel --- drivers/power/supply/axp288_fuel_gauge.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/power') diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c index fd8f0b2210bc..dabcf0c6ea95 100644 --- a/drivers/power/supply/axp288_fuel_gauge.c +++ b/drivers/power/supply/axp288_fuel_gauge.c @@ -754,10 +754,21 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev) [BAT_D_CURR] = "axp288-chrg-d-curr", [BAT_VOLT] = "axp288-batt-volt", }; + unsigned int val; if (dmi_check_system(axp288_fuel_gauge_blacklist)) return -ENODEV; + /* + * On some devices the fuelgauge and charger parts of the axp288 are + * not used, check that the fuelgauge is enabled (CC_CTRL != 0). + */ + ret = regmap_read(axp20x->regmap, AXP20X_CC_CTRL, &val); + if (ret < 0) + return ret; + if (val == 0) + return -ENODEV; + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; -- cgit v1.2.3-59-g8ed1b