From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: sreekuttan2156239@gmail.com, alexandre.belloni@bootlin.com,
claudiu.beznea@tuxon.dev, nicolas.ferre@microchip.com,
perex@perex.cz, tiwai@suse.de
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org
Subject: [PATCH v2] ALSA: atmel: ac97c: fix reset GPIO error handling
Date: Fri, 27 Nov 2026 10:06:45 +0000 [thread overview]
Message-ID: <20261127100645.3564-1-sreekuttan2156239@gmail.com> (raw)
In-Reply-To: <20261127095029.3280-1-sreekuttan2156239@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2026-11-27 11:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 9:50 [PATCH] ALSA: atmel: ac97c: fix reset GPIO error handling Sreeraj S Kurup
2026-11-27 10:06 ` Sreeraj S Kurup [this message]
2026-11-27 17:37 ` [PATCH v2] " Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127100645.3564-1-sreekuttan2156239@gmail.com \
--to=sreekuttan2156239@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox