[PATCH v2] ALSA: atmel: ac97c: fix reset GPIO error handling
From: Sreeraj S Kurup
Date: Fri Nov 27 2026 - 05:07:50 EST
The driver currently ignores errors returned by
devm_gpiod_get_index() and continues probing. This can cause problems
when the GPIO provider is not ready and the function returns
-EPROBE_DEFER.
Use devm_gpiod_get_index_optional() to handle the reset GPIO as
optional. If the GPIO is not available, the driver can continue using
the internal reset mechanism. If GPIO acquisition fails for another
reason, return the error using dev_err_probe().
Also, check the GPIO descriptor for NULL in atmel_ac97c_reset(),
because the optional GPIO API returns NULL when no GPIO is assigned.
Fixes: 5f10e84934e4 ("ALSA: atmel: convert AC97c driver to GPIO descriptor API")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>
---
v2:
- Add Fixes trailer.
sound/atmel/ac97c.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 234549e17351..3ab6ddb3259f 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -670,7 +670,7 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip)
ac97c_writel(chip, CAMR, 0);
ac97c_writel(chip, COMR, 0);
- if (!IS_ERR(chip->reset_pin)) {
+ if (chip->reset_pin) {
gpiod_set_value(chip->reset_pin, 0);
/* AC97 v2.2 specifications says minimum 1 us. */
udelay(2);
@@ -743,9 +743,13 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
chip->pdev = pdev;
chip->regs = regs;
- chip->reset_pin = devm_gpiod_get_index(dev, "ac97", 2, GPIOD_OUT_HIGH);
+ chip->reset_pin = devm_gpiod_get_index_optional(dev,
+ "ac97", 2,
+ GPIOD_OUT_HIGH);
if (IS_ERR(chip->reset_pin))
- dev_dbg(dev, "reset pin not available\n");
+ return dev_err_probe(dev,
+ PTR_ERR(chip->reset_pin),
+ "failed to get reset GPIO\n");
atmel_ac97c_reset(chip);
--
2.55.0