git: 25e92673b54e - main - rk_i2c_transfer: minor improvement to bit twiddling
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 15 Dec 2021 11:16:46 UTC
The branch main has been updated by avg:
URL: https://cgit.FreeBSD.org/src/commit/?id=25e92673b54ea3b66cbaf53826cfd01df3441ea3
commit 25e92673b54ea3b66cbaf53826cfd01df3441ea3
Author: Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2021-12-15 09:11:15 +0000
Commit: Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2021-12-15 11:16:09 +0000
rk_i2c_transfer: minor improvement to bit twiddling
No need to mask a uint8_t with 0xff, the mask covers the whole type.
Explcitly cast to uint32_t before bit shifting instead of relying on
the implicit promotion to signed int.
MFC after: 1 week
---
sys/arm64/rockchip/rk_i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/arm64/rockchip/rk_i2c.c b/sys/arm64/rockchip/rk_i2c.c
index ef41044e65cb..6ad168f0c64c 100644
--- a/sys/arm64/rockchip/rk_i2c.c
+++ b/sys/arm64/rockchip/rk_i2c.c
@@ -524,7 +524,7 @@ rk_i2c_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
/* Write slave register address */
reg = 0;
for (j = 0; j < msgs[i].len ; j++) {
- reg |= (msgs[i].buf[j] & 0xff) << (j * 8);
+ reg |= (uint32_t)msgs[i].buf[j] << (j * 8);
reg |= RK_I2C_MRXADDR_VALID(j);
}
RK_I2C_WRITE(sc, RK_I2C_MRXRADDR, reg);