Message ID | 20250213141045.2716943-7-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | i2c: busses: Introduce and use i2c_10bit_addr_*_from_msg() | expand |
> @@ -132,10 +130,12 @@ static int kempld_i2c_process(struct kempld_i2c_data *i2c) > > /* Second part of 10 bit addressing */ > if (i2c->state == STATE_ADDR10) { > - kempld_write8(pld, KEMPLD_I2C_DATA, i2c->msg->addr & 0xff); > + addr = i2c_10bit_addr_lo_from_msg(msg); > + i2c->state = STATE_START; Any reason you moved this? > + > + kempld_write8(pld, KEMPLD_I2C_DATA, addr); Maybe we could skip using 'addr' here? > kempld_write8(pld, KEMPLD_I2C_CMD, I2C_CMD_WRITE); > > - i2c->state = STATE_START; > return 0; > }
On Thu, Feb 13, 2025 at 05:15:09PM +0100, Wolfram Sang wrote: ... > > /* Second part of 10 bit addressing */ > > if (i2c->state == STATE_ADDR10) { > > - kempld_write8(pld, KEMPLD_I2C_DATA, i2c->msg->addr & 0xff); > > + addr = i2c_10bit_addr_lo_from_msg(msg); > > + i2c->state = STATE_START; > > Any reason you moved this? Yes, I would like to be in sync in the above state machine case, just upper in the code which is not visible in this patch. > > + kempld_write8(pld, KEMPLD_I2C_DATA, addr); > > Maybe we could skip using 'addr' here? Same reason as above. > > kempld_write8(pld, KEMPLD_I2C_CMD, I2C_CMD_WRITE); > > > > - i2c->state = STATE_START; > > return 0; > > }
diff --git a/drivers/i2c/busses/i2c-kempld.c b/drivers/i2c/busses/i2c-kempld.c index 212196af68ba..9b4c7cba62b6 100644 --- a/drivers/i2c/busses/i2c-kempld.c +++ b/drivers/i2c/busses/i2c-kempld.c @@ -115,9 +115,7 @@ static int kempld_i2c_process(struct kempld_i2c_data *i2c) if (i2c->state == STATE_ADDR) { /* 10 bit address? */ if (i2c->msg->flags & I2C_M_TEN) { - addr = 0xf0 | ((i2c->msg->addr >> 7) & 0x6); - /* Set read bit if necessary */ - addr |= (i2c->msg->flags & I2C_M_RD) ? 1 : 0; + addr = i2c_10bit_addr_hi_from_msg(msg); i2c->state = STATE_ADDR10; } else { addr = i2c_8bit_addr_from_msg(i2c->msg); @@ -132,10 +130,12 @@ static int kempld_i2c_process(struct kempld_i2c_data *i2c) /* Second part of 10 bit addressing */ if (i2c->state == STATE_ADDR10) { - kempld_write8(pld, KEMPLD_I2C_DATA, i2c->msg->addr & 0xff); + addr = i2c_10bit_addr_lo_from_msg(msg); + i2c->state = STATE_START; + + kempld_write8(pld, KEMPLD_I2C_DATA, addr); kempld_write8(pld, KEMPLD_I2C_CMD, I2C_CMD_WRITE); - i2c->state = STATE_START; return 0; }
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> --- drivers/i2c/busses/i2c-kempld.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)