git: ee74d0c3619e - stable/12 - rk_i2c_transfer: minor improvement to bit twiddling
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Dec 2021 06:59:22 UTC
The branch stable/12 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=ee74d0c3619e763b7bc354ab4f41ba37583c1471 commit ee74d0c3619e763b7bc354ab4f41ba37583c1471 Author: Andriy Gapon <avg@FreeBSD.org> AuthorDate: 2021-12-15 09:11:15 +0000 Commit: Andriy Gapon <avg@FreeBSD.org> CommitDate: 2021-12-22 06:57:22 +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. (cherry picked from commit 25e92673b54ea3b66cbaf53826cfd01df3441ea3) --- 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 9158eb8222eb..09bfd52a5abe 100644 --- a/sys/arm64/rockchip/rk_i2c.c +++ b/sys/arm64/rockchip/rk_i2c.c @@ -503,7 +503,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);