Skip to content

Commit 6cdc8fe

Browse files
andy-shevAndi Shyti
authored andcommitted
i2c: mt7621: Use i2c_10bit_addr_*_from_msg() helpers
Use i2c_10bit_addr_*_from_msg() helpers instead of local copy. No functional change intended. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20250213141045.2716943-8-andriy.shevchenko@linux.intel.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent ed7f48d commit 6cdc8fe

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

drivers/i2c/busses/i2c-mt7621.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,18 @@ static int mtk_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
164164
/* write address */
165165
if (pmsg->flags & I2C_M_TEN) {
166166
/* 10 bits address */
167-
addr = 0xf0 | ((pmsg->addr >> 7) & 0x06);
168-
addr |= (pmsg->addr & 0xff) << 8;
169-
if (pmsg->flags & I2C_M_RD)
170-
addr |= 1;
171-
iowrite32(addr, i2c->base + REG_SM0D0_REG);
172-
ret = mtk_i2c_cmd(i2c, SM0CTL1_WRITE, 2);
173-
if (ret)
174-
goto err_timeout;
167+
addr = i2c_10bit_addr_hi_from_msg(pmsg);
168+
addr |= i2c_10bit_addr_lo_from_msg(pmsg) << 8;
169+
len = 2;
175170
} else {
176171
/* 7 bits address */
177172
addr = i2c_8bit_addr_from_msg(pmsg);
178-
iowrite32(addr, i2c->base + REG_SM0D0_REG);
179-
ret = mtk_i2c_cmd(i2c, SM0CTL1_WRITE, 1);
180-
if (ret)
181-
goto err_timeout;
173+
len = 1;
182174
}
175+
iowrite32(addr, i2c->base + REG_SM0D0_REG);
176+
ret = mtk_i2c_cmd(i2c, SM0CTL1_WRITE, len);
177+
if (ret)
178+
goto err_timeout;
183179

184180
/* check address ACK */
185181
if (!(pmsg->flags & I2C_M_IGNORE_NAK)) {

0 commit comments

Comments
 (0)