All of lore.kernel.org
 help / color / mirror / Atom feed
From: jacopo mondi <jacopo@jmondi.org>
To: Phil Edworthy <phil.edworthy@renesas.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] pinctrl: rzn1: Fix check for used MDIO bus
Date: Mon, 15 Oct 2018 09:53:31 +0200	[thread overview]
Message-ID: <20181015075331.GC21294@w540> (raw)
In-Reply-To: <20181012104036.28829-1-phil.edworthy@renesas.com>

[-- Attachment #1: Type: text/plain, Size: 1776 bytes --]

Hi Phil,

On Fri, Oct 12, 2018 at 11:40:36AM +0100, Phil Edworthy wrote:
> This fixes the check for unused mdio bus setting and the following static
> checker warning:
>  drivers/pinctrl/pinctrl-rzn1.c:198 rzn1_pinctrl_mdio_select()
>  warn: always true condition '(ipctl->mdio_func[mdio] >= 0) => (0-u32max >= 0)'
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> ---
>  drivers/pinctrl/pinctrl-rzn1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-rzn1.c b/drivers/pinctrl/pinctrl-rzn1.c
> index ce05e3a00be2..f688f3a29dfd 100644
> --- a/drivers/pinctrl/pinctrl-rzn1.c
> +++ b/drivers/pinctrl/pinctrl-rzn1.c
> @@ -195,7 +195,7 @@ static void rzn1_hw_set_lock(struct rzn1_pinctrl *ipctl, u8 lock, u8 value)
>  static void rzn1_pinctrl_mdio_select(struct rzn1_pinctrl *ipctl, int mdio,
>  				     u32 func)
>  {
> -	if (ipctl->mdio_func[mdio] >= 0 && ipctl->mdio_func[mdio] != func)
> +	if (ipctl->mdio_func[mdio] != -1 && ipctl->mdio_func[mdio] != func)
>  		dev_warn(ipctl->dev, "conflicting setting for mdio%d!\n", mdio);
>  	ipctl->mdio_func[mdio] = func;
>

MY understanding here is that the static checker complains because you
are comparing a variable of unsigned type to negative values, and
indeed you are treating mdio_func as signed in the driver code.

mdio_func is defined as:

struct rzn1_pinctrl {
        ...
	u32 mdio_func[2];
        ...
};

Then in probe function mdio_func gets intialized as:

	ipctl->mdio_func[0] = -1;
	ipctl->mdio_func[1] = -1;

I think you could safely make mdio_func integers, or either define an
INVALID value ( > 0), intialize them it that value and check against it for
validity.

Thanks
   j


> --
> 2.17.1
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2018-10-15 15:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12 10:40 [PATCH] pinctrl: rzn1: Fix check for used MDIO bus Phil Edworthy
2018-10-15  7:53 ` jacopo mondi [this message]
2018-10-15 12:02   ` Phil Edworthy
  -- strict thread matches above, loose matches on Subject: below --
2018-11-19 16:18 Phil Edworthy
2018-11-22 14:08 ` Simon Horman
2018-11-22 14:36   ` Phil Edworthy
2018-11-23  9:40 ` Geert Uytterhoeven
2018-11-23 10:01   ` Phil Edworthy
2018-11-23 10:16     ` Geert Uytterhoeven
2018-11-23 11:06       ` Phil Edworthy
2018-11-23 10:54 Phil Edworthy
2018-11-23 12:04 ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181015075331.GC21294@w540 \
    --to=jacopo@jmondi.org \
    --cc=geert@linux-m68k.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=phil.edworthy@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.