Skip to contentSkip to conversation

NFC: trf7970a: fix check of clock frequencies, use && instead of ||

PATCH Mark Greer 1 participant 1 message Apr 27, 2017

lore
Share & tools
lore

Mark Greer

author
#0 lore raw
Quoted 1 line

From: Colin Ian King <[email protected]>

Hi Colin.

[I completely missed this patch and don't have it to directly respond to
anymore so I probably missed some addresses from the CC list.]

Quoted 18 lines

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")
---
 drivers/nfc/trf7970a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nfc/trf7970a.c +0 -0
index 2d1c8ca6e679..00eb6cd2b22f 100644

drivers/nfc/trf7970a.c static int trf7970a_probe(struct spi_device *spi) · line 2078

Quoted 10 lines
drivers/nfc/trf7970a.c +2 -2
@@ -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);

Thanks for catching and fixing this. Please rebase on the latest nfc-next/master branch and line up the two conditional lines of the 'if' statement to match other similar instances in the latest version of the driver.

Thanks,

Mark
--