From 059e614bdd4b61ee2dca315f3525430df10edcf6 Mon Sep 17 00:00:00 2001 From: Xinhuang Li Date: Tue, 21 Nov 2017 16:25:55 +0800 Subject: [PATCH] ASoC: codecs: tc358749x: compatible with different power pin definitions some boards do not define the power pin such as power18/power33 for tc358749x Change-Id: I36914dc005e465c290f71df2483d1969f6d101ef Signed-off-by: Xinhuang Li --- sound/soc/codecs/tc358749x.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/tc358749x.c b/sound/soc/codecs/tc358749x.c index 8698fd9d54fe..6c0252e61f31 100644 --- a/sound/soc/codecs/tc358749x.c +++ b/sound/soc/codecs/tc358749x.c @@ -189,11 +189,6 @@ static int tc358749x_parse_dts(struct i2c_client *i2c, tc358749x->gpio_power18 = devm_gpiod_get_optional(dev, "power18", GPIOD_OUT_LOW); - if (IS_ERR(tc358749x->gpio_power18)) { - ret = PTR_ERR(tc358749x->gpio_power18); - dev_err(&i2c->dev, "Unable to claim gpio \"power18\".\n"); - return ret; - } tc358749x->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); @@ -205,11 +200,6 @@ static int tc358749x_parse_dts(struct i2c_client *i2c, tc358749x->gpio_power33 = devm_gpiod_get_optional(dev, "power33", GPIOD_OUT_LOW); - if (IS_ERR(tc358749x->gpio_power33)) { - ret = PTR_ERR(tc358749x->gpio_power33); - dev_err(&i2c->dev, "Unable to claim gpio \"power33\".\n"); - return ret; - } tc358749x->gpio_int = devm_gpiod_get_optional(dev, "int", GPIOD_OUT_LOW); @@ -232,7 +222,6 @@ static int tc358749x_parse_dts(struct i2c_client *i2c, if (IS_ERR(tc358749x->gpio_csi_ctl)) { ret = PTR_ERR(tc358749x->gpio_csi_ctl); dev_err(&i2c->dev, "Unable to claim gpio \"csi-ctl\".\n"); - return ret; } tc358749x->gpio_stanby = devm_gpiod_get_optional(dev, "stanby", @@ -243,8 +232,20 @@ static int tc358749x_parse_dts(struct i2c_client *i2c, return ret; } - gpiod_direction_output(tc358749x->gpio_power18, 1); - gpiod_direction_output(tc358749x->gpio_power33, 1); + if (IS_ERR(tc358749x->gpio_power18)) { + ret = PTR_ERR(tc358749x->gpio_power18); + dev_err(&i2c->dev, "Unable to claim gpio \"power18\".\n"); + } else { + gpiod_direction_output(tc358749x->gpio_power18, 1); + } + + if (IS_ERR(tc358749x->gpio_power33)) { + ret = PTR_ERR(tc358749x->gpio_power33); + dev_err(&i2c->dev, "Unable to claim gpio \"power33\".\n"); + } else { + gpiod_direction_output(tc358749x->gpio_power33, 1); + } + gpiod_direction_output(tc358749x->gpio_power, 1); gpiod_direction_output(tc358749x->gpio_stanby, 1); gpiod_direction_output(tc358749x->gpio_reset, 1);