@@ -354,17 +354,18 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
354
354
if (ret )
355
355
return ret ;
356
356
357
+ /* IIO framework gives mA but Power Supply framework gives uA */
357
358
if (reg & AXP20X_PWR_STATUS_BAT_CHARGING ) {
358
- ret = iio_read_channel_processed (axp20x_batt -> batt_chrg_i , & val -> intval );
359
+ ret = iio_read_channel_processed_scale (axp20x_batt -> batt_chrg_i ,
360
+ & val -> intval , 1000 );
359
361
} else {
360
- ret = iio_read_channel_processed (axp20x_batt -> batt_dischrg_i , & val1 );
362
+ ret = iio_read_channel_processed_scale (axp20x_batt -> batt_dischrg_i ,
363
+ & val1 , 1000 );
361
364
val -> intval = - val1 ;
362
365
}
363
366
if (ret )
364
367
return ret ;
365
368
366
- /* IIO framework gives mA but Power Supply framework gives uA */
367
- val -> intval *= 1000 ;
368
369
break ;
369
370
370
371
case POWER_SUPPLY_PROP_CAPACITY :
@@ -406,13 +407,12 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
406
407
break ;
407
408
408
409
case POWER_SUPPLY_PROP_VOLTAGE_NOW :
409
- ret = iio_read_channel_processed (axp20x_batt -> batt_v ,
410
- & val -> intval );
410
+ /* IIO framework gives mV but Power Supply framework gives uV */
411
+ ret = iio_read_channel_processed_scale (axp20x_batt -> batt_v ,
412
+ & val -> intval , 1000 );
411
413
if (ret )
412
414
return ret ;
413
415
414
- /* IIO framework gives mV but Power Supply framework gives uV */
415
- val -> intval *= 1000 ;
416
416
break ;
417
417
418
418
default :
@@ -519,13 +519,15 @@ static int axp717_battery_get_prop(struct power_supply *psy,
519
519
* The offset of this value is currently unknown and is
520
520
* not documented in the datasheet. Based on
521
521
* observation it's assumed to be somewhere around
522
- * 450ma. I will leave the value raw for now.
522
+ * 450ma. I will leave the value raw for now. Note that
523
+ * IIO framework gives mA but Power Supply framework
524
+ * gives uA.
523
525
*/
524
- ret = iio_read_channel_processed (axp20x_batt -> batt_chrg_i , & val -> intval );
526
+ ret = iio_read_channel_processed_scale (axp20x_batt -> batt_chrg_i ,
527
+ & val -> intval , 1000 );
525
528
if (ret )
526
529
return ret ;
527
- /* IIO framework gives mA but Power Supply framework gives uA */
528
- val -> intval *= 1000 ;
530
+
529
531
return 0 ;
530
532
531
533
case POWER_SUPPLY_PROP_CAPACITY :
@@ -564,13 +566,12 @@ static int axp717_battery_get_prop(struct power_supply *psy,
564
566
return 0 ;
565
567
566
568
case POWER_SUPPLY_PROP_VOLTAGE_NOW :
567
- ret = iio_read_channel_processed (axp20x_batt -> batt_v ,
568
- & val -> intval );
569
+ /* IIO framework gives mV but Power Supply framework gives uV */
570
+ ret = iio_read_channel_processed_scale (axp20x_batt -> batt_v ,
571
+ & val -> intval , 1000 );
569
572
if (ret )
570
573
return ret ;
571
574
572
- /* IIO framework gives mV but Power Supply framework gives uV */
573
- val -> intval *= 1000 ;
574
575
return 0 ;
575
576
576
577
case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT :
0 commit comments