RE: [PATCH v5 2/2] power/supply: Add support for ltc4162-f/s and ltc4015

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
> Sent: Wednesday, December 11, 2024 9:38 AM
> To: Paller, Kim Seer <KimSeer.Paller@xxxxxxxxxx>
> Cc: Rob Herring <robh@xxxxxxxxxx>; Krzysztof Kozlowski <krzk+dt@xxxxxxxxxx>;
> Conor Dooley <conor+dt@xxxxxxxxxx>; Mike Looijmans
> <mike.looijmans@xxxxxxxx>; linux-pm@xxxxxxxxxxxxxxx;
> devicetree@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v5 2/2] power/supply: Add support for ltc4162-f/s and
> ltc4015
> 
> [External]
> 
> 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) :)

Yes, that makes sense. I just used the actual units seen in the datasheet in this case, 
but I’ll change it accordingly. Thanks for the correction.

>
> >
> >  	return 0;
> >  }
> 
> Otherwise LGTM.
> 
> -- Sebastian




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux