linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: rzn1: remove unnecessary unsigned integer comparison
@ 2018-10-11 20:40 Gustavo A. R. Silva
  2018-10-12  9:17 ` Linus Walleij
  2021-03-24  9:49 ` Geert Uytterhoeven
  0 siblings, 2 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-11 20:40 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, linux-kernel, Gustavo A. R. Silva

There is no need to compare ipctl->mdio_func[mdio] with => 0, because
such comparison is always true. Notice that *mdio_func* is of type
u32 (32 bits, unsigned).

Fix this by removing such comparison.

Addresses-Coverity-ID: 1474166 ("Unsigned compared against 0")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.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 ce05e3a..b5650d8 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] != func)
 		dev_warn(ipctl->dev, "conflicting setting for mdio%d!\n", mdio);
 	ipctl->mdio_func[mdio] = func;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: rzn1: remove unnecessary unsigned integer comparison
  2018-10-11 20:40 [PATCH] pinctrl: rzn1: remove unnecessary unsigned integer comparison Gustavo A. R. Silva
@ 2018-10-12  9:17 ` Linus Walleij
  2018-10-12  9:27   ` Gustavo A. R. Silva
  2021-03-24  9:49 ` Geert Uytterhoeven
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2018-10-12  9:17 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Geert Uytterhoeven
  Cc: open list:GPIO SUBSYSTEM, linux-kernel

Sorry for top-posting, Geert is maintainer for this driver.

Yours,
Linus Walleij

On Thu, Oct 11, 2018 at 10:40 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
>
> There is no need to compare ipctl->mdio_func[mdio] with => 0, because
> such comparison is always true. Notice that *mdio_func* is of type
> u32 (32 bits, unsigned).
>
> Fix this by removing such comparison.
>
> Addresses-Coverity-ID: 1474166 ("Unsigned compared against 0")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.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 ce05e3a..b5650d8 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] != func)
>                 dev_warn(ipctl->dev, "conflicting setting for mdio%d!\n", mdio);
>         ipctl->mdio_func[mdio] = func;
>
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: rzn1: remove unnecessary unsigned integer comparison
  2018-10-12  9:17 ` Linus Walleij
@ 2018-10-12  9:27   ` Gustavo A. R. Silva
  2018-10-15 14:21     ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-12  9:27 UTC (permalink / raw)
  To: Linus Walleij, Geert Uytterhoeven; +Cc: open list:GPIO SUBSYSTEM, linux-kernel



On 10/12/18 11:17 AM, Linus Walleij wrote:
> Sorry for top-posting, Geert is maintainer for this driver.
> 

Oh okay.

This is what I get when I run the get_maintainer scripts on the rzn1 driver:

$ scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback drivers/pinctrl/pinctrl-rzn1.c
Linus Walleij <linus.walleij@linaro.org> (maintainer:PIN CONTROL SUBSYSTEM)
linux-gpio@vger.kernel.org (open list:PIN CONTROL SUBSYSTEM)
linux-kernel@vger.kernel.org (open list)

Thanks
--
Gustavo

> Yours,
> Linus Walleij
> 
> On Thu, Oct 11, 2018 at 10:40 PM Gustavo A. R. Silva
> <gustavo@embeddedor.com> wrote:
>>
>> There is no need to compare ipctl->mdio_func[mdio] with => 0, because
>> such comparison is always true. Notice that *mdio_func* is of type
>> u32 (32 bits, unsigned).
>>
>> Fix this by removing such comparison.
>>
>> Addresses-Coverity-ID: 1474166 ("Unsigned compared against 0")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.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 ce05e3a..b5650d8 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] != func)
>>                 dev_warn(ipctl->dev, "conflicting setting for mdio%d!\n", mdio);
>>         ipctl->mdio_func[mdio] = func;
>>
>> --
>> 2.7.4
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: rzn1: remove unnecessary unsigned integer comparison
  2018-10-12  9:27   ` Gustavo A. R. Silva
@ 2018-10-15 14:21     ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2018-10-15 14:21 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Geert Uytterhoeven
  Cc: open list:GPIO SUBSYSTEM, linux-kernel

On Fri, Oct 12, 2018 at 11:28 AM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> On 10/12/18 11:17 AM, Linus Walleij wrote:
> > Sorry for top-posting, Geert is maintainer for this driver.
> >
>
> Oh okay.
>
> This is what I get when I run the get_maintainer scripts on the rzn1 driver:
>
> $ scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback drivers/pinctrl/pinctrl-rzn1.c
> Linus Walleij <linus.walleij@linaro.org> (maintainer:PIN CONTROL SUBSYSTEM)
> linux-gpio@vger.kernel.org (open list:PIN CONTROL SUBSYSTEM)
> linux-kernel@vger.kernel.org (open list)

Hm I bet it needs a MAINTAINERS update.
Geert can you assume maintainership?

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: rzn1: remove unnecessary unsigned integer comparison
  2018-10-11 20:40 [PATCH] pinctrl: rzn1: remove unnecessary unsigned integer comparison Gustavo A. R. Silva
  2018-10-12  9:17 ` Linus Walleij
@ 2021-03-24  9:49 ` Geert Uytterhoeven
  1 sibling, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2021-03-24  9:49 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Linus Walleij, open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

Hi Gustavo,

On Thu, Oct 11, 2018 at 10:42 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> There is no need to compare ipctl->mdio_func[mdio] with => 0, because
> such comparison is always true. Notice that *mdio_func* is of type
> u32 (32 bits, unsigned).
>
> Fix this by removing such comparison.
>
> Addresses-Coverity-ID: 1474166 ("Unsigned compared against 0")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Thanks for your patch, which I somehow missed to review.
Sorry for that.

> --- 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] != func)

Note that mdio_func is initialized to -1, hence the check.
But the check indeed didn't work this way, so mdio_func was changed
later to int in commit 8deaaa46d2de91e3 ("pinctrl: rzn1: Fix check for
used MDIO bus").

>                 dev_warn(ipctl->dev, "conflicting setting for mdio%d!\n", mdio);
>         ipctl->mdio_func[mdio] = func;

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-24  9:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-11 20:40 [PATCH] pinctrl: rzn1: remove unnecessary unsigned integer comparison Gustavo A. R. Silva
2018-10-12  9:17 ` Linus Walleij
2018-10-12  9:27   ` Gustavo A. R. Silva
2018-10-15 14:21     ` Linus Walleij
2021-03-24  9:49 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).