Skip to contentSkip to conversation

i2c_probe: Use "read_byte" command for probing

PATCH Applied Alexander Shiyan 2 participants 2 messages Nov 4, 2020 – Nov 9, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c_probe: Use "read_byte" command for probing

Some I2C adapters do not allow zero length data transfers, such as the AM335X. To use the i2c_probe command, let's use byte reading for this purpose.

---
 commands/i2c.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
commands/i2c.c +4 -2
index 53f36dfaa..997d49a94 100644
@@ -16,10 +16,12 @@ static void i2c_probe_range(struct i2c_adapter *adapter, int startaddr, int stop
 
 	printf("probing i2c%d range 0x%02x-0x%02x: ", adapter->nr, startaddr, stopaddr);
 	for (addr = startaddr; addr <= stopaddr && !ctrlc(); addr++) {
+		u8 buf[1];
 		struct i2c_msg msg = {
 			.addr = addr,
-			.buf = NULL,
-			.len = 0,
+			.buf = buf,
+			.len = sizeof(buf),
+			.flags = I2C_M_RD,
 		};
 		int ret = i2c_transfer(adapter, &msg, 1);
 		if (ret == 1)
Signature · 7 lines
2.26.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 7 lines · Alexander Shiyan

Some I2C adapters do not allow zero length data transfers, such as the AM335X. To use the i2c_probe command, let's use byte reading for this purpose.

---
 commands/i2c.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

Quoted 29 lines
commands/i2c.c +4 -2
index 53f36dfaa..997d49a94 100644
@@ -16,10 +16,12 @@ static void i2c_probe_range(struct i2c_adapter *adapter, int startaddr, int stop
 
 	printf("probing i2c%d range 0x%02x-0x%02x: ", adapter->nr, startaddr, stopaddr);
 	for (addr = startaddr; addr <= stopaddr && !ctrlc(); addr++) {
+		u8 buf[1];
 		struct i2c_msg msg = {
 			.addr = addr,
-			.buf = NULL,
-			.len = 0,
+			.buf = buf,
+			.len = sizeof(buf),
+			.flags = I2C_M_RD,
 		};
 		int ret = i2c_transfer(adapter, &msg, 1);
 		if (ret == 1)
Signature · 7 lines
2.26.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox