svn commit: r262745 - stable/9/sys/dev/iicbus

Jean-Sebastien Pedron dumbbell at FreeBSD.org
Tue Mar 4 18:27:01 UTC 2014


Author: dumbbell
Date: Tue Mar  4 18:27:00 2014
New Revision: 262745
URL: http://svnweb.freebsd.org/changeset/base/262745

Log:
  MFC r232365:
  
  Provide pre/post transfer method callbacks for icbbb
  clients.
  
  These are helful when making certain drivers work on both Linux
  and FreeBSD without changing the code flow too much.
  
  Reviewed by:	kib, wlosh
  Approved by:	kan@

Modified:
  stable/9/sys/dev/iicbus/iicbb.c
  stable/9/sys/dev/iicbus/iicbb_if.m
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/iicbus/iicbb.c
==============================================================================
--- stable/9/sys/dev/iicbus/iicbb.c	Tue Mar  4 17:12:06 2014	(r262744)
+++ stable/9/sys/dev/iicbus/iicbb.c	Tue Mar  4 18:27:00 2014	(r262745)
@@ -75,6 +75,7 @@ static int iicbb_stop(device_t);
 static int iicbb_write(device_t, const char *, int, int *, int);
 static int iicbb_read(device_t, char *, int, int *, int, int);
 static int iicbb_reset(device_t, u_char, u_char, u_char *);
+static int iicbb_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs);
 
 static device_method_t iicbb_methods[] = {
 	/* device interface */
@@ -94,7 +95,7 @@ static device_method_t iicbb_methods[] =
 	DEVMETHOD(iicbus_write,		iicbb_write),
 	DEVMETHOD(iicbus_read,		iicbb_read),
 	DEVMETHOD(iicbus_reset,		iicbb_reset),
-	DEVMETHOD(iicbus_transfer,	iicbus_transfer_gen),
+	DEVMETHOD(iicbus_transfer,	iicbb_transfer),
 
 	{ 0, 0 }
 };
@@ -413,6 +414,21 @@ iicbb_read(device_t dev, char * buf, int
 	return (0);
 }
 
+static int
+iicbb_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
+{
+	int error;
+
+	error = IICBB_PRE_XFER(device_get_parent(dev));
+	if (error)
+		return (error);
+
+	error = iicbus_transfer_gen(dev, msgs, nmsgs);
+
+	IICBB_POST_XFER(device_get_parent(dev));
+	return (error);
+}
+
 DRIVER_MODULE(iicbus, iicbb, iicbus_driver, iicbus_devclass, 0, 0);
 
 MODULE_DEPEND(iicbb, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER);

Modified: stable/9/sys/dev/iicbus/iicbb_if.m
==============================================================================
--- stable/9/sys/dev/iicbus/iicbb_if.m	Tue Mar  4 17:12:06 2014	(r262744)
+++ stable/9/sys/dev/iicbus/iicbb_if.m	Tue Mar  4 18:27:00 2014	(r262745)
@@ -31,13 +31,50 @@
 INTERFACE iicbb;
 
 #
+# Default implementation of optional methods
+#
+CODE {
+	static int
+	null_pre_xfer(device_t dev)
+	{
+		return 0;
+	}
+
+	static void
+	null_post_xfer(device_t dev)
+
+	{
+	}
+
+	static int
+	null_callback(device_t dev, int index, caddr_t data)
+	{
+		return 0;
+	}
+};
+
+#
 # iicbus callback
 #
 METHOD int callback {
 	device_t dev;
 	int index;
 	caddr_t data;
-};
+} DEFAULT null_callback;
+
+#
+# Prepare device for I2C transfer
+#
+METHOD int pre_xfer {
+	device_t dev;
+} DEFAULT null_pre_xfer;
+
+#
+# Cleanup device after I2C transfer
+#
+METHOD void post_xfer {
+	device_t dev;
+} DEFAULT null_post_xfer;
 
 #
 # Set I2C bus data line


More information about the svn-src-stable-9 mailing list