[PATCH 11/25] I2c: Add i2c_8bit_addr_from_msg()

Sascha Hauer s.hauer at pengutronix.de
Fri Nov 10 04:57:46 PST 2023


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 include/i2c/i2c.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index 4fc278f800..9094003b68 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -329,6 +329,10 @@ extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 extern int i2c_master_send(struct i2c_client *client, const char *buf, int count);
 extern int i2c_master_recv(struct i2c_client *client, char *buf, int count);
 
+static inline u8 i2c_8bit_addr_from_msg(const struct i2c_msg *msg)
+{
+	return (msg->addr << 1) | (msg->flags & I2C_M_RD ? 1 : 0);
+}
 
 #define I2C_ADDR_16_BIT	(1 << 31)
 
-- 
2.39.2




More information about the barebox mailing list