]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix numerous issues in iic(4) and iicbus(4):
authorJason A. Harmening <jah@FreeBSD.org>
Tue, 21 Apr 2015 11:50:31 +0000 (11:50 +0000)
committerJason A. Harmening <jah@FreeBSD.org>
Tue, 21 Apr 2015 11:50:31 +0000 (11:50 +0000)
commit0afebee290a603f583b1be32e150cc35a13956a5
treebb835543b8a361d83645cb2c61c7e198c0c33f65
parent869fd29a7b764a0d50cf25f17483122901d7c278
Fix numerous issues in iic(4) and iicbus(4):
--Allow multiple open iic fds by storing addressing state in cdevpriv
--Fix, as much as possible, the baked-in race conditions in the iic
ioctl interface by requesting bus ownership on I2CSTART, releasing it on
I2CSTOP/I2CRSTCARD, and requiring bus ownership by the current cdevpriv
to use the I/O ioctls
--Reduce internal iic buffer size and remove 1K read/write limit by
iteratively calling iicbus_read/iicbus_write
--Eliminate dynamic allocation in I2CWRITE/I2CREAD
--Move handling of I2CRDWR to separate function and improve error handling
--Add new I2CSADDR ioctl to store address in current cdevpriv so that
I2CSTART is not needed for read(2)/write(2) to work
--Redesign iicbus_request_bus() and iicbus_release_bus():
    --iicbus_request_bus() no longer falls through if the bus is already
owned by the requesting device.  Multiple threads on the same device may
want exclusive access.  Also, iicbus_release_bus() was never
device-recursive anyway.
    --Previously, if IICBUS_CALLBACK failed in iicbus_release_bus(), but
the following iicbus_poll() call succeeded, IICBUS_CALLBACK would not be
issued again
    --Do not hold iicbus mtx during IICBUS_CALLBACK call.  There are
several drivers that may sleep in IICBUS_CALLBACK, if IIC_WAIT is passed.
    --Do not loop in iicbus_request_bus if IICBUS_CALLBACK returns
EWOULDBLOCK; instead pass that to the caller so that it can retry if so
desired.

Differential Revision: https://reviews.freebsd.org/D2140
Reviewed by: imp, jhb, loos
Approved by: kib (mentor)
sys/dev/iicbus/iic.c
sys/dev/iicbus/iic.h
sys/dev/iicbus/iicbus_if.m
sys/dev/iicbus/iiconf.c