Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Sep 2017 23:47:49 +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: r323474 - head/sys/dev/iicbus
Message-ID:  <201709112347.v8BNln8G097919@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Mon Sep 11 23:47:49 2017
New Revision: 323474
URL: https://svnweb.freebsd.org/changeset/base/323474

Log:
  Add a default implementation that returns ENODEV for start, repeat_start,
  stop, read, and write methods.  Some controllers don't implement these
  individual operations and have only a transfer method.  In that case, we
  should return an indication that the device is present but doesn't support
  the method, as opposed to the kobj default error ENXIO which makes it
  look like the whole device is missing.  Userland tools such as i2c(8) can
  use the differing return values to switch between the two different i2c
  IO mechanisms.

Modified:
  head/sys/dev/iicbus/iicbus_if.m

Modified: head/sys/dev/iicbus/iicbus_if.m
==============================================================================
--- head/sys/dev/iicbus/iicbus_if.m	Mon Sep 11 22:43:01 2017	(r323473)
+++ head/sys/dev/iicbus/iicbus_if.m	Mon Sep 11 23:47:49 2017	(r323474)
@@ -32,6 +32,12 @@
 INTERFACE iicbus;
 
 CODE {
+	static int iicbus_nosupport(void)
+	{
+
+		return (ENODEV);
+	}
+
 	static u_int
 	iicbus_default_frequency(device_t bus, u_char speed)
 	{
@@ -69,7 +75,7 @@ METHOD int repeated_start {
 	device_t dev;
 	u_char slave;
 	int timeout;
-};
+} DEFAULT iicbus_nosupport;
 
 #
 # Send START condition
@@ -78,14 +84,14 @@ METHOD int start {
 	device_t dev;
 	u_char slave;
 	int timeout;
-};
+} DEFAULT iicbus_nosupport;
 
 #
 # Send STOP condition
 #
 METHOD int stop {
 	device_t dev;
-};
+} DEFAULT iicbus_nosupport;
 
 #
 # Read from I2C bus
@@ -97,7 +103,7 @@ METHOD int read {
 	int *bytes;
 	int last;
 	int delay;
-};
+} DEFAULT iicbus_nosupport;
 
 #
 # Write to the I2C bus
@@ -108,7 +114,7 @@ METHOD int write {
 	int len;
 	int *bytes;
 	int timeout;
-};
+} DEFAULT iicbus_nosupport;
 
 #
 # Reset I2C bus



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