Hi, On Tue, Dec 10, 2024 at 02:05:06PM +0800, Kim Seer Paller wrote: > static int ltc4162l_get_ibat(struct ltc4162l_info *info, > union power_supply_propval *val) > { > + const struct ltc4162l_chip_info *chip_info = info->chip_info; > unsigned int regval; > int ret; > > @@ -249,9 +356,8 @@ static int ltc4162l_get_ibat(struct ltc4162l_info *info, > if (ret) > return ret; > > - /* Signed 16-bit number, 1.466μV / RSNSB amperes/LSB. */ > ret = (s16)(regval & 0xFFFF); > - val->intval = 100 * mult_frac(ret, 14660, (int)info->rsnsb); > + val->intval = mult_frac(ret, chip_info->ibat_resolution_uv, info->rsnsb); ibat_resolution_uv is in picovolt as far as I can see: 1.466 uV / RSNSB = 1466 nV / RSNSB = 1466000 pV / RSNSB RSNSB is provided in microOhm and picoVolt / microOhm equals microAmp, which is the unit expected by the power-supply subsystem. > return 0; > } > @@ -260,6 +366,7 @@ static int ltc4162l_get_ibat(struct ltc4162l_info *info, > static int ltc4162l_get_input_voltage(struct ltc4162l_info *info, > union power_supply_propval *val) > { > + const struct ltc4162l_chip_info *chip_info = info->chip_info; > unsigned int regval; > int ret; > > @@ -267,8 +374,7 @@ static int ltc4162l_get_input_voltage(struct ltc4162l_info *info, > if (ret) > return ret; > > - /* 1.649mV/LSB */ > - val->intval = regval * 1694; > + val->intval = regval * chip_info->vin_resolution_mv; I believe it should be vin_resolution_uv. Microvolt is what the power-supply subsystem wants and 1.649 mV (from the comment above) is 1649 uV (from the chip_info->vin_resolution_mv value) :) > > return 0; > } Otherwise LGTM. -- Sebastian
Attachment:
signature.asc
Description: PGP signature