Commit 02040811 authored by Ray Jui's avatar Ray Jui Committed by Wolfram Sang

i2c: iproc: Fix shifting 31 bits

Fix undefined behaviour in the iProc I2C driver by using 'BIT' marcro.
Reported-by: default avatarWolfram Sang <wsa@kernel.org>
Signed-off-by: default avatarRay Jui <ray.jui@broadcom.com>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
[wsa: in commit msg, don't say 'checkpatch' but name the issue]
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 914a7b35
...@@ -720,7 +720,7 @@ static int bcm_iproc_i2c_xfer_internal(struct bcm_iproc_i2c_dev *iproc_i2c, ...@@ -720,7 +720,7 @@ static int bcm_iproc_i2c_xfer_internal(struct bcm_iproc_i2c_dev *iproc_i2c,
/* mark the last byte */ /* mark the last byte */
if (!process_call && (i == msg->len - 1)) if (!process_call && (i == msg->len - 1))
val |= 1 << M_TX_WR_STATUS_SHIFT; val |= BIT(M_TX_WR_STATUS_SHIFT);
iproc_i2c_wr_reg(iproc_i2c, M_TX_OFFSET, val); iproc_i2c_wr_reg(iproc_i2c, M_TX_OFFSET, val);
} }
...@@ -738,7 +738,7 @@ static int bcm_iproc_i2c_xfer_internal(struct bcm_iproc_i2c_dev *iproc_i2c, ...@@ -738,7 +738,7 @@ static int bcm_iproc_i2c_xfer_internal(struct bcm_iproc_i2c_dev *iproc_i2c,
*/ */
addr = i2c_8bit_addr_from_msg(msg); addr = i2c_8bit_addr_from_msg(msg);
/* mark it the last byte out */ /* mark it the last byte out */
val = addr | (1 << M_TX_WR_STATUS_SHIFT); val = addr | BIT(M_TX_WR_STATUS_SHIFT);
iproc_i2c_wr_reg(iproc_i2c, M_TX_OFFSET, val); iproc_i2c_wr_reg(iproc_i2c, M_TX_OFFSET, val);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment