driver: media: fix ov5693 gpio warnings
Frank Chen [Fri, 12 Feb 2016 18:57:23 +0000 (10:57 -0800)]
Use gpio_set_value_cansleep() function when gpio driver
supports it.

Bug 1729926

Change-Id: Ib6e363c6587ca9439eeda3a45f8c91b8c18a917c
Signed-off-by: Frank Chen <frankc@nvidia.com>
Reviewed-on: http://git-master/r/1011425
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Igor Tryndin <itryndin@nvidia.com>
Reviewed-by: Jihoon Bang <jbang@nvidia.com>
Reviewed-by: Hayden Du <haydend@nvidia.com>

drivers/media/i2c/ov5693.c

index 7d219d7..c0bab21 100644 (file)
@@ -272,8 +272,12 @@ static void ov5693_gpio_set(struct ov5693 *priv,
 {
        if (priv->pdata->use_cam_gpio)
                cam_gpio_ctrl(priv->i2c_client, gpio, val, 1);
-       else
-               gpio_set_value(gpio, val);
+       else {
+               if (gpio_cansleep(gpio))
+                       gpio_set_value_cansleep(gpio, val);
+               else
+                       gpio_set_value(gpio, val);
+       }
 }
 
 static int ov5693_power_on(struct camera_common_data *s_data)
@@ -315,7 +319,7 @@ static int ov5693_power_on(struct camera_common_data *s_data)
        usleep_range(2000, 2010);
 
        if (pw->reset_gpio)
-               gpio_set_value(pw->reset_gpio, 1);
+               ov5693_gpio_set(priv, pw->reset_gpio, 1);
 
        /* datasheet fig 2-9: t3 */
        usleep_range(1350, 1360);
@@ -356,7 +360,7 @@ static int ov5693_power_off(struct camera_common_data *s_data)
                ov5693_gpio_set(priv, pw->pwdn_gpio, 0);
        usleep_range(1, 2);
        if (pw->reset_gpio)
-               gpio_set_value(pw->reset_gpio, 0);
+               ov5693_gpio_set(priv, pw->reset_gpio, 0);
 
        /* datasheet 2.9: reset requires ~2ms settling time*/
        usleep_range(2000, 2010);
@@ -387,8 +391,10 @@ static int ov5693_power_put(struct ov5693 *priv)
 
        if (priv->pdata->use_cam_gpio)
                cam_gpio_deregister(priv->i2c_client, pw->pwdn_gpio);
-       else
+       else {
                gpio_free(pw->pwdn_gpio);
+               gpio_free(pw->reset_gpio);
+       }
 
        return 0;
 }
@@ -441,8 +447,11 @@ static int ov5693_power_get(struct ov5693 *priv)
                        dev_err(&priv->i2c_client->dev,
                                "%s ERR can't register cam gpio %u!\n",
                                 __func__, pw->pwdn_gpio);
-       } else
+       } else {
                gpio_request(pw->pwdn_gpio, "cam_pwdn_gpio");
+               gpio_request(pw->reset_gpio, "cam_reset_gpio");
+       }
+
 
        pw->state = SWITCH_OFF;
        return err;