ASoC: codecs: rt5645: Simplify optional GPIO error handling
Subsystems (3)
PATCH 1/2 ASoC: codecs: rt5645: Simplify optional GPIO error handling
From: bui duc phuc <[email protected]>
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.
--- sound/soc/codecs/rt5645.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
sound/soc/codecs/rt5645.c +6 -16
@@ -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];
Signature · 1 line
2.43.0
PATCH 2/2 ASoC: codecs: rt5659: propagate GPIO errors
From: bui duc phuc <[email protected]>
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.
--- sound/soc/codecs/rt5659.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5659.c +5 -1
@@ -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 );
Signature · 1 line
2.43.0
Quoted 10 lines · On Fri, Oct 09, 2026 at 06:22:03PM +0700, [email protected] wrote:
From: bui duc phuc <[email protected]>
gpiod_not_found()converts-ENOENTto NULL beforedevm_gpiod_get_optional()returns, so there is no need to handle-ENOENTexplicitly.Use
dev_err_probe()to simplify error reporting and handle -EPROBE_DEFER.Signed-off-by bui duc phuc <[email protected]>
Quoted 3 lines
--- sound/soc/codecs/rt5645.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
Re: [PATCH 2/2] ASoC: codecs: rt5659: propagate GPIO errors
In reply to [email protected]Quoted 10 lines · On Fri, Oct 09, 2026 at 06:22:04PM +0700, [email protected] wrote:
From: bui duc phuc <[email protected]>
devm_gpiod_get_optional()may return an error pointer, including -EPROBE_DEFER, butrt5659_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 <[email protected]>
Quoted 3 lines
--- sound/soc/codecs/rt5659.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Mark Brown
maintainerQuoted 1 line · On Fri, 09 Oct 2026 18:22:03 +0700, [email protected] wrote:
ASoC: codecs: rt5645: Simplify optional GPIO error handling
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[1/2] ASoC: codecs: rt5645: Simplify optional GPIO error handling
https://git.kernel.org/broonie/misc/c/50fb7f7fc7e4 [2/2] ASoC: codecs: rt5659: propagate GPIO errors https://git.kernel.org/broonie/misc/c/c1e321bd5ce6
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark