diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2019-01-25 21:59:35 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-01-28 10:01:36 +0100 |
commit | 1b6253ab991d272adf8c84b0a6063b4076253d61 (patch) | |
tree | ddd631f1e9f66fbbc455af37fc812dfdc661d252 /commands/i2c.c | |
parent | d4c88b90c558d595bec49de933052ad855da5c69 (diff) | |
download | barebox-1b6253ab991d272adf8c84b0a6063b4076253d61.tar.gz barebox-1b6253ab991d272adf8c84b0a6063b4076253d61.tar.xz |
i2c_probe: Use a quick write transfer instead of writing a zero
This matches the method implemented in i2cdetect(8) when using its -q
option.
With this change an rx8130 RTC is detectable using i2c_probe. This
failed before because this chip acks the first byte (containing its
address and the R/̅W bit) but nacks the following 0 (representing the
target address to write nothing to) which makes i2c_write_reg() return
with an error and so the chip is not listed as available.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/i2c.c')
-rw-r--r-- | commands/i2c.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/commands/i2c.c b/commands/i2c.c index 65ff7378ec..77d65e3fa3 100644 --- a/commands/i2c.c +++ b/commands/i2c.c @@ -24,19 +24,19 @@ static void i2c_probe_range(struct i2c_adapter *adapter, int startaddr, int stopaddr) { - struct i2c_client client = {}; int addr; - int ret; - u8 reg; - - client.adapter = adapter; printf("probing i2c%d range 0x%02x-0x%02x: ", adapter->nr, startaddr, stopaddr); for (addr = startaddr; addr <= stopaddr && !ctrlc(); addr++) { - client.addr = addr; - ret = i2c_write_reg(&client, 0x00, ®, 0); - if (ret == 0) + struct i2c_msg msg = { + .addr = addr, + .buf = NULL, + .len = 0, + }; + int ret = i2c_transfer(adapter, &msg, 1); + if (ret == 1) printf("0x%02x ", addr); + } printf("\n"); } |