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.
This commit is contained in:
Ian Lepore 2017-09-11 23:47:49 +00:00
parent 21a8b38698
commit 813c1b27fe
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323474

View File

@ -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