mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] i2c_probe: Use "read_byte" command for probing
@ 2020-11-04  3:59 Alexander Shiyan
  2020-11-09  7:50 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Shiyan @ 2020-11-04  3:59 UTC (permalink / raw)
  To: barebox

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.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 commands/i2c.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/commands/i2c.c b/commands/i2c.c
index 53f36dfaa..997d49a94 100644
--- a/commands/i2c.c
+++ b/commands/i2c.c
@@ -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)
-- 
2.26.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-09  7:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-04  3:59 [PATCH] i2c_probe: Use "read_byte" command for probing Alexander Shiyan
2020-11-09  7:50 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox