Re: [PATCH v4 2/7] iio: adc: hx711: move scale computation to per-device storage

From: Jonathan Cameron

Date: Tue Apr 28 2026 - 13:57:43 EST


On Tue, 28 Apr 2026 04:08:26 +0530
Piyush Patle <piyushpatle228@xxxxxxxxx> wrote:

> On Mon, Apr 27, 2026 at 7:32 PM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxx> wrote:
> >
> > On Mon, Apr 27, 2026 at 03:39:33PM +0530, Piyush Patle wrote:
> > > The gain-to-scale table hx711_gain_to_scale[] is a global array whose
> > > .scale fields are overwritten in hx711_probe() using the AVDD voltage
> > > read at probe time. When two HX711 sensors are connected to supplies at
> > > different voltages, the second probe call overwrites the scale values
> > > computed for the first sensor, silently corrupting its readings.
> > >
> > > Fix this by removing the .scale field from the global table, making the
> > > table const, and adding a per-instance gain_scale[] array to hx711_data.
> > > Populate gain_scale[] in hx711_probe() using the device's own AVDD
> > > regulator voltage. Update hx711_get_gain_to_scale() and
> > > hx711_get_scale_to_gain() to take the per-instance array as a parameter,
> > > and update hx711_scale_available_show() to retrieve it via iio_priv().
> > >
> > > No functional change for single-sensor configurations.
> >
> > ...
Hi Pisyush

A small process thing. Whilst it may seem less polite than you'd like
to be, we are all drowning in email! So don't send a reply if you
agree with all the feedback. Feel free to acknowledge the reviewer
when you list the changes in the changelog for v5.

Not almost everyone falls into this overreplying trap when they
start out so I send this email a lot!

Jonathan