Module Name: src
Committed By: thorpej
Date: Sat Jun 16 21:24:36 UTC 2018
Modified Files:
src/sys/dev/i2c: hytp14.c
Log Message:
More cleanup to i2c autoconfiguration:
- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.
XXX This driver is an odd-ball with respect to the hardware device.
See comments in the match routine. Unclear how best to handle it.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/hytp14.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/i2c/hytp14.c
diff -u src/sys/dev/i2c/hytp14.c:1.7 src/sys/dev/i2c/hytp14.c:1.8
--- src/sys/dev/i2c/hytp14.c:1.7 Sun Jul 3 12:26:55 2016
+++ src/sys/dev/i2c/hytp14.c Sat Jun 16 21:24:36 2018
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.7 2016/07/03 12:26:55 kardel Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.8 2018/06/16 21:24:36 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -98,19 +98,25 @@ static struct hytp14_sensor hytp14_senso
static int
hytp14_match(device_t parent, cfdata_t match, void *aux)
{
- struct i2c_attach_args *ia;
+ struct i2c_attach_args *ia = aux;
+ int match_result;
- ia = aux;
+ if (iic_use_direct_match(ia, match, NULL, &match_result))
+ return match_result;
- if (ia->ia_name) {
- /* direct config - check name */
- if (strcmp(ia->ia_name, "hythygtemp") == 0)
- return 1;
- } else {
- /* indirect config - check for configured address */
- if ((ia->ia_addr > 0) && (ia->ia_addr <= 0x7F))
- return 1;
- }
+ if (ia->ia_addr == 0x28)
+ return I2C_MATCH_ADDRESS_ONLY;
+
+ /*
+ * XXXJRT
+ * This device is an odd-ball; the i2c address can be changed
+ * at run-time using a command sequence documented in the
+ * application note, but the timing is critical (within 10ms
+ * after power-on of the device), and the device always starts
+ * up at address 0x28.
+ *
+ * How should we handle this?
+ */
return 0;
}