Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Oct 2015 21:34:46 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289084 - head/sys/dev/iicbus
Message-ID:  <201510092134.t99LYkEd015616@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510092134.t99LYkEd015616>