HSI: omap_ssi_port: fix handling of_get_named_gpio result
authorAndrzej Hajda <a.hajda@samsung.com>
Mon, 21 Sep 2015 13:33:44 +0000 (15:33 +0200)
committerSebastian Reichel <sre@kernel.org>
Thu, 7 Jan 2016 15:07:54 +0000 (16:07 +0100)
The function can return negative value.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/hsi/controllers/omap_ssi_port.c

index 02e66032ae7360addfd6a64d1c5cc46991743d57..e80a66e20998697de466d6b5fe7bb773d7a77888 100644 (file)
@@ -1147,13 +1147,13 @@ static int __init ssi_port_probe(struct platform_device *pd)
                goto error;
        }
 
-       cawake_gpio = of_get_named_gpio(np, "ti,ssi-cawake-gpio", 0);
-       if (cawake_gpio < 0) {
+       err = of_get_named_gpio(np, "ti,ssi-cawake-gpio", 0);
+       if (err < 0) {
                dev_err(&pd->dev, "DT data is missing cawake gpio (err=%d)\n",
-                       cawake_gpio);
-               err = -ENODEV;
+                       err);
                goto error;
        }
+       cawake_gpio = err;
 
        err = devm_gpio_request_one(&port->device, cawake_gpio, GPIOF_DIR_IN,
                "cawake");