ASoC: rt5645: Use devm_gpiod_get_optional for hp-detect

Since hp-detect is optional, use devm_gpiod_get_optional instead.
In additional, it should return error if devm_gpiod_get_optional fails.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Axel Lin 2015-06-12 17:19:15 +08:00 committed by Mark Brown
parent 48edaa4b4f
commit 25c8888ad6

View file

@ -3268,11 +3268,12 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
else
rt5645_parse_dt(rt5645, &i2c->dev);
rt5645->gpiod_hp_det = devm_gpiod_get(&i2c->dev, "hp-detect", GPIOD_IN);
rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect",
GPIOD_IN);
if (IS_ERR(rt5645->gpiod_hp_det)) {
rt5645->gpiod_hp_det = NULL;
dev_err(&i2c->dev, "failed to initialize gpiod\n");
return PTR_ERR(rt5645->gpiod_hp_det);
}
rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5645_regmap);