* [PATCH 1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling
@ 2026-10-09 11:22 phucduc.bui
2026-10-09 11:22 ` [PATCH 2/2] ASoC: codecs: rt5659: propagate GPIO errors phucduc.bui
2026-10-09 15:37 ` [PATCH 1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling Alvin Šipraga
0 siblings, 2 replies; 4+ messages in thread
From: phucduc.bui @ 2026-10-09 11:22 UTC (permalink / raw)
To: Mark Brown, Oder Chiou, Bard Liao
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
gpiod_not_found() converts -ENOENT to NULL before
devm_gpiod_get_optional() returns, so there is no need to handle
-ENOENT explicitly.
Use dev_err_probe() to simplify error reporting and handle
-EPROBE_DEFER.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/rt5645.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 7313ea71c958..ea58512a55b0 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -4032,26 +4032,16 @@ static int rt5645_i2c_probe(struct i2c_client *i2c)
rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect",
GPIOD_IN);
- if (IS_ERR(rt5645->gpiod_hp_det)) {
- dev_info(&i2c->dev, "failed to initialize gpiod\n");
- ret = PTR_ERR(rt5645->gpiod_hp_det);
- /*
- * Continue if optional gpiod is missing, bail for all other
- * errors, including -EPROBE_DEFER
- */
- if (ret != -ENOENT)
- return ret;
- }
+ if (IS_ERR(rt5645->gpiod_hp_det))
+ return dev_err_probe(&i2c->dev, PTR_ERR(rt5645->gpiod_hp_det),
+ "failed to get hp-detect gpio\n");
rt5645->gpiod_cbj_sleeve = devm_gpiod_get_optional(&i2c->dev, "cbj-sleeve",
GPIOD_OUT_LOW);
- if (IS_ERR(rt5645->gpiod_cbj_sleeve)) {
- ret = PTR_ERR(rt5645->gpiod_cbj_sleeve);
- dev_info(&i2c->dev, "failed to initialize gpiod, ret=%d\n", ret);
- if (ret != -ENOENT)
- return ret;
- }
+ if (IS_ERR(rt5645->gpiod_cbj_sleeve))
+ return dev_err_probe(&i2c->dev, PTR_ERR(rt5645->gpiod_cbj_sleeve),
+ "failed to get cbj-sleeve gpio\n");
for (i = 0; i < ARRAY_SIZE(rt5645->supplies); i++)
rt5645->supplies[i].supply = rt5645_supply_names[i];
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] ASoC: codecs: rt5659: propagate GPIO errors
2026-10-09 11:22 [PATCH 1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling phucduc.bui
@ 2026-10-09 11:22 ` phucduc.bui
2026-10-09 15:38 ` Alvin Šipraga
2026-10-09 15:37 ` [PATCH 1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling Alvin Šipraga
1 sibling, 1 reply; 4+ messages in thread
From: phucduc.bui @ 2026-10-09 11:22 UTC (permalink / raw)
To: Mark Brown, Oder Chiou, Bard Liao
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
devm_gpiod_get_optional() may return an error pointer, including
-EPROBE_DEFER, but rt5659_i2c_probe() does not handle these errors
for the ldo1-en GPIO and does not check for errors for the reset GPIO.
Check the return values and propagate GPIO lookup errors.
Fixes: d3cb2de2479b ("ASoC: rt5659: add rt5659 codec driver")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/rt5659.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c
index 3097ee6d4e89..b40dc9c50139 100644
--- a/sound/soc/codecs/rt5659.c
+++ b/sound/soc/codecs/rt5659.c
@@ -4113,10 +4113,14 @@ static int rt5659_i2c_probe(struct i2c_client *i2c)
rt5659->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev, "ldo1-en",
GPIOD_OUT_HIGH);
if (IS_ERR(rt5659->gpiod_ldo1_en))
- dev_warn(&i2c->dev, "Request ldo1-en GPIO failed\n");
+ return dev_err_probe(&i2c->dev, PTR_ERR(rt5659->gpiod_ldo1_en),
+ "failed to get ldo1-en GPIO\n");
rt5659->gpiod_reset = devm_gpiod_get_optional(&i2c->dev, "reset",
GPIOD_OUT_HIGH);
+ if (IS_ERR(rt5659->gpiod_reset))
+ return dev_err_probe(&i2c->dev, PTR_ERR(rt5659->gpiod_reset),
+ "failed to get reset GPIO\n");
/* Sleep for 300 ms minimum */
msleep(300);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 2/2] ASoC: codecs: rt5659: propagate GPIO errors
2026-10-09 11:22 ` [PATCH 2/2] ASoC: codecs: rt5659: propagate GPIO errors phucduc.bui
@ 2026-10-09 15:38 ` Alvin Šipraga
0 siblings, 0 replies; 4+ messages in thread
From: Alvin Šipraga @ 2026-10-09 15:38 UTC (permalink / raw)
To: phucduc.bui
Cc: Mark Brown, Oder Chiou, Bard Liao, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel
On Fri, Oct 09, 2026 at 06:22:04PM +0700, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> devm_gpiod_get_optional() may return an error pointer, including
> -EPROBE_DEFER, but rt5659_i2c_probe() does not handle these errors
> for the ldo1-en GPIO and does not check for errors for the reset GPIO.
>
> Check the return values and propagate GPIO lookup errors.
>
> Fixes: d3cb2de2479b ("ASoC: rt5659: add rt5659 codec driver")
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>
> ---
> sound/soc/codecs/rt5659.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling
2026-10-09 11:22 [PATCH 1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling phucduc.bui
2026-10-09 11:22 ` [PATCH 2/2] ASoC: codecs: rt5659: propagate GPIO errors phucduc.bui
@ 2026-10-09 15:37 ` Alvin Šipraga
1 sibling, 0 replies; 4+ messages in thread
From: Alvin Šipraga @ 2026-10-09 15:37 UTC (permalink / raw)
To: phucduc.bui
Cc: Mark Brown, Oder Chiou, Bard Liao, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel
On Fri, Oct 09, 2026 at 06:22:03PM +0700, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> gpiod_not_found() converts -ENOENT to NULL before
> devm_gpiod_get_optional() returns, so there is no need to handle
> -ENOENT explicitly.
>
> Use dev_err_probe() to simplify error reporting and handle
> -EPROBE_DEFER.
>
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>
> ---
> sound/soc/codecs/rt5645.c | 22 ++++++----------------
> 1 file changed, 6 insertions(+), 16 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-09 15:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-09 11:22 [PATCH 1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling phucduc.bui
2026-10-09 11:22 ` [PATCH 2/2] ASoC: codecs: rt5659: propagate GPIO errors phucduc.bui
2026-10-09 15:38 ` Alvin Šipraga
2026-10-09 15:37 ` [PATCH 1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling Alvin Šipraga
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®