Message ID | c41f5795-4b53-48d5-5a46-b2a579f3b931@sakamocchi.jp (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>> if (IS_ERR(rt5645->gpiod_hp_det)) { >> - dev_err(&i2c->dev, "failed to initialize gpiod\n"); >> - return PTR_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; >> } >> >> for (i = 0; i < ARRAY_SIZE(rt5645->supplies); i++) > > (sound/soc/codecs/rt5645.c) > rt5645_i2c_probe() > (drivers/gpio/devres.c) > ->devm_gpiod_get_optional() > ->devm_gpiod_get_index_optional() > > As long as seeing current implementation of > 'devm_gpiod_get_index_optional()', this function never returns ENOENT. > In this case, it returns NULL. > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/gpio/devres.c#n185 > Thanks for pointing this out, I didn't see it and naively thought that everyone followed the same conventions. Oh well. I'll respin a v2.
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 1ac96ef..a588454 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3656,10 +3656,15 @@ 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_err(&i2c->dev, "failed to initialize gpiod\n"); - return PTR_ERR(rt5645->gpiod_hp_det); + if (rt5645->gpiod_hp_det && 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. -ENOENT is never returns + * according to implementation of devm_gpiod_get_optional(). + */ + return ret; }