Commit 934ed384 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Sebastian Reichel

power: supply: lp8788: Fix an error handling path in 'lp8788_charger_probe()'

In the probe function, in case of error, resources allocated in
'lp8788_setup_adc_channel()' must be released.

This can be achieved easily by using the devm_ variant of
'iio_channel_get()'.
This has the extra benefit to simplify the remove function and to axe the
'lp8788_release_adc_channel()' function which is now useless.

Fixes: 98a27664 ("power_supply: Add new lp8788 charger driver")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent a776f560
...@@ -572,27 +572,14 @@ static void lp8788_setup_adc_channel(struct device *dev, ...@@ -572,27 +572,14 @@ static void lp8788_setup_adc_channel(struct device *dev,
return; return;
/* ADC channel for battery voltage */ /* ADC channel for battery voltage */
chan = iio_channel_get(dev, pdata->adc_vbatt); chan = devm_iio_channel_get(dev, pdata->adc_vbatt);
pchg->chan[LP8788_VBATT] = IS_ERR(chan) ? NULL : chan; pchg->chan[LP8788_VBATT] = IS_ERR(chan) ? NULL : chan;
/* ADC channel for battery temperature */ /* ADC channel for battery temperature */
chan = iio_channel_get(dev, pdata->adc_batt_temp); chan = devm_iio_channel_get(dev, pdata->adc_batt_temp);
pchg->chan[LP8788_BATT_TEMP] = IS_ERR(chan) ? NULL : chan; pchg->chan[LP8788_BATT_TEMP] = IS_ERR(chan) ? NULL : chan;
} }
static void lp8788_release_adc_channel(struct lp8788_charger *pchg)
{
int i;
for (i = 0; i < LP8788_NUM_CHG_ADC; i++) {
if (!pchg->chan[i])
continue;
iio_channel_release(pchg->chan[i]);
pchg->chan[i] = NULL;
}
}
static ssize_t lp8788_show_charger_status(struct device *dev, static ssize_t lp8788_show_charger_status(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -735,7 +722,6 @@ static int lp8788_charger_remove(struct platform_device *pdev) ...@@ -735,7 +722,6 @@ static int lp8788_charger_remove(struct platform_device *pdev)
flush_work(&pchg->charger_work); flush_work(&pchg->charger_work);
lp8788_irq_unregister(pdev, pchg); lp8788_irq_unregister(pdev, pchg);
lp8788_psy_unregister(pchg); lp8788_psy_unregister(pchg);
lp8788_release_adc_channel(pchg);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment