ASoC: codecs: rt5645: Simplify optional GPIO error handling

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>
Link: https://patch.msgid.link/20261009112204.33199-1-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
bui duc phuc 2026-10-09 18:22:03 +07:00 committed by Mark Brown
parent 0688699b36
commit 50fb7f7fc7
No known key found for this signature in database
GPG Key ID: 2FEF73B0B3D03889

View File

@ -4045,26 +4045,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];