spi: npcm: fix u32 csgpio being checked for less than zero
authorColin Ian King <colin.king@canonical.com>
Wed, 14 Nov 2018 21:42:46 +0000 (21:42 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 14 Nov 2018 22:02:33 +0000 (14:02 -0800)
The u32 variable csgpio is being checked for an error return
from the call to of_get_named_gpio, however, since this is unsigned
this comparison will always be false. Fix this by making csgpio an
int and fix up the %u format specifiers to %d accordingly.

Detected by CoverityScan, CID#1475476 ("Unsigned compared against 0")

Fixes: 2a22f1b30cee ("spi: npcm: add NPCM PSPI controller driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-npcm-pspi.c

index 51777515c83f4bbff83283ab0690b1355998d0a7..6dae91091143591e2bd251055ba17f4a14c8a3ef 100644 (file)
@@ -329,7 +329,7 @@ static int npcm_pspi_probe(struct platform_device *pdev)
        unsigned long clk_hz;
        struct device_node *np = pdev->dev.of_node;
        int num_cs, i;
-       u32 csgpio;
+       int csgpio;
        int irq;
        int ret;
 
@@ -417,12 +417,12 @@ static int npcm_pspi_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev, "failed to get csgpio#%u\n", i);
                        goto out_disable_clk;
                }
-               dev_dbg(&pdev->dev, "csgpio#%u = %u\n", i, csgpio);
+               dev_dbg(&pdev->dev, "csgpio#%u = %d\n", i, csgpio);
                ret = devm_gpio_request_one(&pdev->dev, csgpio,
                                            GPIOF_OUT_INIT_HIGH, DRIVER_NAME);
                if (ret < 0) {
                        dev_err(&pdev->dev,
-                               "failed to configure csgpio#%u %u\n"
+                               "failed to configure csgpio#%u %d\n"
                                , i, csgpio);
                        goto out_disable_clk;
                }