Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Chris Morgan and committed by
Sebastian Reichel
1d3db2d9 9fdd97d6

+17 -16
+17 -16
drivers/power/supply/axp20x_battery.c
··· 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: ··· 407 406 break; 408 407 409 408 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 410 - ret = iio_read_channel_processed(axp20x_batt->batt_v, 411 - &val->intval); 409 + /* IIO framework gives mV but Power Supply framework gives uV */ 410 + ret = iio_read_channel_processed_scale(axp20x_batt->batt_v, 411 + &val->intval, 1000); 412 412 if (ret) 413 413 return ret; 414 414 415 - /* IIO framework gives mV but Power Supply framework gives uV */ 416 - val->intval *= 1000; 417 415 break; 418 416 419 417 default: ··· 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: ··· 566 564 return 0; 567 565 568 566 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 569 - ret = iio_read_channel_processed(axp20x_batt->batt_v, 570 - &val->intval); 567 + /* IIO framework gives mV but Power Supply framework gives uV */ 568 + ret = iio_read_channel_processed_scale(axp20x_batt->batt_v, 569 + &val->intval, 1000); 571 570 if (ret) 572 571 return ret; 573 572 574 - /* IIO framework gives mV but Power Supply framework gives uV */ 575 - val->intval *= 1000; 576 573 return 0; 577 574 578 575 case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: