git: 94427ab8f276 - stable/13 - rk_i2c_transfer: minor improvement to bit twiddling

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Wed, 22 Dec 2021 06:51:32 UTC
The branch stable/13 has been updated by avg:

URL: https://cgit.FreeBSD.org/src/commit/?id=94427ab8f276c6f1aba8cca2aef6607bb6d17ac0

commit 94427ab8f276c6f1aba8cca2aef6607bb6d17ac0
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:49:15 +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 2be6716af4eb..fcfdde1bb202 100644
--- a/sys/arm64/rockchip/rk_i2c.c
+++ b/sys/arm64/rockchip/rk_i2c.c
@@ -501,7 +501,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);