diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2022-01-29 01:49:24 +0100 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2022-02-11 20:24:53 +0100 |
commit | 0f6dad11fdf765a2fc89ef86961efcfcf94b5d0a (patch) | |
tree | 434bd4f60b4f32298087ab240d2fae79b8d27941 | |
parent | 75ee3f6f0c1a0b70b9afc2b758566aa49c3cf978 (diff) |
power: supply: ab8500_charger: Restrict ADC retrieveal
The AB8505 only has two ADC channels: the voltage and current
provided from VBUS (USB). It does not support AC charging at all.
Make sure we don't try to retrieve the non-existing channels.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-rw-r--r-- | drivers/power/supply/ab8500_charger.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index ce074c018dcb..681b53bb0df0 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -3443,17 +3443,19 @@ static int ab8500_charger_probe(struct platform_device *pdev) di->parent = dev_get_drvdata(pdev->dev.parent); /* Get ADC channels */ - di->adc_main_charger_v = devm_iio_channel_get(dev, "main_charger_v"); - if (IS_ERR(di->adc_main_charger_v)) { - ret = dev_err_probe(dev, PTR_ERR(di->adc_main_charger_v), - "failed to get ADC main charger voltage\n"); - return ret; - } - di->adc_main_charger_c = devm_iio_channel_get(dev, "main_charger_c"); - if (IS_ERR(di->adc_main_charger_c)) { - ret = dev_err_probe(dev, PTR_ERR(di->adc_main_charger_c), - "failed to get ADC main charger current\n"); - return ret; + if (!is_ab8505(di->parent)) { + di->adc_main_charger_v = devm_iio_channel_get(dev, "main_charger_v"); + if (IS_ERR(di->adc_main_charger_v)) { + ret = dev_err_probe(dev, PTR_ERR(di->adc_main_charger_v), + "failed to get ADC main charger voltage\n"); + return ret; + } + di->adc_main_charger_c = devm_iio_channel_get(dev, "main_charger_c"); + if (IS_ERR(di->adc_main_charger_c)) { + ret = dev_err_probe(dev, PTR_ERR(di->adc_main_charger_c), + "failed to get ADC main charger current\n"); + return ret; + } } di->adc_vbus_v = devm_iio_channel_get(dev, "vbus_v"); if (IS_ERR(di->adc_vbus_v)) { |