linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFC: trf7970a: fix check of clock frequencies, use && instead of ||
@ 2017-04-24 13:36 Colin King
  2017-04-25 13:18 ` Geoff Lansberry
  2017-06-22 22:01 ` Samuel Ortiz
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2017-04-24 13:36 UTC (permalink / raw)
  To: Geoff Lansberry, Samuel Ortiz, linux-wireless
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The "or" condition (clk_freq != TRF7970A_27MHZ_CLOCK_FREQUENCY) ||
(clk_freq != TRF7970A_13MHZ_CLOCK_FREQUE) will always be true because
clk_freq cannot be equal to two different values at the same time. Use
the  && operator instead of || to fix this.

Detected by CoverityScan, CID#1430468 ("Constant expression result")

Fixes: 837eb4d21ecde7 ("NFC: trf7970a: add device tree option for 27MHz clock")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/nfc/trf7970a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 2d1c8ca6e679..00eb6cd2b22f 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -2071,8 +2071,8 @@ static int trf7970a_probe(struct spi_device *spi)
 	}
 
 	of_property_read_u32(np, "clock-frequency", &clk_freq);
-	if ((clk_freq != TRF7970A_27MHZ_CLOCK_FREQUENCY) ||
-		(clk_freq != TRF7970A_13MHZ_CLOCK_FREQUENCY)) {
+	if ((clk_freq != TRF7970A_27MHZ_CLOCK_FREQUENCY) &&
+		(clk_freq != TRF7970A_13MHZ_CLOCK_FREQUENCY)) {
 		dev_err(trf->dev,
 			"clock-frequency (%u Hz) unsupported\n",
 			clk_freq);
-- 
2.11.0

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

* Re: [PATCH] NFC: trf7970a: fix check of clock frequencies, use && instead of ||
  2017-04-24 13:36 [PATCH] NFC: trf7970a: fix check of clock frequencies, use && instead of || Colin King
@ 2017-04-25 13:18 ` Geoff Lansberry
  2017-06-22 22:01 ` Samuel Ortiz
  1 sibling, 0 replies; 3+ messages in thread
From: Geoff Lansberry @ 2017-04-25 13:18 UTC (permalink / raw)
  To: Colin King; +Cc: Samuel Ortiz, linux-wireless, kernel-janitors, linux-kernel

On Mon, Apr 24, 2017 at 9:36 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The "or" condition (clk_freq != TRF7970A_27MHZ_CLOCK_FREQUENCY) ||
> (clk_freq != TRF7970A_13MHZ_CLOCK_FREQUE) will always be true because
> clk_freq cannot be equal to two different values at the same time. Use
> the  && operator instead of || to fix this.
>
> Detected by CoverityScan, CID#1430468 ("Constant expression result")
>
> Fixes: 837eb4d21ecde7 ("NFC: trf7970a: add device tree option for 27MHz clock")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/nfc/trf7970a.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
> index 2d1c8ca6e679..00eb6cd2b22f 100644
> --- a/drivers/nfc/trf7970a.c
> +++ b/drivers/nfc/trf7970a.c
> @@ -2071,8 +2071,8 @@ static int trf7970a_probe(struct spi_device *spi)
>         }
>
>         of_property_read_u32(np, "clock-frequency", &clk_freq);
> -       if ((clk_freq != TRF7970A_27MHZ_CLOCK_FREQUENCY) ||
> -               (clk_freq != TRF7970A_13MHZ_CLOCK_FREQUENCY)) {
> +       if ((clk_freq != TRF7970A_27MHZ_CLOCK_FREQUENCY) &&
> +               (clk_freq != TRF7970A_13MHZ_CLOCK_FREQUENCY)) {
>                 dev_err(trf->dev,
>                         "clock-frequency (%u Hz) unsupported\n",
>                         clk_freq);
> --
> 2.11.0
>
Nice catch.

Acked-by: Geoff Lansberry <geoff@kuvee.com>

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

* Re: [PATCH] NFC: trf7970a: fix check of clock frequencies, use && instead of ||
  2017-04-24 13:36 [PATCH] NFC: trf7970a: fix check of clock frequencies, use && instead of || Colin King
  2017-04-25 13:18 ` Geoff Lansberry
@ 2017-06-22 22:01 ` Samuel Ortiz
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Ortiz @ 2017-06-22 22:01 UTC (permalink / raw)
  To: Colin King; +Cc: Geoff Lansberry, linux-wireless, kernel-janitors, linux-kernel

Hi Colin,

On Mon, Apr 24, 2017 at 02:36:02PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The "or" condition (clk_freq != TRF7970A_27MHZ_CLOCK_FREQUENCY) ||
> (clk_freq != TRF7970A_13MHZ_CLOCK_FREQUE) will always be true because
> clk_freq cannot be equal to two different values at the same time. Use
> the  && operator instead of || to fix this.
> 
> Detected by CoverityScan, CID#1430468 ("Constant expression result")
> 
> Fixes: 837eb4d21ecde7 ("NFC: trf7970a: add device tree option for 27MHz clock")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/nfc/trf7970a.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
Applied to nfc-next, thanks.

Cheers,
Samuel.

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

end of thread, other threads:[~2017-06-22 22:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-24 13:36 [PATCH] NFC: trf7970a: fix check of clock frequencies, use && instead of || Colin King
2017-04-25 13:18 ` Geoff Lansberry
2017-06-22 22:01 ` Samuel Ortiz

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).