mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-16 23:36:09 -05:00
power: supply: axp20x_battery: Use scaled iio_read_channel
Change iio_read_channel_processed to iio_read_channel_processed_scale where appropriate. Signed-off-by: Chris Morgan <macromorgan@hotmail.com> Link: https://lore.kernel.org/r/20241023184800.109376-3-macroalpha82@gmail.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
committed by
Sebastian Reichel
parent
9fdd97d63f
commit
1d3db2d99f
@@ -354,17 +354,18 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* IIO framework gives mA but Power Supply framework gives uA */
|
||||
if (reg & AXP20X_PWR_STATUS_BAT_CHARGING) {
|
||||
ret = iio_read_channel_processed(axp20x_batt->batt_chrg_i, &val->intval);
|
||||
ret = iio_read_channel_processed_scale(axp20x_batt->batt_chrg_i,
|
||||
&val->intval, 1000);
|
||||
} else {
|
||||
ret = iio_read_channel_processed(axp20x_batt->batt_dischrg_i, &val1);
|
||||
ret = iio_read_channel_processed_scale(axp20x_batt->batt_dischrg_i,
|
||||
&val1, 1000);
|
||||
val->intval = -val1;
|
||||
}
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* IIO framework gives mA but Power Supply framework gives uA */
|
||||
val->intval *= 1000;
|
||||
break;
|
||||
|
||||
case POWER_SUPPLY_PROP_CAPACITY:
|
||||
@@ -406,13 +407,12 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
|
||||
break;
|
||||
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
|
||||
ret = iio_read_channel_processed(axp20x_batt->batt_v,
|
||||
&val->intval);
|
||||
/* IIO framework gives mV but Power Supply framework gives uV */
|
||||
ret = iio_read_channel_processed_scale(axp20x_batt->batt_v,
|
||||
&val->intval, 1000);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* IIO framework gives mV but Power Supply framework gives uV */
|
||||
val->intval *= 1000;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -519,13 +519,15 @@ static int axp717_battery_get_prop(struct power_supply *psy,
|
||||
* The offset of this value is currently unknown and is
|
||||
* not documented in the datasheet. Based on
|
||||
* observation it's assumed to be somewhere around
|
||||
* 450ma. I will leave the value raw for now.
|
||||
* 450ma. I will leave the value raw for now. Note that
|
||||
* IIO framework gives mA but Power Supply framework
|
||||
* gives uA.
|
||||
*/
|
||||
ret = iio_read_channel_processed(axp20x_batt->batt_chrg_i, &val->intval);
|
||||
ret = iio_read_channel_processed_scale(axp20x_batt->batt_chrg_i,
|
||||
&val->intval, 1000);
|
||||
if (ret)
|
||||
return ret;
|
||||
/* IIO framework gives mA but Power Supply framework gives uA */
|
||||
val->intval *= 1000;
|
||||
|
||||
return 0;
|
||||
|
||||
case POWER_SUPPLY_PROP_CAPACITY:
|
||||
@@ -564,13 +566,12 @@ static int axp717_battery_get_prop(struct power_supply *psy,
|
||||
return 0;
|
||||
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
|
||||
ret = iio_read_channel_processed(axp20x_batt->batt_v,
|
||||
&val->intval);
|
||||
/* IIO framework gives mV but Power Supply framework gives uV */
|
||||
ret = iio_read_channel_processed_scale(axp20x_batt->batt_v,
|
||||
&val->intval, 1000);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* IIO framework gives mV but Power Supply framework gives uV */
|
||||
val->intval *= 1000;
|
||||
return 0;
|
||||
|
||||
case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
|
||||
|
||||
Reference in New Issue
Block a user