[PATCH v5 08/11] iio: adc: hx711: localize loop iterators in hx711_read
From: Piyush Patle
Date: Wed Apr 29 2026 - 01:48:23 EST
Tighten the scope of the loop variables in hx711_read() now that the
trailing-pulse refactor is in place.
No functional change.
Signed-off-by: Piyush Patle <piyushpatle228@xxxxxxxxx>
---
Changes in v5:
- New patch split out of the trailing-pulse refactor during review.
- Use unsigned scoped loop iterators in hx711_read().
Changes in v4:
- The scoped loop-variable cleanup was previously bundled with the
trailing-pulse patch.
---
drivers/iio/adc/hx711.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c
index d85ff2f4a3dd..15b9f78b6a25 100644
--- a/drivers/iio/adc/hx711.c
+++ b/drivers/iio/adc/hx711.c
@@ -157,7 +157,7 @@ static int hx711_cycle(struct hx711_data *hx711_data)
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);
@@ -165,7 +165,7 @@ static int hx711_read(struct hx711_data *hx711_data, int trailing_pulses)
if (val)
return -EIO;
- for (i = 0; i < 24; i++) {
+ for (unsigned int i = 0; i < 24; i++) {
value <<= 1;
ret = hx711_cycle(hx711_data);
if (ret)
@@ -174,7 +174,7 @@ static int hx711_read(struct hx711_data *hx711_data, int trailing_pulses)
value ^= 0x800000;
- for (i = 0; i < trailing_pulses; i++)
+ for (unsigned int i = 0; i < trailing_pulses; i++)
hx711_cycle(hx711_data);
return value;
--
2.43.0