diff mbox series

i2c: brcmstb: Fix brcmstd_send_i2c_cmd condition

Message ID 20210225161101.1856192-1-maxime@cerno.tech
State Accepted
Commit a1858ce0cfe31368b23ba55794e409fb57ced4a4
Headers show
Series i2c: brcmstb: Fix brcmstd_send_i2c_cmd condition | expand

Commit Message

Maxime Ripard Feb. 25, 2021, 4:11 p.m. UTC
The brcmstb_send_i2c_cmd currently has a condition that is (CMD_RD ||
CMD_WR) which always evaluates to true, while the obvious fix is to test
whether the cmd variable passed as parameter holds one of these two
values.

Reported-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/i2c/busses/i2c-brcmstb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wolfram Sang Feb. 25, 2021, 6:31 p.m. UTC | #1
On Thu, Feb 25, 2021 at 05:11:01PM +0100, Maxime Ripard wrote:
> The brcmstb_send_i2c_cmd currently has a condition that is (CMD_RD ||
> CMD_WR) which always evaluates to true, while the obvious fix is to test
> whether the cmd variable passed as parameter holds one of these two
> values.
> 
> Reported-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

I got a feeling of deja vu...

... and, in deed, I already fixed this, too, one year ago:

http://patchwork.ozlabs.org/project/linux-i2c/patch/20200426081211.10876-1-wsa+renesas@sang-engineering.com/

Dunno why it never appeared in a pull request :(

I'll pick this one, now!
Wolfram Sang Feb. 26, 2021, 10:24 a.m. UTC | #2
On Thu, Feb 25, 2021 at 05:11:01PM +0100, Maxime Ripard wrote:
> The brcmstb_send_i2c_cmd currently has a condition that is (CMD_RD ||

> CMD_WR) which always evaluates to true, while the obvious fix is to test

> whether the cmd variable passed as parameter holds one of these two

> values.

> 

> Reported-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

> Signed-off-by: Maxime Ripard <maxime@cerno.tech>


Applied to for-current, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index d4e0a0f6732a..ba766d24219e 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -316,7 +316,7 @@  static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev *dev,
 		goto cmd_out;
 	}
 
-	if ((CMD_RD || CMD_WR) &&
+	if ((cmd == CMD_RD || cmd == CMD_WR) &&
 	    bsc_readl(dev, iic_enable) & BSC_IIC_EN_NOACK_MASK) {
 		rc = -EREMOTEIO;
 		dev_dbg(dev->device, "controller received NOACK intr for %s\n",