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:
parent
21a8b38698
commit
813c1b27fe
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user