diff mbox

media: i2c/adp1653: fix check of devm_gpiod_get() error code

Message ID 1457375972-9923-1-git-send-email-vz@mleia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vladimir Zapolskiy March 7, 2016, 6:39 p.m. UTC
The devm_gpiod_get() function returns either a valid pointer to
struct gpio_desc or ERR_PTR() error value, check for NULL is bogus.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
 drivers/media/i2c/adp1653.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Sakari Ailus March 9, 2016, 9:44 a.m. UTC | #1
Hi Vladimir,

On Mon, Mar 07, 2016 at 08:39:32PM +0200, Vladimir Zapolskiy wrote:
> The devm_gpiod_get() function returns either a valid pointer to
> struct gpio_desc or ERR_PTR() error value, check for NULL is bogus.
> 
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>

Thanks! Applied to my fixes branch.
diff mbox

Patch

diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index fb7ed73..9e1731c 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -466,9 +466,9 @@  static int adp1653_of_init(struct i2c_client *client,
 	of_node_put(child);
 
 	pd->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
-	if (!pd->enable_gpio) {
+	if (IS_ERR(pd->enable_gpio)) {
 		dev_err(&client->dev, "Error getting GPIO\n");
-		return -EINVAL;
+		return PTR_ERR(pd->enable_gpio);
 	}
 
 	return 0;