diff mbox

ASoC: rt5645: Use devm_gpiod_get_optional for hp-detect

Message ID 1434100755.7458.1.camel@ingics.com (mailing list archive)
State New, archived
Headers show

Commit Message

Axel Lin June 12, 2015, 9:19 a.m. UTC
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>
---
 sound/soc/codecs/rt5645.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Mark Brown June 12, 2015, 10:54 a.m. UTC | #1
On Fri, Jun 12, 2015 at 05:19:15PM +0800, Axel Lin wrote:
> 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.
diff mbox

Patch

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 7d04b1a..04d9ff8 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -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);