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

Konstantin Belousov kib at FreeBSD.org
Mon Oct 27 07:51:27 UTC 2014


Author: kib
Date: Mon Oct 27 07:51:26 2014
New Revision: 273728
URL: https://svnweb.freebsd.org/changeset/base/273728

Log:
  Add a method to iicbus to request IIC_M_NOSTOP behaviour for multibyte
  transfers to be default.  It simplifies porting code which assumes
  such settings.
  
  Discussed with:	avg, llos, nwhitehorn
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

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

Modified: head/sys/dev/iicbus/iicbus.h
==============================================================================
--- head/sys/dev/iicbus/iicbus.h	Mon Oct 27 07:47:13 2014	(r273727)
+++ head/sys/dev/iicbus/iicbus.h	Mon Oct 27 07:51:26 2014	(r273728)
@@ -49,16 +49,19 @@ struct iicbus_softc
 struct iicbus_ivar
 {
 	uint32_t	addr;
+	bool		nostop;
 };
 
 enum {
-	IICBUS_IVAR_ADDR		/* Address or base address */
+	IICBUS_IVAR_ADDR,		/* Address or base address */
+	IICBUS_IVAR_NOSTOP,		/* nostop defaults */
 };
 
 #define IICBUS_ACCESSOR(A, B, T)					\
 	__BUS_ACCESSOR(iicbus, A, IICBUS, B, T)
 	
 IICBUS_ACCESSOR(addr,		ADDR,		uint32_t)
+IICBUS_ACCESSOR(nostop,		NOSTOP,		bool)
 
 #define	IICBUS_LOCK(sc)			mtx_lock(&(sc)->lock)
 #define	IICBUS_UNLOCK(sc)      		mtx_unlock(&(sc)->lock)

Modified: head/sys/dev/iicbus/iiconf.c
==============================================================================
--- head/sys/dev/iicbus/iiconf.c	Mon Oct 27 07:47:13 2014	(r273727)
+++ head/sys/dev/iicbus/iiconf.c	Mon Oct 27 07:51:26 2014	(r273728)
@@ -365,6 +365,7 @@ iicbus_transfer_gen(device_t dev, struct
 {
 	int i, error, lenread, lenwrote, nkid, rpstart, addr;
 	device_t *children, bus;
+	bool nostop;
 
 	if ((error = device_get_children(dev, &children, &nkid)) != 0)
 		return (error);
@@ -375,6 +376,7 @@ iicbus_transfer_gen(device_t dev, struct
 	bus = children[0];
 	rpstart = 0;
 	free(children, M_TEMP);
+	nostop = iicbus_get_nostop(dev);
 	for (i = 0, error = 0; i < nmsgs && error == 0; i++) {
 		addr = msgs[i].slave;
 		if (msgs[i].flags & IIC_M_RD)
@@ -399,11 +401,12 @@ iicbus_transfer_gen(device_t dev, struct
 			error = iicbus_write(bus, msgs[i].buf, msgs[i].len,
 			    &lenwrote, 0);
 
-		if (!(msgs[i].flags & IIC_M_NOSTOP)) {
+		if ((msgs[i].flags & IIC_M_NOSTOP) != 0 ||
+		    (nostop && i + 1 < nmsgs)) {
+			rpstart = 1;	/* Next message gets repeated start */
+		} else {
 			rpstart = 0;
 			iicbus_stop(bus);
-		} else {
-			rpstart = 1;	/* Next message gets repeated start */
 		}
 	}
 	return (error);


More information about the svn-src-all mailing list