pinctrl: imx: fix unsigned check if nfuncs with less than or equal zero
authorDong Aisheng <aisheng.dong@nxp.com>
Fri, 27 Apr 2018 19:01:48 +0000 (03:01 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 2 May 2018 12:36:31 +0000 (14:36 +0200)
The unsigned integer nfuncs is being error checked with a value less
or equal to zero; this is always false if of_get_child_count returns a
-ve for an error condition since nfuncs is not signed. Fix this by
making variables nfuncs and i signed integers.

Detected with Coccinelle:
drivers/pinctrl/freescale/pinctrl-imx.c:620:6-12: WARNING: Unsigned
expression compared with zero: nfuncs <= 0

Cc: Linus Walleij <linus.walleij@linaro.org>
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/freescale/pinctrl-imx.c

index 24aaddd760a08d3c562da937fd895d037a2a4b51..77cd3641f17d7b257da4f0fff300e09ceea60092 100644 (file)
@@ -617,7 +617,7 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev,
                nfuncs = 1;
        } else {
                nfuncs = of_get_child_count(np);
-               if (nfuncs <= 0) {
+               if (nfuncs == 0) {
                        dev_err(&pdev->dev, "no functions defined\n");
                        return -EINVAL;
                }