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

power: supply: sc27xx: Add POWER_SUPPLY_PROP_CHARGE_NOW attribute

Add the POWER_SUPPLY_PROP_CHARGE_NOW attribute to allow user to get
current battery capacity (uAh) to do measurement.

Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Baolin Wang and committed by
Sebastian Reichel
1c5dfc5e 5b11e5d7

+12
+12
drivers/power/supply/sc27xx_fuel_gauge.c
··· 614 614 val->intval = data->total_cap * 1000; 615 615 break; 616 616 617 + case POWER_SUPPLY_PROP_CHARGE_NOW: 618 + ret = sc27xx_fgu_get_clbcnt(data, &value); 619 + if (ret) 620 + goto error; 621 + 622 + value = DIV_ROUND_CLOSEST(value * 10, 623 + 36 * SC27XX_FGU_SAMPLE_HZ); 624 + val->intval = sc27xx_fgu_adc_to_current(data, value); 625 + 626 + break; 627 + 617 628 default: 618 629 ret = -EINVAL; 619 630 break; ··· 693 682 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, 694 683 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 695 684 POWER_SUPPLY_PROP_CALIBRATE, 685 + POWER_SUPPLY_PROP_CHARGE_NOW 696 686 }; 697 687 698 688 static const struct power_supply_desc sc27xx_fgu_desc = {