Commit 32887570 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Sebastian Reichel

power: supply: ab8500: Fix error handling when calling iio_read_channel_processed()

The ab8500_charger_get_[ac|vbus]_[current|voltage]() functions should
return an error code on error.

Up to now, an un-initialized value is returned.
This makes the error handling of the callers un-reliable.

Return the error code instead, to fix the issue.

Fixes: 97ab78ba ("power: supply: ab8500_charger: Convert to IIO ADC")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/f9f65642331c9e40aaebb888589db043db80b7eb.1719037737.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent ad175de1
...@@ -488,8 +488,10 @@ static int ab8500_charger_get_ac_voltage(struct ab8500_charger *di) ...@@ -488,8 +488,10 @@ static int ab8500_charger_get_ac_voltage(struct ab8500_charger *di)
/* Only measure voltage if the charger is connected */ /* Only measure voltage if the charger is connected */
if (di->ac.charger_connected) { if (di->ac.charger_connected) {
ret = iio_read_channel_processed(di->adc_main_charger_v, &vch); ret = iio_read_channel_processed(di->adc_main_charger_v, &vch);
if (ret < 0) if (ret < 0) {
dev_err(di->dev, "%s ADC conv failed,\n", __func__); dev_err(di->dev, "%s ADC conv failed,\n", __func__);
return ret;
}
} else { } else {
vch = 0; vch = 0;
} }
...@@ -540,8 +542,10 @@ static int ab8500_charger_get_vbus_voltage(struct ab8500_charger *di) ...@@ -540,8 +542,10 @@ static int ab8500_charger_get_vbus_voltage(struct ab8500_charger *di)
/* Only measure voltage if the charger is connected */ /* Only measure voltage if the charger is connected */
if (di->usb.charger_connected) { if (di->usb.charger_connected) {
ret = iio_read_channel_processed(di->adc_vbus_v, &vch); ret = iio_read_channel_processed(di->adc_vbus_v, &vch);
if (ret < 0) if (ret < 0) {
dev_err(di->dev, "%s ADC conv failed,\n", __func__); dev_err(di->dev, "%s ADC conv failed,\n", __func__);
return ret;
}
} else { } else {
vch = 0; vch = 0;
} }
...@@ -563,8 +567,10 @@ static int ab8500_charger_get_usb_current(struct ab8500_charger *di) ...@@ -563,8 +567,10 @@ static int ab8500_charger_get_usb_current(struct ab8500_charger *di)
/* Only measure current if the charger is online */ /* Only measure current if the charger is online */
if (di->usb.charger_online) { if (di->usb.charger_online) {
ret = iio_read_channel_processed(di->adc_usb_charger_c, &ich); ret = iio_read_channel_processed(di->adc_usb_charger_c, &ich);
if (ret < 0) if (ret < 0) {
dev_err(di->dev, "%s ADC conv failed,\n", __func__); dev_err(di->dev, "%s ADC conv failed,\n", __func__);
return ret;
}
} else { } else {
ich = 0; ich = 0;
} }
...@@ -586,8 +592,10 @@ static int ab8500_charger_get_ac_current(struct ab8500_charger *di) ...@@ -586,8 +592,10 @@ static int ab8500_charger_get_ac_current(struct ab8500_charger *di)
/* Only measure current if the charger is online */ /* Only measure current if the charger is online */
if (di->ac.charger_online) { if (di->ac.charger_online) {
ret = iio_read_channel_processed(di->adc_main_charger_c, &ich); ret = iio_read_channel_processed(di->adc_main_charger_c, &ich);
if (ret < 0) if (ret < 0) {
dev_err(di->dev, "%s ADC conv failed,\n", __func__); dev_err(di->dev, "%s ADC conv failed,\n", __func__);
return ret;
}
} else { } else {
ich = 0; ich = 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