[PATCH v7 3/4] drivers: leds: aw2013: Leverage C99 for-loops
From: Paul Sajna
Date: Sat Nov 14 2026 - 17:56:41 EST
Declare the int within the for-loop declaration rather than as a
separate local variable. To make the code more readable.
Signed-off-by: Paul Sajna <sajattack@xxxxxxxxxxxxxxxx>
---
drivers/leds/leds-aw2013.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c
index 2937a0f92d92..7fe7e9dae903 100644
--- a/drivers/leds/leds-aw2013.c
+++ b/drivers/leds/leds-aw2013.c
@@ -72,7 +72,7 @@ struct aw2013 {
static int aw2013_chip_init(struct aw2013 *chip)
{
- int i, ret;
+ int ret;
ret = regmap_write(chip->regmap, AW2013_GCR, AW2013_GCR_ENABLE);
if (ret) {
@@ -81,7 +81,7 @@ static int aw2013_chip_init(struct aw2013 *chip)
return ret;
}
- for (i = 0; i < chip->num_leds; i++) {
+ for (int i = 0; i < chip->num_leds; i++) {
ret = regmap_update_bits(chip->regmap,
AW2013_LCFG(chip->leds[i].num),
AW2013_LCFG_IMAX_MASK,
@@ -142,9 +142,7 @@ static int aw2013_chip_enable(struct aw2013 *chip)
static bool aw2013_chip_in_use(struct aw2013 *chip)
{
- int i;
-
- for (i = 0; i < chip->num_leds; i++)
+ for (int i = 0; i < chip->num_leds; i++)
if (chip->leds[i].cdev.brightness)
return true;
--
2.56.1