Skip to contentSkip to conversation

ASoC: rt5645: Use devm_gpiod_get_optional for hp-detect

PATCH Applied Axel Lin 2 participants 2 messages Jun 12, 2015

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 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.

---
 sound/soc/codecs/rt5645.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/codecs/rt5645.c +3 -2
index 7d04b1a..04d9ff8 100644
@@ -3255,11 +3255,12 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
 		}
 	}
 
-	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);
Signature · 1 line
2.1.0
maintainer Applied
#1 lore raw
Quoted 2 lines · Axel Lin

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

Applied, thanks.