[PATCH v3 6/6] leds: aw2013: Move reset register write
From: Paul Sajna
Date: Tue Oct 13 2026 - 01:41:30 EST
It has no reason to be in probe_dt, and putting it there complicates
the mutex requirements.
probe_dt calls devm_led_classdev_register_ext, which may trigger a
callback to aw2013_brightness_set, which would result in deadlock.
Signed-off-by: Paul Sajna <sajattack@xxxxxxxxxxxxxxxx>
---
drivers/leds/leds-aw2013.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c
index 6e661afd7775..8d1d649064c7 100644
--- a/drivers/leds/leds-aw2013.c
+++ b/drivers/leds/leds-aw2013.c
@@ -383,8 +383,6 @@ static int aw2013_probe_dt(struct aw2013 *chip)
if (!count || count > AW2013_MAX_LEDS)
return -EINVAL;
- regmap_write(chip->regmap, AW2013_RSTR, AW2013_RSTR_RESET);
-
for_each_available_child_of_node_scoped(np, child) {
struct led_init_data init_data = {};
u32 source;
@@ -504,6 +502,14 @@ static int aw2013_probe(struct i2c_client *client)
if (ret)
goto error_reg;
+ ret = regmap_write(chip->regmap, AW2013_RSTR, AW2013_RSTR_RESET);
+ if (ret) {
+ dev_err(&chip->client->dev, "Failed to reset the chip: %d\n", ret);
+ goto error_reg;
+ }
+
+ mutex_unlock(&chip->mutex);
+
ret = aw2013_probe_dt(chip);
if (ret < 0)
goto error_reg;
@@ -516,8 +522,6 @@ static int aw2013_probe(struct i2c_client *client)
goto error;
}
- mutex_unlock(&chip->mutex);
-
return 0;
error_reg:
--
2.55.0