Re: [PATCH v4 5/7] iio: adc: hx711: pass trailing pulse count into hx711_read()

Piyush Patle
2026-04-27T22:50:34Z

On Mon, Apr 27, 2026 at 7:42 PM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
>
> On Mon, Apr 27, 2026 at 03:39:36PM +0530, Piyush Patle wrote:
> > Move the trailing-pulse computation out of hx711_read() and into the
> > callers. hx711_read() now takes an explicit 'trailing_pulses' parameter
> > so the HX710B support patch can pass the per-channel count stored in
> > chan->address without adding a separate code path in hx711_read().
> >
> > Use scoped loop variables (for (int i = ...) / for (unsigned int i = ...))
> > to tighten the scope of the loop counters.
> >
> > No functional change.
>
> ...
>
> > -static int hx711_read(struct hx711_data *hx711_data)
> > +static int hx711_read(struct hx711_data *hx711_data, unsigned int trailing_pulses)
> > {
> > - int i, ret;
> > + int ret;
> > int value = 0;
> > int val = gpiod_get_value(hx711_data->gpiod_dout);
>
> Try to follow the reversed xmas tree order.
Will reorder hx711_read() locals
>
> > - for (i = 0; i < 24; i++) {
> > + for (int i = 0; i < 24; i++) {
>
> Why is 'i' signed?
Will change to `unsigned int i` in the scoped-iterator patch.
>
> > - for (i = 0; i < hx711_get_gain_to_pulse(hx711_data->gain_set); i++)
> > + for (unsigned int i = 0; i < trailing_pulses; i++)
> > hx711_cycle(hx711_data);
>
> With the above the both seems like a candidate to a separate change (after this
> trailing_pulses patch).
>
> > return value;
>
> ...
>
> So, split this to two:
> - trailing_pulses (without touching 'i')
> - localising loop iterators
>
Will split in v5.
> --
> With Best Regards,
> Andy Shevchenko
>
>