Re: [PATCH v3 1/3] hwmon: ina238: add support for samples and update_interval

From: Guenter Roeck

Date: Tue Jun 09 2026 - 16:45:06 EST


On Tue, Jun 09, 2026 at 09:43:10PM +0200, Ferdinand Schwenk wrote:
> From: Ferdinand Schwenk <ferdinand.schwenk@xxxxxxxxxxxxx>
>
> Expose INA238 ADC averaging count (AVG) and conversion timing
> (VBUSCT/VSHCT/VTCT) through chip-level hwmon attributes:
>
> chip/samples
> chip/update_interval
>
> Use per-chip conversion-time lookup tables so the same helpers work
> for INA228/INA237/INA238/INA700/INA780 and SQ52206. Cache ADC_CONFIG
> in driver data and update it on writes to avoid extra register reads
> during read-modify-write updates.
>
> Report update_interval in milliseconds as required by the hwmon ABI.
> Compute it from raw ADC cycle time multiplied by the active averaging
> count, and apply the inverse mapping on writes so programmed conversion
> time tracks the selected sample count.
>
> Clamp user-provided update_interval before unit scaling to prevent
> overflow in arithmetic conversions.
>
> Also combine chip attributes in HWMON_CHANNEL_INFO using a bitwise OR
> for a single logical chip channel.
>
> Signed-off-by: Ferdinand Schwenk <ferdinand.schwenk@xxxxxxxxxxxxx>

Applied.

Thanks,
Guenter