diff mbox series

[v1,3/8] i2c: bcm-kona: Use i2c_10bit_addr_from_msg() helper

Message ID 20250212163359.2407327-4-andriy.shevchenko@linux.intel.com (mailing list archive)
State New
Headers show
Series i2c: busses: Introduce and use i2c_10bit_addr_from_msg() | expand

Commit Message

Andy Shevchenko Feb. 12, 2025, 4:32 p.m. UTC
Use i2c_10bit_addr_from_msg() helper instead of local copy.
No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-bcm-kona.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-bcm-kona.c b/drivers/i2c/busses/i2c-bcm-kona.c
index 340fe1305dd9..f8826e2d3ec2 100644
--- a/drivers/i2c/busses/i2c-bcm-kona.c
+++ b/drivers/i2c/busses/i2c-bcm-kona.c
@@ -470,14 +470,14 @@  static int bcm_kona_i2c_do_addr(struct bcm_kona_i2c_dev *dev,
 	unsigned char addr;
 
 	if (msg->flags & I2C_M_TEN) {
+		addr = i2c_10bit_addr_from_msg(msg);
+
 		/* First byte is 11110XX0 where XX is upper 2 bits */
-		addr = 0xF0 | ((msg->addr & 0x300) >> 7);
-		if (bcm_kona_i2c_write_byte(dev, addr, 0) < 0)
+		if (bcm_kona_i2c_write_byte(dev, addr & ~I2C_M_RD, 0) < 0)
 			return -EREMOTEIO;
 
 		/* Second byte is the remaining 8 bits */
-		addr = msg->addr & 0xFF;
-		if (bcm_kona_i2c_write_byte(dev, addr, 0) < 0)
+		if (bcm_kona_i2c_write_byte(dev, msg->addr & 0xFF, 0) < 0)
 			return -EREMOTEIO;
 
 		if (msg->flags & I2C_M_RD) {
@@ -486,7 +486,6 @@  static int bcm_kona_i2c_do_addr(struct bcm_kona_i2c_dev *dev,
 				return -EREMOTEIO;
 
 			/* Then re-send the first byte with the read bit set */
-			addr = 0xF0 | ((msg->addr & 0x300) >> 7) | 0x01;
 			if (bcm_kona_i2c_write_byte(dev, addr, 0) < 0)
 				return -EREMOTEIO;
 		}