i2c(8): clean up and clarify read operation
authoravg <avg@FreeBSD.org>
Fri, 13 Oct 2017 09:21:41 +0000 (09:21 +0000)
committeravg <avg@FreeBSD.org>
Fri, 13 Oct 2017 09:21:41 +0000 (09:21 +0000)
commitbdcff5173b2cd3c000435225d1c04fc4b56209da
treeb4f8e77584cee970f406d0d673a4b337b70f03a7
parent5ff550eae1b503fba5c2bb2a0e6bde89ab06d539
i2c(8): clean up and clarify read operation

The code went to a lot of trouble to issue either a start+stop condition
or a repeated start condition only to follow it with a stop condition
and a read(2) call that issues a new start condition.
So, fix the read in I2C_MODE_REPEATED_START mode by using I2CREAD ioctl
within the running transaction.  This obviously requires that the slave
address has the read bit set which was not required before.

Another problem was with width parameter of zero and
I2C_MODE_REPEATED_START mode.  In that case we issued a repeated start
without any preceding start.

While here, remove the redundant (unused) argument to I2CSTOP throughout
the program.
Also, clarify the meaning of -w option, especially "-w 0", in the manual
page.

Reviewed by: no one
Differential Revision: https://reviews.freebsd.org/D12331
usr.sbin/i2c/i2c.8
usr.sbin/i2c/i2c.c