Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] media: adv7604: improve usage of gpiod API

Since 39b2bbe3d715 (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: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Uwe Kleine-König and committed by
Mauro Carvalho Chehab
269bd132 48ab45ad

+6 -10
+6 -10
drivers/media/i2c/adv7604.c
··· 538 538 { 539 539 unsigned int i; 540 540 541 - for (i = 0; i < state->info->num_dv_ports; ++i) { 542 - if (IS_ERR(state->hpd_gpio[i])) 543 - continue; 544 - 541 + for (i = 0; i < state->info->num_dv_ports; ++i) 545 542 gpiod_set_value_cansleep(state->hpd_gpio[i], hpd & BIT(i)); 546 - } 547 543 548 544 v4l2_subdev_notify(&state->sd, ADV76XX_HOTPLUG, &hpd); 549 545 } ··· 2725 2729 /* Request GPIOs. */ 2726 2730 for (i = 0; i < state->info->num_dv_ports; ++i) { 2727 2731 state->hpd_gpio[i] = 2728 - devm_gpiod_get_index(&client->dev, "hpd", i); 2732 + devm_gpiod_get_index_optional(&client->dev, "hpd", i, 2733 + GPIOD_OUT_LOW); 2729 2734 if (IS_ERR(state->hpd_gpio[i])) 2730 - continue; 2735 + return PTR_ERR(state->hpd_gpio[i]); 2731 2736 2732 - gpiod_direction_output(state->hpd_gpio[i], 0); 2733 - 2734 - v4l_info(client, "Handling HPD %u GPIO\n", i); 2737 + if (state->hpd_gpio[i]) 2738 + v4l_info(client, "Handling HPD %u GPIO\n", i); 2735 2739 } 2736 2740 2737 2741 state->timings = cea640x480;