diff options
author | ian <ian@FreeBSD.org> | 2016-01-24 18:54:11 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2016-01-24 18:54:11 +0000 |
commit | 6e1c6c6f92ae9dbb55ebdb1d11907f9fcb540329 (patch) | |
tree | b087809b83f3032481110bad8c68a74bc9f9eb21 /sys/dev/iicbus | |
parent | 375d176b915ae25fa3119c32266e5cae55f25d99 (diff) | |
download | FreeBSD-src-6e1c6c6f92ae9dbb55ebdb1d11907f9fcb540329.zip FreeBSD-src-6e1c6c6f92ae9dbb55ebdb1d11907f9fcb540329.tar.gz |
MFC r289726:
Add iicbus_transfer_excl(), a helper routine to do an i2c bus transaction
while holding exclusive ownership of the bus. This is the routine most
slave drivers should use unless they have a need to acquire and hold the
bus across a series of related operations that involves multiple transfers.
Diffstat (limited to 'sys/dev/iicbus')
-rw-r--r-- | sys/dev/iicbus/iiconf.c | 15 | ||||
-rw-r--r-- | sys/dev/iicbus/iiconf.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/sys/dev/iicbus/iiconf.c b/sys/dev/iicbus/iiconf.c index e28d341..8ac8a47 100644 --- a/sys/dev/iicbus/iiconf.c +++ b/sys/dev/iicbus/iiconf.c @@ -395,6 +395,21 @@ iicbus_transfer(device_t bus, struct iic_msg *msgs, uint32_t nmsgs) return (IICBUS_TRANSFER(device_get_parent(bus), msgs, nmsgs)); } +int +iicbus_transfer_excl(device_t dev, struct iic_msg *msgs, uint32_t nmsgs, + int how) +{ + device_t bus; + int error; + + bus = device_get_parent(dev); + error = iicbus_request_bus(bus, dev, how); + if (error == 0) + error = IICBUS_TRANSFER(bus, msgs, nmsgs); + iicbus_release_bus(bus, dev); + return (error); +} + /* * Generic version of iicbus_transfer that calls the appropriate * routines to accomplish this. See note above about acceptable diff --git a/sys/dev/iicbus/iiconf.h b/sys/dev/iicbus/iiconf.h index aca0137..12ac0d7 100644 --- a/sys/dev/iicbus/iiconf.h +++ b/sys/dev/iicbus/iiconf.h @@ -129,6 +129,8 @@ extern int iicbus_block_read(device_t, u_char, char *, int, int *); /* vectors of iic operations to pass to bridge */ int iicbus_transfer(device_t bus, struct iic_msg *msgs, uint32_t nmsgs); +int iicbus_transfer_excl(device_t bus, struct iic_msg *msgs, uint32_t nmsgs, + int how); int iicbus_transfer_gen(device_t bus, struct iic_msg *msgs, uint32_t nmsgs); #define IICBUS_MODVER 1 |