Skip to content

Commit 3622d3e

Browse files
committed
[media] ov2640: print error if devm_*_optional*() fails
devm_gpiod_get_optional() can return -ENOSYS if GPIOLIB is disabled, causing probe to fail. Warn the user if this happens. Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent 9eb9db3 commit 3622d3e

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

drivers/media/i2c/ov2640.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,17 +765,17 @@ static int ov2640_s_register(struct v4l2_subdev *sd,
765765

766766
static int ov2640_s_power(struct v4l2_subdev *sd, int on)
767767
{
768+
#ifdef CONFIG_GPIOLIB
768769
struct i2c_client *client = v4l2_get_subdevdata(sd);
769770
struct ov2640_priv *priv = to_ov2640(client);
770771

771-
#ifdef CONFIG_GPIOLIB
772772
if (priv->pwdn_gpio)
773773
gpiod_direction_output(priv->pwdn_gpio, !on);
774774
if (on && priv->resetb_gpio) {
775775
/* Active the resetb pin to perform a reset pulse */
776776
gpiod_direction_output(priv->resetb_gpio, 1);
777777
usleep_range(3000, 5000);
778-
gpiod_direction_output(priv->resetb_gpio, 0);
778+
gpiod_set_value(priv->resetb_gpio, 0);
779779
}
780780
#endif
781781
return 0;
@@ -1048,21 +1048,35 @@ static const struct v4l2_subdev_ops ov2640_subdev_ops = {
10481048
static int ov2640_probe_dt(struct i2c_client *client,
10491049
struct ov2640_priv *priv)
10501050
{
1051+
int ret;
1052+
10511053
/* Request the reset GPIO deasserted */
10521054
priv->resetb_gpio = devm_gpiod_get_optional(&client->dev, "resetb",
10531055
GPIOD_OUT_LOW);
1056+
10541057
if (!priv->resetb_gpio)
10551058
dev_dbg(&client->dev, "resetb gpio is not assigned!\n");
1056-
else if (IS_ERR(priv->resetb_gpio))
1057-
return PTR_ERR(priv->resetb_gpio);
1059+
1060+
ret = PTR_ERR_OR_ZERO(priv->resetb_gpio);
1061+
if (ret && ret != -ENOSYS) {
1062+
dev_dbg(&client->dev,
1063+
"Error %d while getting resetb gpio\n", ret);
1064+
return ret;
1065+
}
10581066

10591067
/* Request the power down GPIO asserted */
10601068
priv->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "pwdn",
10611069
GPIOD_OUT_HIGH);
1070+
10621071
if (!priv->pwdn_gpio)
10631072
dev_dbg(&client->dev, "pwdn gpio is not assigned!\n");
1064-
else if (IS_ERR(priv->pwdn_gpio))
1065-
return PTR_ERR(priv->pwdn_gpio);
1073+
1074+
ret = PTR_ERR_OR_ZERO(priv->pwdn_gpio);
1075+
if (ret && ret != -ENOSYS) {
1076+
dev_dbg(&client->dev,
1077+
"Error %d while getting pwdn gpio\n", ret);
1078+
return ret;
1079+
}
10661080

10671081
return 0;
10681082
}

0 commit comments

Comments
 (0)