Re: [PATCH v5 08/11] iio: adc: hx711: localize loop iterators in hx711_read

From: Andy Shevchenko

Date: Wed Apr 29 2026 - 14:50:14 EST


On Wed, Apr 29, 2026 at 11:15:41AM +0530, Piyush Patle wrote:
> Tighten the scope of the loop variables in hx711_read() now that the
> trailing-pulse refactor is in place.
>
> No functional change.

Suggested-by:?

...

> static int hx711_read(struct hx711_data *hx711_data, int trailing_pulses)
> {
> - int i, ret;
> + int ret;
> int value = 0;
> int val = gpiod_get_value(hx711_data->gpiod_dout);

Try to place it to follow reversed xmas tree order (yes, it doesn't and won't
fully be, but it will be step closer).

int value = 0;
int val = gpiod_get_value(hx711_data->gpiod_dout);
int ret;

But as you see, this needs to be coupled with splitting definition and
assignment of val, hence

int value = 0;
int val;
int ret;

val = gpiod_get_value(hx711_data->gpiod_dout);

This part should be in a separate change before you are doing the loop
iterators.

TL;DR: Should be two patches here: 1) split val assignment; 2) this patch with
proper location of int ret.

--
With Best Regards,
Andy Shevchenko