diff options
author | ian <ian@FreeBSD.org> | 2015-10-09 21:34:46 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2015-10-09 21:34:46 +0000 |
commit | 6a25be77ca4812720a26bc463d8c3ec090053757 (patch) | |
tree | 52e66b9bdf91d6d08caec77d71d6fd86c1077f3e /sys/dev/iicbus | |
parent | ac5a71dcddf6cda4111de2a687b17a447c1e4df7 (diff) | |
download | FreeBSD-src-6a25be77ca4812720a26bc463d8c3ec090053757.zip FreeBSD-src-6a25be77ca4812720a26bc463d8c3ec090053757.tar.gz |
Bugfix: Exit the transfer loop if any read or write operation fails. Also,
perform a stop operation on the bus if there was an error, otherwise the
bus will remain hung forever. Consistantly use 'if (error != 0)' style in
the function.
Diffstat (limited to 'sys/dev/iicbus')
-rw-r--r-- | sys/dev/iicbus/iiconf.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/dev/iicbus/iiconf.c b/sys/dev/iicbus/iiconf.c index 09edb39..37de020 100644 --- a/sys/dev/iicbus/iiconf.c +++ b/sys/dev/iicbus/iiconf.c @@ -397,8 +397,7 @@ iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) else error = iicbus_start(bus, addr, 0); } - - if (error) + if (error != 0) break; if (msgs[i].flags & IIC_M_RD) @@ -407,6 +406,8 @@ iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) else error = iicbus_write(bus, msgs[i].buf, msgs[i].len, &lenwrote, 0); + if (error != 0) + break; if ((msgs[i].flags & IIC_M_NOSTOP) != 0 || (nostop && i + 1 < nmsgs)) { @@ -416,5 +417,7 @@ iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) iicbus_stop(bus); } } + if (error != 0 && !nostop) + iicbus_stop(bus); return (error); } |