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

[media] media: adv7604: 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 devm_gpiod_get_index_optional instead of
devm_gpiod_get_index with ignoring all errors.
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 48ab45ad
...@@ -538,12 +538,8 @@ static void adv76xx_set_hpd(struct adv76xx_state *state, unsigned int hpd) ...@@ -538,12 +538,8 @@ static void adv76xx_set_hpd(struct adv76xx_state *state, unsigned int hpd)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < state->info->num_dv_ports; ++i) { for (i = 0; i < state->info->num_dv_ports; ++i)
if (IS_ERR(state->hpd_gpio[i]))
continue;
gpiod_set_value_cansleep(state->hpd_gpio[i], hpd & BIT(i)); gpiod_set_value_cansleep(state->hpd_gpio[i], hpd & BIT(i));
}
v4l2_subdev_notify(&state->sd, ADV76XX_HOTPLUG, &hpd); v4l2_subdev_notify(&state->sd, ADV76XX_HOTPLUG, &hpd);
} }
...@@ -2729,12 +2725,12 @@ static int adv76xx_probe(struct i2c_client *client, ...@@ -2729,12 +2725,12 @@ static int adv76xx_probe(struct i2c_client *client,
/* Request GPIOs. */ /* Request GPIOs. */
for (i = 0; i < state->info->num_dv_ports; ++i) { for (i = 0; i < state->info->num_dv_ports; ++i) {
state->hpd_gpio[i] = state->hpd_gpio[i] =
devm_gpiod_get_index(&client->dev, "hpd", i); devm_gpiod_get_index_optional(&client->dev, "hpd", i,
GPIOD_OUT_LOW);
if (IS_ERR(state->hpd_gpio[i])) if (IS_ERR(state->hpd_gpio[i]))
continue; return PTR_ERR(state->hpd_gpio[i]);
gpiod_direction_output(state->hpd_gpio[i], 0);
if (state->hpd_gpio[i])
v4l_info(client, "Handling HPD %u GPIO\n", i); v4l_info(client, "Handling HPD %u GPIO\n", i);
} }
......
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