From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>,
Oder Chiou <oder_chiou@realtek.com>,
Bard Liao <bardliao@realtek.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling
Date: Fri, 9 Oct 2026 18:22:03 +0700 [thread overview]
Message-ID: <20261009112204.33199-1-phucduc.bui@gmail.com> (raw)
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
next reply other threads:[~2026-10-09 11:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 11:22 phucduc.bui [this message]
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
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=20261009112204.33199-1-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=bardliao@realtek.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=oder_chiou@realtek.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/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
all inboxes | Powered by JetHome®