Commit 2660a22b authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] mt9p031: Use gpio_is_valid()

Replace the manual validity checks for the reset GPIO with the
gpio_is_valid() function.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: default avatarLad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent bbcc9fa0
...@@ -272,7 +272,7 @@ static inline int mt9p031_pll_disable(struct mt9p031 *mt9p031) ...@@ -272,7 +272,7 @@ static inline int mt9p031_pll_disable(struct mt9p031 *mt9p031)
static int mt9p031_power_on(struct mt9p031 *mt9p031) static int mt9p031_power_on(struct mt9p031 *mt9p031)
{ {
/* Ensure RESET_BAR is low */ /* Ensure RESET_BAR is low */
if (mt9p031->reset != -1) { if (gpio_is_valid(mt9p031->reset)) {
gpio_set_value(mt9p031->reset, 0); gpio_set_value(mt9p031->reset, 0);
usleep_range(1000, 2000); usleep_range(1000, 2000);
} }
...@@ -287,7 +287,7 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) ...@@ -287,7 +287,7 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031)
clk_prepare_enable(mt9p031->clk); clk_prepare_enable(mt9p031->clk);
/* Now RESET_BAR must be high */ /* Now RESET_BAR must be high */
if (mt9p031->reset != -1) { if (gpio_is_valid(mt9p031->reset)) {
gpio_set_value(mt9p031->reset, 1); gpio_set_value(mt9p031->reset, 1);
usleep_range(1000, 2000); usleep_range(1000, 2000);
} }
...@@ -297,7 +297,7 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) ...@@ -297,7 +297,7 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031)
static void mt9p031_power_off(struct mt9p031 *mt9p031) static void mt9p031_power_off(struct mt9p031 *mt9p031)
{ {
if (mt9p031->reset != -1) { if (gpio_is_valid(mt9p031->reset)) {
gpio_set_value(mt9p031->reset, 0); gpio_set_value(mt9p031->reset, 0);
usleep_range(1000, 2000); usleep_range(1000, 2000);
} }
...@@ -1031,7 +1031,7 @@ static int mt9p031_probe(struct i2c_client *client, ...@@ -1031,7 +1031,7 @@ static int mt9p031_probe(struct i2c_client *client,
mt9p031->format.field = V4L2_FIELD_NONE; mt9p031->format.field = V4L2_FIELD_NONE;
mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB; mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB;
if (pdata->reset != -1) { if (gpio_is_valid(pdata->reset)) {
ret = devm_gpio_request_one(&client->dev, pdata->reset, ret = devm_gpio_request_one(&client->dev, pdata->reset,
GPIOF_OUT_INIT_LOW, "mt9p031_rst"); GPIOF_OUT_INIT_LOW, "mt9p031_rst");
if (ret < 0) if (ret < 0)
......
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