diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-04-19 08:58:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-04-25 06:08:21 -0400 |
commit | 3622d3e77ecef090b5111e3c5423313f11711dfa (patch) | |
tree | 766d16bfdf2a61b193bd381bec7a2aae6cecbc4c | |
parent | 9eb9db3a0f92b75ec710066202e0b2accb45afa9 (diff) |
[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>
-rw-r--r-- | drivers/media/i2c/ov2640.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c index 4a2ae24f8722..e6d0c1f64f0b 100644 --- a/drivers/media/i2c/ov2640.c +++ b/drivers/media/i2c/ov2640.c | |||
@@ -765,17 +765,17 @@ static int ov2640_s_register(struct v4l2_subdev *sd, | |||
765 | 765 | ||
766 | static int ov2640_s_power(struct v4l2_subdev *sd, int on) | 766 | static int ov2640_s_power(struct v4l2_subdev *sd, int on) |
767 | { | 767 | { |
768 | #ifdef CONFIG_GPIOLIB | ||
768 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 769 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
769 | struct ov2640_priv *priv = to_ov2640(client); | 770 | struct ov2640_priv *priv = to_ov2640(client); |
770 | 771 | ||
771 | #ifdef CONFIG_GPIOLIB | ||
772 | if (priv->pwdn_gpio) | 772 | if (priv->pwdn_gpio) |
773 | gpiod_direction_output(priv->pwdn_gpio, !on); | 773 | gpiod_direction_output(priv->pwdn_gpio, !on); |
774 | if (on && priv->resetb_gpio) { | 774 | if (on && priv->resetb_gpio) { |
775 | /* Active the resetb pin to perform a reset pulse */ | 775 | /* Active the resetb pin to perform a reset pulse */ |
776 | gpiod_direction_output(priv->resetb_gpio, 1); | 776 | gpiod_direction_output(priv->resetb_gpio, 1); |
777 | usleep_range(3000, 5000); | 777 | usleep_range(3000, 5000); |
778 | gpiod_direction_output(priv->resetb_gpio, 0); | 778 | gpiod_set_value(priv->resetb_gpio, 0); |
779 | } | 779 | } |
780 | #endif | 780 | #endif |
781 | return 0; | 781 | return 0; |
@@ -1048,21 +1048,35 @@ static const struct v4l2_subdev_ops ov2640_subdev_ops = { | |||
1048 | static int ov2640_probe_dt(struct i2c_client *client, | 1048 | static int ov2640_probe_dt(struct i2c_client *client, |
1049 | struct ov2640_priv *priv) | 1049 | struct ov2640_priv *priv) |
1050 | { | 1050 | { |
1051 | int ret; | ||
1052 | |||
1051 | /* Request the reset GPIO deasserted */ | 1053 | /* Request the reset GPIO deasserted */ |
1052 | priv->resetb_gpio = devm_gpiod_get_optional(&client->dev, "resetb", | 1054 | priv->resetb_gpio = devm_gpiod_get_optional(&client->dev, "resetb", |
1053 | GPIOD_OUT_LOW); | 1055 | GPIOD_OUT_LOW); |
1056 | |||
1054 | if (!priv->resetb_gpio) | 1057 | if (!priv->resetb_gpio) |
1055 | dev_dbg(&client->dev, "resetb gpio is not assigned!\n"); | 1058 | dev_dbg(&client->dev, "resetb gpio is not assigned!\n"); |
1056 | else if (IS_ERR(priv->resetb_gpio)) | 1059 | |
1057 | return PTR_ERR(priv->resetb_gpio); | 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 | } | ||
1058 | 1066 | ||
1059 | /* Request the power down GPIO asserted */ | 1067 | /* Request the power down GPIO asserted */ |
1060 | priv->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "pwdn", | 1068 | priv->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "pwdn", |
1061 | GPIOD_OUT_HIGH); | 1069 | GPIOD_OUT_HIGH); |
1070 | |||
1062 | if (!priv->pwdn_gpio) | 1071 | if (!priv->pwdn_gpio) |
1063 | dev_dbg(&client->dev, "pwdn gpio is not assigned!\n"); | 1072 | dev_dbg(&client->dev, "pwdn gpio is not assigned!\n"); |
1064 | else if (IS_ERR(priv->pwdn_gpio)) | 1073 | |
1065 | return PTR_ERR(priv->pwdn_gpio); | 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 | } | ||
1066 | 1080 | ||
1067 | return 0; | 1081 | return 0; |
1068 | } | 1082 | } |