Skip to content

Commit 9fdd97d

Browse files
macromorgansre
authored andcommitted
power: supply: axp20x_usb_power: 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-2-macroalpha82@gmail.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent c0f3a01 commit 9fdd97d

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

drivers/power/supply/axp20x_usb_power.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,15 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
220220
return 0;
221221
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
222222
if (IS_ENABLED(CONFIG_AXP20X_ADC)) {
223-
ret = iio_read_channel_processed(power->vbus_v,
224-
&val->intval);
225-
if (ret)
226-
return ret;
227-
228223
/*
229224
* IIO framework gives mV but Power Supply framework
230225
* gives uV.
231226
*/
232-
val->intval *= 1000;
227+
ret = iio_read_channel_processed_scale(power->vbus_v,
228+
&val->intval, 1000);
229+
if (ret)
230+
return ret;
231+
233232
return 0;
234233
}
235234

@@ -253,16 +252,15 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
253252
return 0;
254253
case POWER_SUPPLY_PROP_CURRENT_NOW:
255254
if (IS_ENABLED(CONFIG_AXP20X_ADC)) {
256-
ret = iio_read_channel_processed(power->vbus_i,
257-
&val->intval);
258-
if (ret)
259-
return ret;
260-
261255
/*
262256
* IIO framework gives mA but Power Supply framework
263257
* gives uA.
264258
*/
265-
val->intval *= 1000;
259+
ret = iio_read_channel_processed_scale(power->vbus_i,
260+
&val->intval, 1000);
261+
if (ret)
262+
return ret;
263+
266264
return 0;
267265
}
268266

@@ -374,16 +372,15 @@ static int axp717_usb_power_get_property(struct power_supply *psy,
374372
break;
375373
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
376374
if (IS_ENABLED(CONFIG_AXP20X_ADC)) {
377-
ret = iio_read_channel_processed(power->vbus_v,
378-
&val->intval);
379-
if (ret)
380-
return ret;
381-
382375
/*
383376
* IIO framework gives mV but Power Supply framework
384377
* gives uV.
385378
*/
386-
val->intval *= 1000;
379+
ret = iio_read_channel_processed_scale(power->vbus_v,
380+
&val->intval, 1000);
381+
if (ret)
382+
return ret;
383+
387384
return 0;
388385
}
389386

0 commit comments

Comments
 (0)