Re: [PATCH] (ina2xx) Drop bus_voltage_shift configuration

From: Guenter Roeck

Date: Mon Mar 02 2026 - 17:13:09 EST


On 3/2/26 08:02, Jonas Rebmann wrote:
Hi Guenter,

On 2026-03-02 16:50, Guenter Roeck wrote:
Hi,

On 3/2/26 07:26, Jonas Rebmann wrote:
The INA219 has the lowest three bits of the bus voltage register
zero-reserved and the bus_voltage_shift ina2xx_config field was
introduced to accommodate for that.

The INA234 has four bits of the bus voltage, of the shunt voltage, and
of the current registers zero-reserved but the latter two were
implemented by choosing a 16x higher conversion constant instead of a
separate field specifying a bit shift.

For consistency and simplicity, drop bus_voltage_shift and adapt the
conversion constants for INA219 and INA234 accordingly, yielding the
same measurement values.


This isn't about simplicity, it is about correctness.

The datasheet for INA234 says for the lower 4 bits:

      Always returns 0. Remove these bits from the full result by doing a
      right arithmetic shift

which is what we should do for all chips with reserved bits instead of
assuming that the reserved bits always return 0.

It says that for the reserved-zero bits at the lower end of the shunt
voltage and current registers of INA234 as well as for the bus voltage
register.

If bus_voltage_shift is kept, wouldn't a shunt_voltage_shift and
current_shift need to be introduced to support those registers of the
INA234 with the same notion of correctness?


shunt_voltage_shift, yes, but the current register is not used,
so a current_shift would be unnecessary.

Thanks,
Guenter