svn commit: r289084 - head/sys/dev/iicbus

Ian Lepore ian at FreeBSD.org
Fri Oct 9 21:34:47 UTC 2015


Author: ian
Date: Fri Oct  9 21:34:46 2015
New Revision: 289084
URL: https://svnweb.freebsd.org/changeset/base/289084

Log:
  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.

Modified:
  head/sys/dev/iicbus/iiconf.c

Modified: head/sys/dev/iicbus/iiconf.c
==============================================================================
--- head/sys/dev/iicbus/iiconf.c	Fri Oct  9 21:27:30 2015	(r289083)
+++ head/sys/dev/iicbus/iiconf.c	Fri Oct  9 21:34:46 2015	(r289084)
@@ -397,8 +397,7 @@ iicbus_transfer_gen(device_t dev, struct
 			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
 		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
 			iicbus_stop(bus);
 		}
 	}
+	if (error != 0 && !nostop)
+		iicbus_stop(bus);
 	return (error);
 }


More information about the svn-src-all mailing list