Re: [PATCH v2 07/10] i2c: mt7621: Use i2c_10bit_addr_*_from_msg() helpers

AngeloGioacchino Del Regno
2025-02-13T16:01:23Z

Il 13/02/25 15:07, Andy Shevchenko ha scritto:
> 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>

Can we please do the helper conversion as one commit and the (much needed)
cleanup of assigning len and de-duplicating the call to mtk_i2c_cmd() as
two commits?

One with just the conversion, one with the cleanup (or in inverse order,
as you wish).

Thanks,
Angelo

> ---
> drivers/i2c/busses/i2c-mt7621.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mt7621.c b/drivers/i2c/busses/i2c-mt7621.c
> index 2103f21f9ddd..0a288c998419 100644
> --- a/drivers/i2c/busses/i2c-mt7621.c
> +++ b/drivers/i2c/busses/i2c-mt7621.c
> @@ -164,22 +164,18 @@ static int mtk_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
> /* write address */
> if (pmsg->flags & I2C_M_TEN) {
> /* 10 bits address */
> - addr = 0xf0 | ((pmsg->addr >> 7) & 0x06);
> - addr |= (pmsg->addr & 0xff) << 8;
> - if (pmsg->flags & I2C_M_RD)
> - addr |= 1;
> - iowrite32(addr, i2c->base + REG_SM0D0_REG);
> - ret = mtk_i2c_cmd(i2c, SM0CTL1_WRITE, 2);
> - if (ret)
> - goto err_timeout;
> + addr = i2c_10bit_addr_hi_from_msg(pmsg);
> + addr |= i2c_10bit_addr_lo_from_msg(pmsg) << 8;
> + len = 2;
> } else {
> /* 7 bits address */
> addr = i2c_8bit_addr_from_msg(pmsg);
> - iowrite32(addr, i2c->base + REG_SM0D0_REG);
> - ret = mtk_i2c_cmd(i2c, SM0CTL1_WRITE, 1);
> - if (ret)
> - goto err_timeout;
> + len = 1;
> }
> + iowrite32(addr, i2c->base + REG_SM0D0_REG);
> + ret = mtk_i2c_cmd(i2c, SM0CTL1_WRITE, len);
> + if (ret)
> + goto err_timeout;
>
> /* check address ACK */
> if (!(pmsg->flags & I2C_M_IGNORE_NAK)) {