Commit b36ae853 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Mauro Carvalho Chehab

[media] media: radio-si4713: improve usage of gpiod API

Since 39b2bbe3 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.
Simplify accordingly.

Moreover use the _optional variant which has tighter error checking, but
is simpler to use which allows further simplification.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 4a203349
...@@ -383,7 +383,7 @@ static int si4713_powerup(struct si4713_device *sdev) ...@@ -383,7 +383,7 @@ static int si4713_powerup(struct si4713_device *sdev)
} }
} }
if (!IS_ERR(sdev->gpio_reset)) { if (sdev->gpio_reset) {
udelay(50); udelay(50);
gpiod_set_value(sdev->gpio_reset, 1); gpiod_set_value(sdev->gpio_reset, 1);
} }
...@@ -407,7 +407,6 @@ static int si4713_powerup(struct si4713_device *sdev) ...@@ -407,7 +407,6 @@ static int si4713_powerup(struct si4713_device *sdev)
SI4713_STC_INT | SI4713_CTS); SI4713_STC_INT | SI4713_CTS);
return err; return err;
} }
if (!IS_ERR(sdev->gpio_reset))
gpiod_set_value(sdev->gpio_reset, 0); gpiod_set_value(sdev->gpio_reset, 0);
...@@ -447,7 +446,7 @@ static int si4713_powerdown(struct si4713_device *sdev) ...@@ -447,7 +446,7 @@ static int si4713_powerdown(struct si4713_device *sdev)
v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n", v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n",
resp[0]); resp[0]);
v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n"); v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n");
if (!IS_ERR(sdev->gpio_reset)) if (sdev->gpio_reset)
gpiod_set_value(sdev->gpio_reset, 0); gpiod_set_value(sdev->gpio_reset, 0);
if (sdev->vdd) { if (sdev->vdd) {
...@@ -1460,14 +1459,9 @@ static int si4713_probe(struct i2c_client *client, ...@@ -1460,14 +1459,9 @@ static int si4713_probe(struct i2c_client *client,
goto exit; goto exit;
} }
sdev->gpio_reset = devm_gpiod_get(&client->dev, "reset"); sdev->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset",
if (!IS_ERR(sdev->gpio_reset)) { GPIOD_OUT_LOW);
gpiod_direction_output(sdev->gpio_reset, 0); if (IS_ERR(sdev->gpio_reset)) {
} else if (PTR_ERR(sdev->gpio_reset) == -ENOENT) {
dev_dbg(&client->dev, "No reset GPIO assigned\n");
} else if (PTR_ERR(sdev->gpio_reset) == -ENOSYS) {
dev_dbg(&client->dev, "No reset GPIO support\n");
} else {
rval = PTR_ERR(sdev->gpio_reset); rval = PTR_ERR(sdev->gpio_reset);
dev_err(&client->dev, "Failed to request gpio: %d\n", rval); dev_err(&client->dev, "Failed to request gpio: %d\n", rval);
goto exit; goto exit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment