Module Name: src
Committed By: thorpej
Date: Sat Jun 16 21:22:14 UTC 2018
Modified Files:
src/sys/arch/evbmips/loongson/dev: stvii.c
src/sys/arch/hpcarm/dev: nbppcon.c
src/sys/arch/macppc/dev: deq.c smusat.c videopll.c
src/sys/arch/sparc64/dev: pcf8591_envctrl.c tda.c
src/sys/arch/zaurus/dev: ioexp.c wm8731_zaudio.c wm8750_zaudio.c
src/sys/dev/i2c: ac100.c act8846.c adadc.c adm1021.c adm1026.c am2315.c
as3722.c at24cxx.c axp20x.c axp22x.c axp809.c axppmic.c dbcool.c
ddc.c dstemp.c em3027.c fcu.c g760a.c i2c.c i2cvar.h ibmhawk.c
ihidev.c lm75.c lm87.c lm_i2c.c m41st84.c m41t00.c max6900.c
max77620.c mcp980x.c mpl115a.c pcf8563.c pcf8583.c r2025.c
rs5c372.c s390.c sdtemp.c sgsmix.c si70xx.c smscmon.c spdmem_i2c.c
sy8106a.c tcagpio.c tcakp.c titemp.c tps65217pmic.c tps65950.c
tsl256x.c w83795g.c x1226.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.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbmips/loongson/dev/stvii.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hpcarm/dev/nbppcon.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/dev/deq.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/smusat.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/videopll.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/pcf8591_envctrl.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/dev/tda.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/zaurus/dev/ioexp.c \
src/sys/arch/zaurus/dev/wm8731_zaudio.c \
src/sys/arch/zaurus/dev/wm8750_zaudio.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/ac100.c src/sys/dev/i2c/axp809.c \
src/sys/dev/i2c/dstemp.c src/sys/dev/i2c/em3027.c \
src/sys/dev/i2c/mpl115a.c src/sys/dev/i2c/sy8106a.c \
src/sys/dev/i2c/tcagpio.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/act8846.c src/sys/dev/i2c/g760a.c \
src/sys/dev/i2c/lm_i2c.c src/sys/dev/i2c/titemp.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/adadc.c src/sys/dev/i2c/axp22x.c \
src/sys/dev/i2c/fcu.c src/sys/dev/i2c/s390.c src/sys/dev/i2c/si70xx.c \
src/sys/dev/i2c/tsl256x.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/i2c/adm1021.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/adm1026.c src/sys/dev/i2c/am2315.c \
src/sys/dev/i2c/ihidev.c src/sys/dev/i2c/max77620.c \
src/sys/dev/i2c/smscmon.c src/sys/dev/i2c/w83795g.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/i2c/as3722.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/i2c/at24cxx.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/i2c/axp20x.c src/sys/dev/i2c/axppmic.c
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/i2c/dbcool.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/ddc.c src/sys/dev/i2c/ibmhawk.c \
src/sys/dev/i2c/tcakp.c
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/i2c/i2c.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/i2c/i2cvar.h
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/i2c/lm75.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/lm87.c src/sys/dev/i2c/r2025.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/i2c/m41st84.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/i2c/m41t00.c src/sys/dev/i2c/x1226.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/i2c/max6900.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/mcp980x.c src/sys/dev/i2c/tps65950.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/pcf8563.c src/sys/dev/i2c/sgsmix.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/i2c/pcf8583.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/i2c/rs5c372.c \
src/sys/dev/i2c/spdmem_i2c.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/i2c/sdtemp.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/i2c/tps65217pmic.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/arch/evbmips/loongson/dev/stvii.c
diff -u src/sys/arch/evbmips/loongson/dev/stvii.c:1.5 src/sys/arch/evbmips/loongson/dev/stvii.c:1.6
--- src/sys/arch/evbmips/loongson/dev/stvii.c:1.5 Mon Feb 29 18:24:31 2016
+++ src/sys/arch/evbmips/loongson/dev/stvii.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: stvii.c,v 1.5 2016/02/29 18:24:31 christos Exp $ */
+/* $NetBSD: stvii.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (C) 2011 Michael Lorenz.
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: stvii.c,v 1.5 2016/02/29 18:24:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stvii.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -136,7 +136,7 @@ stvii_match(device_t parent, cfdata_t cf
DPRINTF("%02x\n", in);
iic_release_bus(args->ia_tag, 0);
}
- return (ret >= 0);
+ return (ret >= 0) ? I2C_MATCH_ADDRESS_AND_PROBE : 0;
}
static void
Index: src/sys/arch/hpcarm/dev/nbppcon.c
diff -u src/sys/arch/hpcarm/dev/nbppcon.c:1.2 src/sys/arch/hpcarm/dev/nbppcon.c:1.3
--- src/sys/arch/hpcarm/dev/nbppcon.c:1.2 Sat Jun 16 05:58:03 2012
+++ src/sys/arch/hpcarm/dev/nbppcon.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: nbppcon.c,v 1.2 2012/06/16 05:58:03 kiyohara Exp $ */
+/* $NetBSD: nbppcon.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2011 KIYOHARA Takashi
* All rights reserved.
@@ -25,7 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nbppcon.c,v 1.2 2012/06/16 05:58:03 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nbppcon.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -78,7 +78,7 @@ nbppcon_match(device_t parent, cfdata_t
!platid_match(&platid, &platid_mask_MACH_PSIONTEKLOGIX_NETBOOK_PRO))
return 0;
- return 1;
+ return I2C_MATCH_ADDRESS_AND_PROBE;
}
/* ARGSUSED */
Index: src/sys/arch/macppc/dev/deq.c
diff -u src/sys/arch/macppc/dev/deq.c:1.13 src/sys/arch/macppc/dev/deq.c:1.14
--- src/sys/arch/macppc/dev/deq.c:1.13 Fri May 4 17:15:23 2018
+++ src/sys/arch/macppc/dev/deq.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: deq.c,v 1.13 2018/05/04 17:15:23 macallan Exp $ */
+/* $NetBSD: deq.c,v 1.14 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (C) 2005 Michael Lorenz
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: deq.c,v 1.13 2018/05/04 17:15:23 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: deq.c,v 1.14 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -65,15 +65,13 @@ int
deq_match(device_t parent, struct cfdata *cf, void *aux)
{
struct i2c_attach_args *ia = aux;
-
- if (ia->ia_name) {
- if (ia->ia_ncompat > 0) {
- if (iic_compat_match(ia, deq_compats))
- return 1;
- }
- if (strcmp(ia->ia_name, "deq") == 0)
- return 1;
- }
+ int match_result;
+
+ if (iic_use_direct_match(ia, cf, deq_compats, &match_result))
+ return match_result;
+
+ /* This driver is direct-config only. */
+
return 0;
}
Index: src/sys/arch/macppc/dev/smusat.c
diff -u src/sys/arch/macppc/dev/smusat.c:1.3 src/sys/arch/macppc/dev/smusat.c:1.4
--- src/sys/arch/macppc/dev/smusat.c:1.3 Fri Apr 20 18:22:50 2018
+++ src/sys/arch/macppc/dev/smusat.c Sat Jun 16 21:22:13 2018
@@ -115,15 +115,15 @@ static int
smusat_match(device_t parent, struct cfdata *cf, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name == NULL) {
- /* no ID registers on this chip */
- if (ia->ia_addr == 0x58)
- return 1;
- return 0;
- } else {
- return iic_compat_match(ia, smusat_compats);
- }
+ if (iic_use_direct_match(ia, cf, smusat_compats, &match_result))
+ return match_result;
+
+ if (ia->ia_addr == 0x58)
+ return I2C_MATCH_ADDRESS_ONLY;
+
+ return 0;
}
static void
Index: src/sys/arch/macppc/dev/videopll.c
diff -u src/sys/arch/macppc/dev/videopll.c:1.2 src/sys/arch/macppc/dev/videopll.c:1.3
--- src/sys/arch/macppc/dev/videopll.c:1.2 Fri Sep 22 04:01:41 2017
+++ src/sys/arch/macppc/dev/videopll.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: videopll.c,v 1.2 2017/09/22 04:01:41 macallan Exp $ */
+/* $NetBSD: videopll.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2012 Michael Lorenz
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: videopll.c,v 1.2 2017/09/22 04:01:41 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: videopll.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -70,9 +70,12 @@ static int
videopll_match(device_t parent, cfdata_t cfdata, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (strcmp(ia->ia_name, "videopll") == 0)
- return 100;
+ if (iic_use_direct_match(ia, cfdata, NULL, &match_result))
+ return match_result;
+
+ /* This driver is direct-config only. */
return 0;
}
Index: src/sys/arch/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.6 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.7
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.6 Sun Mar 18 05:26:58 2012
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: pcf8591_envctrl.c,v 1.6 2012/03/18 05:26:58 mrg Exp $ */
+/* $NetBSD: pcf8591_envctrl.c,v 1.7 2018/06/16 21:22:13 thorpej Exp $ */
/* $OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
/*
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.6 2012/03/18 05:26:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.7 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -78,9 +78,12 @@ static int
ecadc_match(device_t parent, cfdata_t cf, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (iic_compat_match(ia, ecadc_compats))
- return 1;
+ if (iic_use_direct_match(ia, cf, ecadc_compats, &match_result))
+ return match_result;
+
+ /* This driver is direct-config only. */
return 0;
}
Index: src/sys/arch/sparc64/dev/tda.c
diff -u src/sys/arch/sparc64/dev/tda.c:1.11 src/sys/arch/sparc64/dev/tda.c:1.12
--- src/sys/arch/sparc64/dev/tda.c:1.11 Thu Jul 7 06:55:38 2016
+++ src/sys/arch/sparc64/dev/tda.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: tda.c,v 1.11 2016/07/07 06:55:38 msaitoh Exp $ */
+/* $NetBSD: tda.c,v 1.12 2018/06/16 21:22:13 thorpej Exp $ */
/* $OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */
/*
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.11 2016/07/07 06:55:38 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.12 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -100,7 +100,9 @@ tda_match(device_t parent, cfdata_t matc
*/
if (ia->ia_name == NULL)
return(0);
- return strcmp(ia->ia_name, "fan-control") == 0;
+
+ return strcmp(ia->ia_name, "fan-control") == 0 ?
+ I2C_MATCH_DIRECT_SPECIFIC : 0;
}
void
Index: src/sys/arch/zaurus/dev/ioexp.c
diff -u src/sys/arch/zaurus/dev/ioexp.c:1.1 src/sys/arch/zaurus/dev/ioexp.c:1.2
--- src/sys/arch/zaurus/dev/ioexp.c:1.1 Sun Jun 19 16:20:09 2011
+++ src/sys/arch/zaurus/dev/ioexp.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ioexp.c,v 1.1 2011/06/19 16:20:09 nonaka Exp $ */
+/* $NetBSD: ioexp.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ioexp.c,v 1.1 2011/06/19 16:20:09 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ioexp.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -86,20 +86,19 @@ static int
ioexp_match(device_t parent, cfdata_t cf, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
/* only for SL-C1000 */
if (!ZAURUS_ISC1000)
return 0;
- if (ia->ia_name) {
- /* direct config - check name */
- if (strcmp(ia->ia_name, "ioexp") == 0)
- return 1;
- } else {
- /* indirect config - check typical address */
- if (ia->ia_addr == IOEXP_ADDRESS)
- return 1;
- }
+ if (iic_use_direct_match(ia, cf, NULL, &match_result))
+ return match_result;
+
+ /* indirect config - check typical address */
+ if (ia->ia_addr == IOEXP_ADDRESS)
+ return I2C_MATCH_ADDRESS_ONLY;
+
return 0;
}
Index: src/sys/arch/zaurus/dev/wm8731_zaudio.c
diff -u src/sys/arch/zaurus/dev/wm8731_zaudio.c:1.1 src/sys/arch/zaurus/dev/wm8731_zaudio.c:1.2
--- src/sys/arch/zaurus/dev/wm8731_zaudio.c:1.1 Tue Sep 23 14:49:46 2014
+++ src/sys/arch/zaurus/dev/wm8731_zaudio.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: wm8731_zaudio.c,v 1.1 2014/09/23 14:49:46 nonaka Exp $ */
+/* $NetBSD: wm8731_zaudio.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include "opt_zaudio.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wm8731_zaudio.c,v 1.1 2014/09/23 14:49:46 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wm8731_zaudio.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -211,19 +211,18 @@ wm8731_write(struct zaudio_softc *sc, in
int
wm8731_match(device_t parent, cfdata_t cf, struct i2c_attach_args *ia)
{
+ int match_result;
if (ZAURUS_ISC1000 || ZAURUS_ISC3000)
return 0;
- if (ia->ia_name) {
- /* direct config - check name */
- if (strcmp(ia->ia_name, "zaudio") == 0)
- return 1;
- } else {
- /* indirect config - check typical address */
- if (ia->ia_addr == WM8731_ADDRESS)
- return 1;
- }
+ if (iic_use_direct_match(ia, cf, NULL, &match_result))
+ return match_result;
+
+ /* indirect config - check typical address */
+ if (ia->ia_addr == WM8731_ADDRESS)
+ return I2C_MATCH_ADDRESS_ONLY;
+
return 0;
}
Index: src/sys/arch/zaurus/dev/wm8750_zaudio.c
diff -u src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.1 src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.2
--- src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.1 Tue Sep 23 14:49:46 2014
+++ src/sys/arch/zaurus/dev/wm8750_zaudio.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: wm8750_zaudio.c,v 1.1 2014/09/23 14:49:46 nonaka Exp $ */
+/* $NetBSD: wm8750_zaudio.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/* $OpenBSD: zaurus_audio.c,v 1.8 2005/08/18 13:23:02 robert Exp $ */
/*
@@ -51,7 +51,7 @@
#include "opt_zaudio.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wm8750_zaudio.c,v 1.1 2014/09/23 14:49:46 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wm8750_zaudio.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -276,19 +276,18 @@ wm8750_write(struct zaudio_softc *sc, in
int
wm8750_match(device_t parent, cfdata_t cf, struct i2c_attach_args *ia)
{
+ int match_result;
if (ZAURUS_ISC860)
return 0;
- if (ia->ia_name) {
- /* direct config - check name */
- if (strcmp(ia->ia_name, "zaudio") == 0)
- return 1;
- } else {
- /* indirect config - check typical address */
- if (ia->ia_addr == WM8750_ADDRESS)
- return 1;
- }
+ if (iic_use_direct_match(ia, cf, NULL, &match_result))
+ return match_result;
+
+ /* indirect config - check typical address */
+ if (ia->ia_addr == WM8750_ADDRESS)
+ return I2C_MATCH_ADDRESS_ONLY;
+
return 0;
}
Index: src/sys/dev/i2c/ac100.c
diff -u src/sys/dev/i2c/ac100.c:1.1 src/sys/dev/i2c/ac100.c:1.2
--- src/sys/dev/i2c/ac100.c:1.1 Sun Dec 7 14:24:11 2014
+++ src/sys/dev/i2c/ac100.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ac100.c,v 1.1 2014/12/07 14:24:11 jmcneill Exp $ */
+/* $NetBSD: ac100.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.1 2014/12/07 14:24:11 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -109,7 +109,7 @@ CFATTACH_DECL_NEW(ac100ic, sizeof(struct
static int
ac100_match(device_t parent, cfdata_t match, void *aux)
{
- return 1;
+ return I2C_MATCH_ADDRESS_ONLY; /* XXX */
}
static void
Index: src/sys/dev/i2c/axp809.c
diff -u src/sys/dev/i2c/axp809.c:1.1 src/sys/dev/i2c/axp809.c:1.2
--- src/sys/dev/i2c/axp809.c:1.1 Sun Dec 7 00:33:26 2014
+++ src/sys/dev/i2c/axp809.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: axp809.c,v 1.1 2014/12/07 00:33:26 jmcneill Exp $ */
+/* $NetBSD: axp809.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <[email protected]>
@@ -29,7 +29,7 @@
#define AXP_DEBUG
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: axp809.c,v 1.1 2014/12/07 00:33:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axp809.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -105,7 +105,15 @@ CFATTACH_DECL_NEW(axp809pm, sizeof(struc
static int
axp809_match(device_t parent, cfdata_t match, void *aux)
{
- return 1;
+ struct i2c_attach_args *ia = aux;
+ int match_result;
+
+ if (iic_use_direct_match(ia, match, NULL, &match_result))
+ return match_result;
+
+ /* This device is direct-config only. */
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/dstemp.c
diff -u src/sys/dev/i2c/dstemp.c:1.1 src/sys/dev/i2c/dstemp.c:1.2
--- src/sys/dev/i2c/dstemp.c:1.1 Thu Feb 1 21:44:17 2018
+++ src/sys/dev/i2c/dstemp.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dstemp.c,v 1.1 2018/02/01 21:44:17 macallan Exp $ */
+/* $NetBSD: dstemp.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dstemp.c,v 1.1 2018/02/01 21:44:17 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dstemp.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -81,15 +81,15 @@ static int
dstemp_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name == NULL) {
- /* no ID registers on this chip */
- if ((ia->ia_addr & 0xf8) == 0x48)
- return 1;
- return 0;
- } else {
- return iic_compat_match(ia, dstemp_compats);
- }
+ if (iic_use_direct_match(ia, match, dstemp_compats, &match_result))
+ return match_result;
+
+ if ((ia->ia_addr & 0xf8) == 0x48)
+ return I2C_MATCH_ADDRESS_ONLY;
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/em3027.c
diff -u src/sys/dev/i2c/em3027.c:1.1 src/sys/dev/i2c/em3027.c:1.2
--- src/sys/dev/i2c/em3027.c:1.1 Fri Jan 5 03:07:15 2018
+++ src/sys/dev/i2c/em3027.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: em3027.c,v 1.1 2018/01/05 03:07:15 uwe Exp $ */
+/* $NetBSD: em3027.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2018 Valery Ushakov
* All rights reserved.
@@ -28,7 +28,7 @@
* EM Microelectronic EM3027 RTC
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: em3027.c,v 1.1 2018/01/05 03:07:15 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: em3027.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -128,7 +128,7 @@ em3027rtc_match(device_t parent, cfdata_
if (error)
return 0;
- return 1;
+ return I2C_MATCH_ADDRESS_AND_PROBE;
}
Index: src/sys/dev/i2c/mpl115a.c
diff -u src/sys/dev/i2c/mpl115a.c:1.1 src/sys/dev/i2c/mpl115a.c:1.2
--- src/sys/dev/i2c/mpl115a.c:1.1 Sun Sep 8 14:59:42 2013
+++ src/sys/dev/i2c/mpl115a.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: mpl115a.c,v 1.1 2013/09/08 14:59:42 rkujawa Exp $ */
+/* $NetBSD: mpl115a.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpl115a.c,v 1.1 2013/09/08 14:59:42 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpl115a.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -97,7 +97,7 @@ mpl115a_match(device_t parent, cfdata_t
struct i2c_attach_args *ia = aux;
if (ia->ia_addr == MPL115A_ADDR)
- return 1;
+ return I2C_MATCH_ADDRESS_ONLY;
return 0;
}
Index: src/sys/dev/i2c/sy8106a.c
diff -u src/sys/dev/i2c/sy8106a.c:1.1 src/sys/dev/i2c/sy8106a.c:1.2
--- src/sys/dev/i2c/sy8106a.c:1.1 Mon Oct 2 22:48:02 2017
+++ src/sys/dev/i2c/sy8106a.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sy8106a.c,v 1.1 2017/10/02 22:48:02 jmcneill Exp $ */
+/* $NetBSD: sy8106a.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sy8106a.c,v 1.1 2017/10/02 22:48:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sy8106a.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -185,11 +185,12 @@ static int
sy8106a_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name == NULL)
- return 0;
-
- return iic_compat_match(ia, compatible);
+ if (iic_use_direct_match(ia, match, compatible, &match_result))
+ return match_result;
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/tcagpio.c
diff -u src/sys/dev/i2c/tcagpio.c:1.1 src/sys/dev/i2c/tcagpio.c:1.2
--- src/sys/dev/i2c/tcagpio.c:1.1 Fri Sep 22 18:12:31 2017
+++ src/sys/dev/i2c/tcagpio.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: tcagpio.c,v 1.1 2017/09/22 18:12:31 jmcneill Exp $ */
+/* $NetBSD: tcagpio.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcagpio.c,v 1.1 2017/09/22 18:12:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcagpio.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -246,11 +246,12 @@ static int
tcagpio_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name == NULL)
- return 0;
+ if (iic_use_direct_match(ia, match, compatible, &match_result))
+ return match_result;
- return iic_compat_match(ia, compatible);
+ return 0;
}
static void
Index: src/sys/dev/i2c/act8846.c
diff -u src/sys/dev/i2c/act8846.c:1.4 src/sys/dev/i2c/act8846.c:1.5
--- src/sys/dev/i2c/act8846.c:1.4 Mon Apr 30 20:26:09 2018
+++ src/sys/dev/i2c/act8846.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: act8846.c,v 1.4 2018/04/30 20:26:09 jmcneill Exp $ */
+/* $NetBSD: act8846.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <[email protected]>
@@ -29,7 +29,7 @@
//#define ACT_DEBUG
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: act8846.c,v 1.4 2018/04/30 20:26:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: act8846.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -151,7 +151,7 @@ act8846_match(device_t parent, cfdata_t
struct i2c_attach_args *ia = aux;
if (ia->ia_addr == 0x5a)
- return 1;
+ return I2C_MATCH_ADDRESS_ONLY;
return 0;
}
Index: src/sys/dev/i2c/g760a.c
diff -u src/sys/dev/i2c/g760a.c:1.4 src/sys/dev/i2c/g760a.c:1.5
--- src/sys/dev/i2c/g760a.c:1.4 Sun Jul 29 07:04:09 2012
+++ src/sys/dev/i2c/g760a.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: g760a.c,v 1.4 2012/07/29 07:04:09 mlelstv Exp $ */
+/* $NetBSD: g760a.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (C) 2008 A.Leo.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: g760a.c,v 1.4 2012/07/29 07:04:09 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: g760a.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -79,7 +79,7 @@ g760a_match(device_t parent, struct cfda
/*
* TODO: set up minimal speed?
*/
- return 1;
+ return I2C_MATCH_ADDRESS_ONLY;
}
return 0;
Index: src/sys/dev/i2c/lm_i2c.c
diff -u src/sys/dev/i2c/lm_i2c.c:1.4 src/sys/dev/i2c/lm_i2c.c:1.5
--- src/sys/dev/i2c/lm_i2c.c:1.4 Fri Aug 18 04:07:51 2017
+++ src/sys/dev/i2c/lm_i2c.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: lm_i2c.c,v 1.4 2017/08/18 04:07:51 msaitoh Exp $ */
+/* $NetBSD: lm_i2c.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm_i2c.c,v 1.4 2017/08/18 04:07:51 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm_i2c.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -71,6 +71,8 @@ lm_i2c_match(device_t parent, cfdata_t m
if (ia->ia_addr < 1)
return 0;
+ /* XXXJRT filter addresses //at all// please? */
+
/* Bus independent probe */
sc.sc_lmsc.lm_writereg = lm_i2c_writereg;
sc.sc_lmsc.lm_readreg = lm_i2c_readreg;
@@ -78,7 +80,7 @@ lm_i2c_match(device_t parent, cfdata_t m
sc.sc_addr = ia->ia_addr;
rv = lm_match(&sc.sc_lmsc);
- return rv;
+ return rv ? I2C_MATCH_ADDRESS_AND_PROBE : 0;
}
Index: src/sys/dev/i2c/titemp.c
diff -u src/sys/dev/i2c/titemp.c:1.4 src/sys/dev/i2c/titemp.c:1.5
--- src/sys/dev/i2c/titemp.c:1.4 Mon Apr 30 20:37:01 2018
+++ src/sys/dev/i2c/titemp.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: titemp.c,v 1.4 2018/04/30 20:37:01 jmcneill Exp $ */
+/* $NetBSD: titemp.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: titemp.c,v 1.4 2018/04/30 20:37:01 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: titemp.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -94,25 +94,24 @@ titemp_match(device_t parent, cfdata_t m
{
struct i2c_attach_args *ia = aux;
uint8_t mfid;
- int error;
+ int error, match_result;
- if (ia->ia_name == NULL) {
- if (ia->ia_addr != 0x4c)
- return 0;
-
- if (iic_acquire_bus(ia->ia_tag, I2C_F_POLL) != 0)
- return 0;
- error = iic_smbus_read_byte(ia->ia_tag, ia->ia_addr,
- TITEMP_MFID_REG, &mfid, I2C_F_POLL);
- iic_release_bus(ia->ia_tag, I2C_F_POLL);
+ if (iic_use_direct_match(ia, match, titemp_compats, &match_result))
+ return match_result;
+
+ if (ia->ia_addr != 0x4c)
+ return 0;
+
+ if (iic_acquire_bus(ia->ia_tag, I2C_F_POLL) != 0)
+ return 0;
+ error = iic_smbus_read_byte(ia->ia_tag, ia->ia_addr,
+ TITEMP_MFID_REG, &mfid, I2C_F_POLL);
+ iic_release_bus(ia->ia_tag, I2C_F_POLL);
- if (error || mfid != TITEMP_MFID_TMP451)
- return 0;
+ if (error || mfid != TITEMP_MFID_TMP451)
+ return 0;
- return 1;
- } else {
- return iic_compat_match(ia, titemp_compats);
- }
+ return I2C_MATCH_ADDRESS_AND_PROBE;
}
static void
Index: src/sys/dev/i2c/adadc.c
diff -u src/sys/dev/i2c/adadc.c:1.3 src/sys/dev/i2c/adadc.c:1.4
--- src/sys/dev/i2c/adadc.c:1.3 Fri Mar 16 22:10:31 2018
+++ src/sys/dev/i2c/adadc.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: adadc.c,v 1.3 2018/03/16 22:10:31 macallan Exp $ */
+/* $NetBSD: adadc.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2018 Michael Lorenz
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adadc.c,v 1.3 2018/03/16 22:10:31 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adadc.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -105,19 +105,20 @@ static int
adadc_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name == NULL) {
- /*
- * XXX
- * this driver is pretty much useless without OF, should
- * probably remove this
- */
- if ((ia->ia_addr & 0x2b) == 0x2b)
- return 1;
- return 0;
- } else {
- return iic_compat_match(ia, dstemp_compats);
- }
+ if (iic_use_direct_match(ia, match, dstemp_compats, &match_result))
+ return match_result;
+
+ /*
+ * XXX
+ * this driver is pretty much useless without OF, should
+ * probably remove this
+ */
+ if ((ia->ia_addr & 0x2b) == 0x2b)
+ return I2C_MATCH_ADDRESS_ONLY;
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/axp22x.c
diff -u src/sys/dev/i2c/axp22x.c:1.3 src/sys/dev/i2c/axp22x.c:1.4
--- src/sys/dev/i2c/axp22x.c:1.3 Sat Oct 7 20:31:48 2017
+++ src/sys/dev/i2c/axp22x.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: axp22x.c,v 1.3 2017/10/07 20:31:48 jmcneill Exp $ */
+/* $NetBSD: axp22x.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: axp22x.c,v 1.3 2017/10/07 20:31:48 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axp22x.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -69,11 +69,14 @@ static int
axp22x_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name != NULL)
- return iic_compat_match(ia, compatible);
+ if (iic_use_direct_match(ia, match, compatible, &match_result))
+ return match_result;
- return 1;
+ /* This device is direct-config only. */
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/fcu.c
diff -u src/sys/dev/i2c/fcu.c:1.3 src/sys/dev/i2c/fcu.c:1.4
--- src/sys/dev/i2c/fcu.c:1.3 Wed Mar 21 15:41:34 2018
+++ src/sys/dev/i2c/fcu.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.3 2018/03/21 15:41:34 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 2018/03/21 15:41:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -124,15 +124,15 @@ static int
fcu_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name == NULL) {
- /* no ID registers on this chip */
- if (ia->ia_addr == 0x2f)
- return 1;
- return 0;
- } else {
- return iic_compat_match(ia, fcu_compats);
- }
+ if (iic_use_direct_match(ia, match, fcu_compats, &match_result))
+ return match_result;
+
+ if (ia->ia_addr == 0x2f)
+ return I2C_MATCH_ADDRESS_ONLY;
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/s390.c
diff -u src/sys/dev/i2c/s390.c:1.3 src/sys/dev/i2c/s390.c:1.4
--- src/sys/dev/i2c/s390.c:1.3 Thu Nov 20 16:34:26 2014
+++ src/sys/dev/i2c/s390.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: s390.c,v 1.3 2014/11/20 16:34:26 christos Exp $ */
+/* $NetBSD: s390.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2011 Frank Wille.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: s390.c,v 1.3 2014/11/20 16:34:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: s390.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -66,16 +66,15 @@ static int
s390rtc_match(device_t parent, cfdata_t cf, void *arg)
{
struct i2c_attach_args *ia = arg;
+ int match_result;
+
+ if (iic_use_direct_match(ia, cf, NULL, &match_result))
+ return match_result;
+
+ /* indirect config - check typical address */
+ if (ia->ia_addr == S390_ADDR)
+ return I2C_MATCH_ADDRESS_ONLY;
- if (ia->ia_name) {
- /* direct config - check name */
- if (strcmp(ia->ia_name, "s390rtc") == 0)
- return 1;
- } else {
- /* indirect config - check typical address */
- if (ia->ia_addr == S390_ADDR)
- return 1;
- }
return 0;
}
Index: src/sys/dev/i2c/si70xx.c
diff -u src/sys/dev/i2c/si70xx.c:1.3 src/sys/dev/i2c/si70xx.c:1.4
--- src/sys/dev/i2c/si70xx.c:1.3 Sat Dec 30 03:18:26 2017
+++ src/sys/dev/i2c/si70xx.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: si70xx.c,v 1.3 2017/12/30 03:18:26 christos Exp $ */
+/* $NetBSD: si70xx.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2017 Brad Spencer <[email protected]>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.3 2017/12/30 03:18:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $");
/*
Driver for the Silicon Labs SI7013/SI7020/SI7021
@@ -563,21 +563,16 @@ si70xx_sysctl_init(struct si70xx_sc *sc)
static int
si70xx_match(device_t parent, cfdata_t match, void *aux)
{
- struct i2c_attach_args *ia;
- int error;
+ struct i2c_attach_args *ia = aux;
+ int error, match_result;
const bool matchdebug = false;
- 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, "si70xxtemp") != 0)
- return 0;
- } else {
- /* indirect config - check for configured address */
- if (ia->ia_addr != SI70XX_TYPICAL_ADDR)
- return 0;
- }
+ /* indirect config - check for configured address */
+ if (ia->ia_addr != SI70XX_TYPICAL_ADDR)
+ return 0;
/*
* Check to see if something is really at this i2c address. This will
@@ -592,7 +587,7 @@ si70xx_match(device_t parent, cfdata_t m
error = si70xx_poke(ia->ia_tag, ia->ia_addr, matchdebug);
iic_release_bus(ia->ia_tag, 0);
- return error == 0;
+ return error == 0 ? I2C_MATCH_ADDRESS_AND_PROBE : 0;
}
static void
Index: src/sys/dev/i2c/tsl256x.c
diff -u src/sys/dev/i2c/tsl256x.c:1.3 src/sys/dev/i2c/tsl256x.c:1.4
--- src/sys/dev/i2c/tsl256x.c:1.3 Thu Jun 7 05:54:23 2018
+++ src/sys/dev/i2c/tsl256x.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: tsl256x.c,v 1.3 2018/06/07 05:54:23 thorpej Exp $ */
+/* $NetBSD: tsl256x.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2018 Jason R. Thorpe
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tsl256x.c,v 1.3 2018/06/07 05:54:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsl256x.c,v 1.4 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -110,38 +110,35 @@ tsllux_match(device_t parent, cfdata_t m
{
struct i2c_attach_args *ia = aux;
uint8_t id_reg;
- int error;
+ int error, match_result;
- if (ia->ia_name == NULL) {
- switch (ia->ia_addr) {
- case TSL256x_SLAVEADDR_GND:
- case TSL256x_SLAVEADDR_FLOAT:
- case TSL256x_SLAVEADDR_VDD:
- break;
+ if (iic_use_direct_match(ia, match, tsllux_compats, &match_result))
+ return (match_result);
- default:
- return (0);
- }
+ switch (ia->ia_addr) {
+ case TSL256x_SLAVEADDR_GND:
+ case TSL256x_SLAVEADDR_FLOAT:
+ case TSL256x_SLAVEADDR_VDD:
+ break;
- if (iic_acquire_bus(ia->ia_tag, I2C_F_POLL) != 0)
- return (0);
- error = iic_smbus_read_byte(ia->ia_tag, ia->ia_addr,
- TSL256x_REG_ID | COMMAND_CMD, &id_reg, I2C_F_POLL);
- iic_release_bus(ia->ia_tag, I2C_F_POLL);
+ default:
+ return (0);
+ }
- if (error)
- return (0);
+ if (iic_acquire_bus(ia->ia_tag, I2C_F_POLL) != 0)
+ return (0);
+ error = iic_smbus_read_byte(ia->ia_tag, ia->ia_addr,
+ TSL256x_REG_ID | COMMAND_CMD, &id_reg, I2C_F_POLL);
+ iic_release_bus(ia->ia_tag, I2C_F_POLL);
- /*
- * XXX This loses if we have a 2560 rev. 0.
- */
- if (id_reg == 0)
- return (0);
+ if (error)
+ return (0);
- return (1);
- } else {
- return iic_compat_match(ia, tsllux_compats);
- }
+ /* XXX This loses if we have a 2560 rev. 0. */
+ if (id_reg == 0)
+ return (I2C_MATCH_ADDRESS_ONLY);
+
+ return (I2C_MATCH_ADDRESS_AND_PROBE);
}
static void
@@ -517,7 +514,7 @@ static int
tsllux_write2(struct tsllux_softc *sc, uint8_t reg, uint16_t val)
{
reg = (reg & REGMASK) | COMMAND_CMD | COMMAND_WORD;
- return (iic_smbus_write_byte(sc->sc_i2c, sc->sc_addr, reg, val,
+ return (iic_smbus_write_word(sc->sc_i2c, sc->sc_addr, reg, val,
sc->sc_i2c_flags));
}
#endif
Index: src/sys/dev/i2c/adm1021.c
diff -u src/sys/dev/i2c/adm1021.c:1.16 src/sys/dev/i2c/adm1021.c:1.17
--- src/sys/dev/i2c/adm1021.c:1.16 Fri Sep 29 14:17:47 2017
+++ src/sys/dev/i2c/adm1021.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: adm1021.c,v 1.16 2017/09/29 14:17:47 macallan Exp $ */
+/* $NetBSD: adm1021.c,v 1.17 2018/06/16 21:22:13 thorpej Exp $ */
/* $OpenBSD: adm1021.c,v 1.27 2007/06/24 05:34:35 dlg Exp $ */
/*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.16 2017/09/29 14:17:47 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.17 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -162,29 +162,19 @@ int
admtemp_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name == NULL) {
- /*
- * Indirect config - not much we can do!
- * Check typical addresses.
- */
- if (((ia->ia_addr >= 0x18) && (ia->ia_addr <= 0x1a)) ||
- ((ia->ia_addr >= 0x29) && (ia->ia_addr <= 0x2b)) ||
- ((ia->ia_addr >= 0x48) && (ia->ia_addr <= 0x4e)))
- return (1);
- } else {
- /*
- * Direct config - match via the list of compatible
- * hardware or simply match the device name.
- */
- if (ia->ia_ncompat > 0) {
- if (iic_compat_match(ia, admtemp_compats))
- return 1;
- } else {
- if (strcmp(ia->ia_name, "admtemp") == 0)
- return 1;
- }
- }
+ if (iic_use_direct_match(ia, match, admtemp_compats, &match_result))
+ return match_result;
+
+ /*
+ * Indirect config - not much we can do!
+ * Check typical addresses.
+ */
+ if (((ia->ia_addr >= 0x18) && (ia->ia_addr <= 0x1a)) ||
+ ((ia->ia_addr >= 0x29) && (ia->ia_addr <= 0x2b)) ||
+ ((ia->ia_addr >= 0x48) && (ia->ia_addr <= 0x4e)))
+ return I2C_MATCH_ADDRESS_ONLY;
return 0;
}
Index: src/sys/dev/i2c/adm1026.c
diff -u src/sys/dev/i2c/adm1026.c:1.2 src/sys/dev/i2c/adm1026.c:1.3
--- src/sys/dev/i2c/adm1026.c:1.2 Mon Jan 11 18:23:52 2016
+++ src/sys/dev/i2c/adm1026.c Sat Jun 16 21:22:13 2018
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.2 2016/01/11 18:23:52 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -132,22 +132,18 @@ adm1026_match(device_t parent, cfdata_t
{
struct i2c_attach_args *ia = aux;
struct adm1026_softc sc; /* For chip ident */
+ int match_result;
+
sc.sc_tag = ia->ia_tag;
sc.sc_address = ia->ia_addr;
sc.sc_iic_flags = 0;
- /* Direct config - match compats */
- if (ia->ia_name) {
- if (ia->ia_ncompat > 0) {
- if (iic_compat_match(ia, adm1026_compats))
- return 1;
- }
- /* Indirect config - check address and chip ID/rev. */
- } else {
- if ((ia->ia_addr & ADM1026_ADDRMASK) == ADM1026_ADDR &&
- adm1026_ident(&sc))
- return 1;
- }
+ if (iic_use_direct_match(ia, cf, adm1026_compats, &match_result))
+ return match_result;
+
+ if ((ia->ia_addr & ADM1026_ADDRMASK) == ADM1026_ADDR &&
+ adm1026_ident(&sc))
+ return I2C_MATCH_ADDRESS_AND_PROBE;
return 0;
}
Index: src/sys/dev/i2c/am2315.c
diff -u src/sys/dev/i2c/am2315.c:1.2 src/sys/dev/i2c/am2315.c:1.3
--- src/sys/dev/i2c/am2315.c:1.2 Sat Dec 30 03:18:26 2017
+++ src/sys/dev/i2c/am2315.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: am2315.c,v 1.2 2017/12/30 03:18:26 christos Exp $ */
+/* $NetBSD: am2315.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2017 Brad Spencer <[email protected]>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: am2315.c,v 1.2 2017/12/30 03:18:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am2315.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $");
/*
* Driver for the Aosong AM2315
@@ -170,42 +170,19 @@ am2315_poke_m(i2c_tag_t tag, i2c_addr_t
static int
am2315_match(device_t parent, cfdata_t match, void *aux)
{
- struct i2c_attach_args *ia;
+ struct i2c_attach_args *ia = aux;
int rv;
const bool matchdebug = false;
+ 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, "am2315temp") != 0)
- return 0;
- } else {
- /* indirect config - check for configured address */
- if (ia->ia_addr != AM2315_TYPICAL_ADDR)
- return 0;
- }
-
- /*
- * Check to see if something is really at this i2c address. This will
- * keep phantom devices from appearing
- */
- if (iic_acquire_bus(ia->ia_tag, 0) != 0) {
- if (matchdebug)
- printf("in match acquire bus failed\n");
- return 0;
- }
+ /* indirect config - check for standard address */
+ if (ia->ia_addr == AM2315_TYPICAL_ADDR)
+ return I2C_MATCH_ADDRESS_ONLY;
- if ((rv = am2315_poke_m(ia->ia_tag, ia->ia_addr, __func__, matchdebug))
- != 0) {
- if (matchdebug)
- printf("match rv poke %d\n", rv);
- iic_release_bus(ia->ia_tag, 0);
- return 0;
- }
-
- iic_release_bus(ia->ia_tag, 0);
- return 1;
+ return 0;
}
static void
Index: src/sys/dev/i2c/ihidev.c
diff -u src/sys/dev/i2c/ihidev.c:1.2 src/sys/dev/i2c/ihidev.c:1.3
--- src/sys/dev/i2c/ihidev.c:1.2 Tue Mar 20 12:14:52 2018
+++ src/sys/dev/i2c/ihidev.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ihidev.c,v 1.2 2018/03/20 12:14:52 bouyer Exp $ */
+/* $NetBSD: ihidev.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $ */
/* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */
/*-
@@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.2 2018/03/20 12:14:52 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -129,11 +129,11 @@ static int
ihidev_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args * const ia = aux;
+ int match_result;
+
+ if (iic_use_direct_match(ia, match, ihidev_compats, &match_result))
+ return I2C_MATCH_DIRECT_COMPATIBLE;
- if (ia->ia_ncompat > 0) {
- if (iic_compat_match(ia, ihidev_compats))
- return 1;
- }
return 0;
}
Index: src/sys/dev/i2c/max77620.c
diff -u src/sys/dev/i2c/max77620.c:1.2 src/sys/dev/i2c/max77620.c:1.3
--- src/sys/dev/i2c/max77620.c:1.2 Thu Sep 28 13:08:00 2017
+++ src/sys/dev/i2c/max77620.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: max77620.c,v 1.2 2017/09/28 13:08:00 jmcneill Exp $ */
+/* $NetBSD: max77620.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: max77620.c,v 1.2 2017/09/28 13:08:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: max77620.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -258,11 +258,12 @@ static int
max77620_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name == NULL)
- return 0;
+ if (iic_use_direct_match(ia, match, max77620_compats, match_result))
+ return match_result;
- return iic_compat_match(ia, max77620_compats);
+ return 0;
}
static void
Index: src/sys/dev/i2c/smscmon.c
diff -u src/sys/dev/i2c/smscmon.c:1.2 src/sys/dev/i2c/smscmon.c:1.3
--- src/sys/dev/i2c/smscmon.c:1.2 Mon Jun 20 20:16:19 2011
+++ src/sys/dev/i2c/smscmon.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: smscmon.c,v 1.2 2011/06/20 20:16:19 pgoyette Exp $ */
+/* $NetBSD: smscmon.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2009 Takahiro Hayashi
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smscmon.c,v 1.2 2011/06/20 20:16:19 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smscmon.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -183,7 +183,7 @@ smscmon_match(device_t parent, cfdata_t
}
iic_release_bus(ia->ia_tag, 0);
- return 1;
+ return I2C_MATCH_ADDRESS_AND_PROBE;
}
static void
Index: src/sys/dev/i2c/w83795g.c
diff -u src/sys/dev/i2c/w83795g.c:1.2 src/sys/dev/i2c/w83795g.c:1.3
--- src/sys/dev/i2c/w83795g.c:1.2 Sun Apr 13 12:42:47 2014
+++ src/sys/dev/i2c/w83795g.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: w83795g.c,v 1.2 2014/04/13 12:42:47 christos Exp $ */
+/* $NetBSD: w83795g.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2013 Soren S. Jorvang. All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: w83795g.c,v 1.2 2014/04/13 12:42:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: w83795g.c,v 1.3 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -155,7 +155,7 @@ w83795g_match(device_t parent, cfdata_t
if ((bank & BANKSEL_HBACS && vend == VENDOR_NUVOTON_ID_HI) ||
(~bank & BANKSEL_HBACS && vend == VENDOR_NUVOTON_ID_LO))
if (chip == CHIP_W83795G && deva == DEVICEA_A)
- return 1;
+ return I2C_MATCH_ADDRESS_AND_PROBE;
return 0;
}
Index: src/sys/dev/i2c/as3722.c
diff -u src/sys/dev/i2c/as3722.c:1.12 src/sys/dev/i2c/as3722.c:1.13
--- src/sys/dev/i2c/as3722.c:1.12 Sun May 28 15:55:11 2017
+++ src/sys/dev/i2c/as3722.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: as3722.c,v 1.12 2017/05/28 15:55:11 jmcneill Exp $ */
+/* $NetBSD: as3722.c,v 1.13 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <[email protected]>
@@ -29,7 +29,7 @@
#include "opt_fdt.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.12 2017/05/28 15:55:11 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.13 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -51,6 +51,8 @@ __KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1
#include <dev/fdt/fdtvar.h>
#endif
+#define AS3722_I2C_ADDR 0x40
+
#define AS3722_START_YEAR 2000
#define AS3722_SD0_VOLTAGE_REG 0x00
@@ -230,22 +232,24 @@ as3722_match(device_t parent, cfdata_t m
{
struct i2c_attach_args *ia = aux;
uint8_t reg, id1;
- int error;
+ int error, match_result;
- if (ia->ia_name == NULL) {
- iic_acquire_bus(ia->ia_tag, I2C_F_POLL);
- reg = AS3722_ASIC_ID1_REG;
- error = iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
- ®, 1, &id1, 1, I2C_F_POLL);
- iic_release_bus(ia->ia_tag, I2C_F_POLL);
+ if (iic_use_direct_match(ia, match, as3722_compats, &match_result))
+ return match_result;
+
+ if (ia->ia_addr != AS3722_I2C_ADDR)
+ return 0;
+
+ iic_acquire_bus(ia->ia_tag, I2C_F_POLL);
+ reg = AS3722_ASIC_ID1_REG;
+ error = iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
+ ®, 1, &id1, 1, I2C_F_POLL);
+ iic_release_bus(ia->ia_tag, I2C_F_POLL);
- if (error == 0 && id1 == 0x0c)
- return 1;
+ if (error == 0 && id1 == 0x0c)
+ return I2C_MATCH_ADDRESS_AND_PROBE;
- return 0;
- } else {
- return iic_compat_match(ia, as3722_compats);
- }
+ return 0;
}
static void
Index: src/sys/dev/i2c/at24cxx.c
diff -u src/sys/dev/i2c/at24cxx.c:1.25 src/sys/dev/i2c/at24cxx.c:1.26
--- src/sys/dev/i2c/at24cxx.c:1.25 Sat Oct 28 04:53:55 2017
+++ src/sys/dev/i2c/at24cxx.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: at24cxx.c,v 1.25 2017/10/28 04:53:55 riastradh Exp $ */
+/* $NetBSD: at24cxx.c,v 1.26 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.25 2017/10/28 04:53:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.26 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -131,21 +131,15 @@ static int
seeprom_match(device_t parent, cfdata_t cf, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name) {
- if (ia->ia_ncompat > 0) {
- if (iic_compat_match(ia, seeprom_compats))
- return (1);
- } else {
- if (strcmp(ia->ia_name, "seeprom") == 0)
- return (1);
- }
- } else {
- if ((ia->ia_addr & AT24CXX_ADDRMASK) == AT24CXX_ADDR)
- return (1);
- }
+ if (iic_use_direct_match(ia, cf, seeprom_compats, &match_result))
+ return match_result;
- return (0);
+ if ((ia->ia_addr & AT24CXX_ADDRMASK) == AT24CXX_ADDR)
+ return I2C_MATCH_ADDRESS_ONLY;
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/axp20x.c
diff -u src/sys/dev/i2c/axp20x.c:1.10 src/sys/dev/i2c/axp20x.c:1.11
--- src/sys/dev/i2c/axp20x.c:1.10 Sun Oct 22 11:00:28 2017
+++ src/sys/dev/i2c/axp20x.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: axp20x.c,v 1.10 2017/10/22 11:00:28 jmcneill Exp $ */
+/* $NetBSD: axp20x.c,v 1.11 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2014-2017 Jared McNeill <[email protected]>
@@ -29,7 +29,7 @@
#include "opt_fdt.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: axp20x.c,v 1.10 2017/10/22 11:00:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axp20x.c,v 1.11 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -47,6 +47,8 @@ __KERNEL_RCSID(0, "$NetBSD: axp20x.c,v 1
#include <dev/fdt/fdtvar.h>
#endif
+#define AXP209_I2C_ADDR 0x34
+
#define AXP_INPUT_STATUS 0x00
#define AXP_INPUT_STATUS_AC_PRESENT __BIT(7)
#define AXP_INPUT_STATUS_AC_OK __BIT(6)
@@ -221,11 +223,14 @@ static int
axp20x_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args * const ia = aux;
+ int match_result;
+
+ if (iic_use_direct_match(ia, match, compatible, &match_result))
+ return match_result;
- if (ia->ia_name != NULL)
- return iic_compat_match(ia, compatible);
+ /* This device is direct-config only. */
- return 1;
+ return 0;
}
static void
Index: src/sys/dev/i2c/axppmic.c
diff -u src/sys/dev/i2c/axppmic.c:1.10 src/sys/dev/i2c/axppmic.c:1.11
--- src/sys/dev/i2c/axppmic.c:1.10 Sat May 26 14:39:20 2018
+++ src/sys/dev/i2c/axppmic.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.10 2018/05/26 14:39:20 jmcneill Exp $ */
+/* $NetBSD: axppmic.c,v 1.11 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2014-2018 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.10 2018/05/26 14:39:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.11 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -679,14 +679,25 @@ axppmic_match(device_t parent, cfdata_t
{
struct i2c_attach_args *ia = aux;
+ /* XXXJRT Gross. */
if (ia->ia_name != NULL) {
- if (ia->ia_cookie)
- return of_match_compat_data(ia->ia_cookie, compat_data);
- else
+ if (ia->ia_cookie) {
+ int match_result =
+ of_match_compat_data(ia->ia_cookie, compat_data);
+ if (match_result) {
+ match_result = match_result - 1 +
+ I2C_MATCH_DIRECT_COMPATIBLE;
+ match_result = MIN(match_result,
+ I2C_MATCH_DIRECT_COMPATIBLE_MAX);
+ }
+ return match_result;
+ } else
return 0;
}
- return 1;
+ /* This device is direct-config only. */
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/dbcool.c
diff -u src/sys/dev/i2c/dbcool.c:1.48 src/sys/dev/i2c/dbcool.c:1.49
--- src/sys/dev/i2c/dbcool.c:1.48 Tue Feb 6 10:02:09 2018
+++ src/sys/dev/i2c/dbcool.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dbcool.c,v 1.48 2018/02/06 10:02:09 mrg Exp $ */
+/* $NetBSD: dbcool.c,v 1.49 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.48 2018/02/06 10:02:09 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.49 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -748,20 +748,16 @@ dbcool_match(device_t parent, cfdata_t c
dc.dc_chip = NULL;
dc.dc_readreg = dbcool_readreg;
dc.dc_writereg = dbcool_writereg;
+ int match_result;
+
+ if (iic_use_direct_match(ia, cf, dbcool_compats, &match_result))
+ return match_result;
+
+ if ((ia->ia_addr & DBCOOL_ADDRMASK) != DBCOOL_ADDR)
+ return 0;
+ if (dbcool_chip_ident(&dc) >= 0)
+ return I2C_MATCH_ADDRESS_AND_PROBE;
- /* Direct config - match compats */
- if (ia->ia_name) {
- if (ia->ia_ncompat > 0) {
- if (iic_compat_match(ia, dbcool_compats))
- return 1;
- }
- /* Indirect config - check address and chip ID */
- } else {
- if ((ia->ia_addr & DBCOOL_ADDRMASK) != DBCOOL_ADDR)
- return 0;
- if (dbcool_chip_ident(&dc) >= 0)
- return 1;
- }
return 0;
}
Index: src/sys/dev/i2c/ddc.c
diff -u src/sys/dev/i2c/ddc.c:1.6 src/sys/dev/i2c/ddc.c:1.7
--- src/sys/dev/i2c/ddc.c:1.6 Sat Jul 25 15:20:49 2015
+++ src/sys/dev/i2c/ddc.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ddc.c,v 1.6 2015/07/25 15:20:49 jmcneill Exp $ */
+/* $NetBSD: ddc.c,v 1.7 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ddc.c,v 1.6 2015/07/25 15:20:49 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddc.c,v 1.7 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -70,7 +70,7 @@ ddc_match(device_t parent, cfdata_t cf,
struct i2c_attach_args *ia = aux;
if (ia->ia_addr == DDC_ADDR)
- return 1;
+ return I2C_MATCH_ADDRESS_ONLY;
return 0;
}
Index: src/sys/dev/i2c/ibmhawk.c
diff -u src/sys/dev/i2c/ibmhawk.c:1.6 src/sys/dev/i2c/ibmhawk.c:1.7
--- src/sys/dev/i2c/ibmhawk.c:1.6 Wed Jun 6 01:49:08 2018
+++ src/sys/dev/i2c/ibmhawk.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ibmhawk.c,v 1.6 2018/06/06 01:49:08 maya Exp $ */
+/* $NetBSD: ibmhawk.c,v 1.7 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -109,7 +109,8 @@ ibmhawk_match(device_t parent, cfdata_t
sc.sc_addr = ia->ia_addr;
if (ibmhawk_request(&sc, IHR_EQUIP, &resp))
return 0;
- return 1;
+
+ return I2C_MATCH_ADDRESS_AND_PROBE;
}
static void
Index: src/sys/dev/i2c/tcakp.c
diff -u src/sys/dev/i2c/tcakp.c:1.6 src/sys/dev/i2c/tcakp.c:1.7
--- src/sys/dev/i2c/tcakp.c:1.6 Mon Apr 30 20:33:09 2018
+++ src/sys/dev/i2c/tcakp.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: tcakp.c,v 1.6 2018/04/30 20:33:09 jmcneill Exp $ */
+/* $NetBSD: tcakp.c,v 1.7 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <[email protected]>
@@ -29,7 +29,7 @@
#include "opt_fdt.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcakp.c,v 1.6 2018/04/30 20:33:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcakp.c,v 1.7 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -316,13 +316,15 @@ static int
tcakp_match(device_t parent, cfdata_t match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
- if (ia->ia_name == NULL) {
- if (ia->ia_addr == 0x34)
- return 1;
- return 0;
- } else
- return iic_compat_match(ia, tcakp_compats);
+ if (iic_use_direct_match(ia, match, tcakp_compats, &match_result))
+ return match_result;
+
+ if (ia->ia_addr == 0x34)
+ return I2C_MATCH_ADDRESS_ONLY;
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/i2c.c
diff -u src/sys/dev/i2c/i2c.c:1.61 src/sys/dev/i2c/i2c.c:1.62
--- src/sys/dev/i2c/i2c.c:1.61 Thu Jun 7 13:30:49 2018
+++ src/sys/dev/i2c/i2c.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: i2c.c,v 1.61 2018/06/07 13:30:49 thorpej Exp $ */
+/* $NetBSD: i2c.c,v 1.62 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.61 2018/06/07 13:30:49 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.62 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -109,8 +109,9 @@ iic_print_direct(void *aux, const char *
struct i2c_attach_args *ia = aux;
if (pnp != NULL)
- aprint_normal("%s at %s addr 0x%02x", ia->ia_name, pnp,
- ia->ia_addr);
+ aprint_normal("%s at %s addr 0x%02x",
+ ia->ia_name ? ia->ia_name : "(unknown)",
+ pnp, ia->ia_addr);
else
aprint_normal(" addr 0x%02x", ia->ia_addr);
@@ -452,8 +453,10 @@ iic_attach(device_t parent, device_t sel
dev = prop_array_get(child_devices, i);
if (!dev) continue;
if (!prop_dictionary_get_cstring_nocopy(
- dev, "name", &name))
- continue;
+ dev, "name", &name)) {
+ /* "name" property is optional. */
+ name = NULL;
+ }
if (!prop_dictionary_get_uint32(dev, "addr", &addr))
continue;
if (!prop_dictionary_get_uint64(dev, "cookie", &cookie))
@@ -480,14 +483,21 @@ iic_attach(device_t parent, device_t sel
prop_data_data_nocopy(cdata),
prop_data_size(cdata), &buf);
- if (addr > I2C_MAX_ADDR) {
+ if (name == NULL && cdata == NULL) {
aprint_error_dev(self,
- "WARNING: ignoring bad device address "
- "@ 0x%02x\n", addr);
- } else if (sc->sc_devices[addr] == NULL) {
- sc->sc_devices[addr] =
- config_found_sm_loc(self, "iic", loc, &ia,
- iic_print_direct, NULL);
+ "WARNING: ignoring bad child device entry "
+ "for address 0x%02x\n", addr);
+ } else {
+ if (addr > I2C_MAX_ADDR) {
+ aprint_error_dev(self,
+ "WARNING: ignoring bad device "
+ "address @ 0x%02x\n", addr);
+ } else if (sc->sc_devices[addr] == NULL) {
+ sc->sc_devices[addr] =
+ config_found_sm_loc(self, "iic",
+ loc, &ia, iic_print_direct,
+ NULL);
+ }
}
if (ia.ia_compat)
@@ -680,18 +690,58 @@ iic_fill_compat(struct i2c_attach_args *
ia->ia_ncompat = count;
}
+/*
+ * iic_compat_match --
+ * Match a device's "compatible" property against the list
+ * of compatible strings provided by the driver. Note that
+ * we weight the match to the reverse index of the device's
+ * "compatible" property strings so that a driver that matches
+ * an lower-indexed "compatible" property is given a higher
+ * match priority than one that matches a higher-indexed
+ * "compatible" property.
+ */
int
-iic_compat_match(struct i2c_attach_args *ia, const char ** compats)
+iic_compat_match(const struct i2c_attach_args *ia, const char **compats)
{
- int i;
+ int match_result = 0, i, ri;
+
+ if (ia->ia_ncompat == 0 || ia->ia_compat == NULL)
+ return 0;
for (; compats && *compats; compats++) {
- for (i = 0; i < ia->ia_ncompat; i++) {
- if (strcmp(*compats, ia->ia_compat[i]) == 0)
- return 1;
+ for (i = 0, ri = ia->ia_ncompat - 1;
+ i < ia->ia_ncompat;
+ i++, ri--) {
+ if (strcmp(*compats, ia->ia_compat[i]) == 0) {
+ KASSERT(ri >= 0);
+ match_result =
+ I2C_MATCH_DIRECT_COMPATIBLE + ri;
+ }
}
}
- return 0;
+ match_result = MIN(match_result, I2C_MATCH_DIRECT_COMPATIBLE_MAX);
+ return match_result;
+}
+
+bool
+iic_use_direct_match(const struct i2c_attach_args *ia, const cfdata_t cf,
+ const char **compats, int *match_resultp)
+{
+
+ KASSERT(match_resultp != NULL);
+
+ if (ia->ia_name != NULL &&
+ strcmp(ia->ia_name, cf->cf_name) == 0) {
+ *match_resultp = I2C_MATCH_DIRECT_SPECIFIC;
+ return true;
+ }
+
+ if (ia->ia_ncompat > 0 && ia->ia_compat != NULL) {
+ *match_resultp = iic_compat_match(ia, compats);
+ return true;
+ }
+
+ return false;
}
static int
Index: src/sys/dev/i2c/i2cvar.h
diff -u src/sys/dev/i2c/i2cvar.h:1.13 src/sys/dev/i2c/i2cvar.h:1.14
--- src/sys/dev/i2c/i2cvar.h:1.13 Thu Jun 7 13:30:49 2018
+++ src/sys/dev/i2c/i2cvar.h Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: i2cvar.h,v 1.13 2018/06/07 13:30:49 thorpej Exp $ */
+/* $NetBSD: i2cvar.h,v 1.14 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -38,6 +38,7 @@
#ifndef _DEV_I2C_I2CVAR_H_
#define _DEV_I2C_I2CVAR_H_
+#include <sys/device.h>
#include <dev/i2c/i2c_io.h>
#include <prop/proplib.h>
@@ -159,7 +160,13 @@ struct i2c_attach_args {
* API presented to i2c controllers.
*/
int iicbus_print(void *, const char *);
-int iic_compat_match(struct i2c_attach_args*, const char **);
+
+/*
+ * API presented to i2c devices.
+ */
+int iic_compat_match(const struct i2c_attach_args *, const char **);
+bool iic_use_direct_match(const struct i2c_attach_args *,
+ const cfdata_t, const char **, int *);
/*
* Constants to indicate the quality of a match made by a driver's
@@ -176,7 +183,8 @@ int iic_compat_match(struct i2c_attach_a
#define I2C_MATCH_ADDRESS_ONLY 1
#define I2C_MATCH_ADDRESS_AND_PROBE 2
#define I2C_MATCH_DIRECT_COMPATIBLE 10
-#define I2C_MATCH_DIRECT_SPECIFIC 50
+#define I2C_MATCH_DIRECT_COMPATIBLE_MAX 99
+#define I2C_MATCH_DIRECT_SPECIFIC 100
#ifdef _I2C_PRIVATE
/*
Index: src/sys/dev/i2c/lm75.c
diff -u src/sys/dev/i2c/lm75.c:1.30 src/sys/dev/i2c/lm75.c:1.31
--- src/sys/dev/i2c/lm75.c:1.30 Sun Oct 1 05:12:18 2017
+++ src/sys/dev/i2c/lm75.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: lm75.c,v 1.30 2017/10/01 05:12:18 macallan Exp $ */
+/* $NetBSD: lm75.c,v 1.31 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.30 2017/10/01 05:12:18 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.31 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -146,35 +146,23 @@ static int
lmtemp_match(device_t parent, cfdata_t cf, void *aux)
{
struct i2c_attach_args *ia = aux;
- int i;
-
- if (ia->ia_name == NULL) {
- /*
- * Indirect config - not much we can do!
- */
- for (i = 0; lmtemptbl[i].lmtemp_type != -1 ; i++)
- if (lmtemptbl[i].lmtemp_type == cf->cf_flags)
- break;
- if (lmtemptbl[i].lmtemp_type == -1)
- return 0;
+ int i, match_result;
- if ((ia->ia_addr & lmtemptbl[i].lmtemp_addrmask) ==
- lmtemptbl[i].lmtemp_addr)
- return 1;
- } else {
- /*
- * Direct config - match via the list of compatible
- * hardware or simply match the device name.
- */
- if (ia->ia_ncompat > 0) {
- if (iic_compat_match(ia, lmtemp_compats))
- return 1;
- } else {
- if (strcmp(ia->ia_name, "lmtemp") == 0)
- return 1;
- }
- }
+ if (iic_use_direct_match(ia, cf, lmtemp_compats, &match_result))
+ return match_result;
+ /*
+ * Indirect config - not much we can do!
+ */
+ for (i = 0; lmtemptbl[i].lmtemp_type != -1 ; i++)
+ if (lmtemptbl[i].lmtemp_type == cf->cf_flags)
+ break;
+ if (lmtemptbl[i].lmtemp_type == -1)
+ return 0;
+
+ if ((ia->ia_addr & lmtemptbl[i].lmtemp_addrmask) ==
+ lmtemptbl[i].lmtemp_addr)
+ return I2C_MATCH_ADDRESS_ONLY;
return 0;
}
Index: src/sys/dev/i2c/lm87.c
diff -u src/sys/dev/i2c/lm87.c:1.7 src/sys/dev/i2c/lm87.c:1.8
--- src/sys/dev/i2c/lm87.c:1.7 Sun Jan 10 14:03:11 2016
+++ src/sys/dev/i2c/lm87.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: lm87.c,v 1.7 2016/01/10 14:03:11 jdc Exp $ */
+/* $NetBSD: lm87.c,v 1.8 2018/06/16 21:22:13 thorpej Exp $ */
/* $OpenBSD: lm87.c,v 1.20 2008/11/10 05:19:48 cnst Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm87.c,v 1.7 2016/01/10 14:03:11 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm87.c,v 1.8 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -149,41 +149,30 @@ lmenv_match(device_t parent, cfdata_t ma
{
struct i2c_attach_args *ia = aux;
u_int8_t cmd, val;
- int error, i;
+ int error, i, match_result;
- if (ia->ia_name == NULL) {
- /*
- * Indirect config - not much we can do!
- * Check typical addresses and read the Company ID register
- */
- if ((ia->ia_addr < 0x2c) || (ia->ia_addr > 0x2f))
- return 0;
-
- cmd = LM87_COMPANY_ID;
- iic_acquire_bus(ia->ia_tag, 0);
- error = iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
- &cmd, 1, &val, 1, I2C_F_POLL);
- iic_release_bus(ia->ia_tag, 0);
-
- if (error)
- return 0;
-
- for (i = 0; lmenv_ids[i].id != 0; i++)
- if (lmenv_ids[i].id == val)
- return 1;
- } else {
- /*
- * Direct config - match via the list of compatible
- * hardware or simply match the device name.
- */
- if (ia->ia_ncompat > 0) {
- if (iic_compat_match(ia, lmenv_compats))
- return 1;
- } else {
- if (strcmp(ia->ia_name, "lmenv") == 0)
- return 1;
- }
- }
+ if (iic_use_direct_match(ia, match, lmenv_compats, &match_result))
+ return match_result;
+
+ /*
+ * Indirect config - not much we can do!
+ * Check typical addresses and read the Company ID register
+ */
+ if ((ia->ia_addr < 0x2c) || (ia->ia_addr > 0x2f))
+ return 0;
+
+ cmd = LM87_COMPANY_ID;
+ iic_acquire_bus(ia->ia_tag, 0);
+ error = iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
+ &cmd, 1, &val, 1, I2C_F_POLL);
+ iic_release_bus(ia->ia_tag, 0);
+
+ if (error)
+ return 0;
+
+ for (i = 0; lmenv_ids[i].id != 0; i++)
+ if (lmenv_ids[i].id == val)
+ return I2C_MATCH_ADDRESS_AND_PROBE;
return 0;
}
Index: src/sys/dev/i2c/r2025.c
diff -u src/sys/dev/i2c/r2025.c:1.7 src/sys/dev/i2c/r2025.c:1.8
--- src/sys/dev/i2c/r2025.c:1.7 Thu Nov 20 16:34:26 2014
+++ src/sys/dev/i2c/r2025.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: r2025.c,v 1.7 2014/11/20 16:34:26 christos Exp $ */
+/* $NetBSD: r2025.c,v 1.8 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2006 Shigeyuki Fukushima.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: r2025.c,v 1.7 2014/11/20 16:34:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: r2025.c,v 1.8 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -76,7 +76,7 @@ r2025rtc_match(device_t parent, cfdata_t
/* match only R2025 RTC devices */
if (ia->ia_addr == R2025_ADDR)
- return 1;
+ return I2C_MATCH_ADDRESS_ONLY;
return 0;
}
Index: src/sys/dev/i2c/m41st84.c
diff -u src/sys/dev/i2c/m41st84.c:1.23 src/sys/dev/i2c/m41st84.c:1.24
--- src/sys/dev/i2c/m41st84.c:1.23 Sat Oct 28 04:53:55 2017
+++ src/sys/dev/i2c/m41st84.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: m41st84.c,v 1.23 2017/10/28 04:53:55 riastradh Exp $ */
+/* $NetBSD: m41st84.c,v 1.24 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.23 2017/10/28 04:53:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.24 2018/06/16 21:22:13 thorpej Exp $");
#include "opt_strtc.h"
@@ -102,16 +102,15 @@ static int
strtc_match(device_t parent, cfdata_t cf, void *arg)
{
struct i2c_attach_args *ia = arg;
+ int match_result;
+
+ if (iic_use_direct_match(ia, cf, NULL, &match_result))
+ return match_result;
+
+ /* indirect config - check typical address */
+ if (ia->ia_addr == M41ST84_ADDR)
+ return I2C_MATCH_ADDRESS_ONLY;
- if (ia->ia_name) {
- /* direct config - check name */
- if (strcmp(ia->ia_name, "strtc") == 0)
- return 1;
- } else {
- /* indirect config - check typical address */
- if (ia->ia_addr == M41ST84_ADDR)
- return 1;
- }
return 0;
}
Index: src/sys/dev/i2c/m41t00.c
diff -u src/sys/dev/i2c/m41t00.c:1.20 src/sys/dev/i2c/m41t00.c:1.21
--- src/sys/dev/i2c/m41t00.c:1.20 Sat Oct 28 04:53:55 2017
+++ src/sys/dev/i2c/m41t00.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: m41t00.c,v 1.20 2017/10/28 04:53:55 riastradh Exp $ */
+/* $NetBSD: m41t00.c,v 1.21 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: m41t00.c,v 1.20 2017/10/28 04:53:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m41t00.c,v 1.21 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -102,7 +102,7 @@ m41t00_match(device_t parent, cfdata_t c
struct i2c_attach_args *ia = aux;
if (ia->ia_addr == M41T00_ADDR) {
- return 1;
+ return I2C_MATCH_ADDRESS_ONLY;
}
return 0;
Index: src/sys/dev/i2c/x1226.c
diff -u src/sys/dev/i2c/x1226.c:1.20 src/sys/dev/i2c/x1226.c:1.21
--- src/sys/dev/i2c/x1226.c:1.20 Sat Oct 28 04:53:55 2017
+++ src/sys/dev/i2c/x1226.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: x1226.c,v 1.20 2017/10/28 04:53:55 riastradh Exp $ */
+/* $NetBSD: x1226.c,v 1.21 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2003 Shigeyuki Fukushima.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x1226.c,v 1.20 2017/10/28 04:53:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x1226.c,v 1.21 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -103,7 +103,7 @@ xrtc_match(device_t parent, cfdata_t cf,
/* match only this RTC devices */
if (ia->ia_addr == X1226_ADDR)
- return (1);
+ return (I2C_MATCH_ADDRESS_ONLY);
return (0);
}
Index: src/sys/dev/i2c/max6900.c
diff -u src/sys/dev/i2c/max6900.c:1.15 src/sys/dev/i2c/max6900.c:1.16
--- src/sys/dev/i2c/max6900.c:1.15 Thu Nov 20 16:34:26 2014
+++ src/sys/dev/i2c/max6900.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: max6900.c,v 1.15 2014/11/20 16:34:26 christos Exp $ */
+/* $NetBSD: max6900.c,v 1.16 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: max6900.c,v 1.15 2014/11/20 16:34:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: max6900.c,v 1.16 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -98,7 +98,7 @@ maxrtc_match(device_t parent, cfdata_t c
struct i2c_attach_args *ia = aux;
if ((ia->ia_addr & MAX6900_ADDRMASK) == MAX6900_ADDR)
- return (1);
+ return (I2C_MATCH_ADDRESS_ONLY);
return (0);
}
Index: src/sys/dev/i2c/mcp980x.c
diff -u src/sys/dev/i2c/mcp980x.c:1.5 src/sys/dev/i2c/mcp980x.c:1.6
--- src/sys/dev/i2c/mcp980x.c:1.5 Mon Oct 28 11:24:08 2013
+++ src/sys/dev/i2c/mcp980x.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: mcp980x.c,v 1.5 2013/10/28 11:24:08 rkujawa Exp $ */
+/* $NetBSD: mcp980x.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mcp980x.c,v 1.5 2013/10/28 11:24:08 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcp980x.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -106,12 +106,12 @@ CFATTACH_DECL_NEW(mcp980x, sizeof (struc
static int
mcp980x_match(device_t parent, cfdata_t cf, void *aux)
{
- /*
- * No sane way to probe? Perhaps at least try to match constant part
- * of the I2Caddress.
- */
- return 1;
+ if (ia->ia_addr >= MCP980X_ADDR_CONST &&
+ ia->ia_addr <= (MCP980X_ADDR_CONST + MCP980X_ADDR_VAR))
+ return I2C_MATCH_ADDRESS_ONLY;
+
+ return 0;
}
static void
Index: src/sys/dev/i2c/tps65950.c
diff -u src/sys/dev/i2c/tps65950.c:1.5 src/sys/dev/i2c/tps65950.c:1.6
--- src/sys/dev/i2c/tps65950.c:1.5 Thu Nov 20 16:34:26 2014
+++ src/sys/dev/i2c/tps65950.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: tps65950.c,v 1.5 2014/11/20 16:34:26 christos Exp $ */
+/* $NetBSD: tps65950.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2012 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tps65950.c,v 1.5 2014/11/20 16:34:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tps65950.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -131,7 +131,7 @@ tps65950_match(device_t parent, cfdata_t
case TPS65950_ADDR_ID3:
case TPS65950_ADDR_ID4:
case TPS65950_ADDR_ID5:
- return 1;
+ return I2C_MATCH_ADDRESS_ONLY;
default:
return 0;
}
Index: src/sys/dev/i2c/pcf8563.c
diff -u src/sys/dev/i2c/pcf8563.c:1.8 src/sys/dev/i2c/pcf8563.c:1.9
--- src/sys/dev/i2c/pcf8563.c:1.8 Sat Oct 7 20:18:16 2017
+++ src/sys/dev/i2c/pcf8563.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: pcf8563.c,v 1.8 2017/10/07 20:18:16 jmcneill Exp $ */
+/* $NetBSD: pcf8563.c,v 1.9 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2011 Jonathan A. Kollasch
@@ -32,7 +32,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcf8563.c,v 1.8 2017/10/07 20:18:16 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8563.c,v 1.9 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -76,15 +76,15 @@ static int
pcf8563rtc_match(device_t parent, cfdata_t cf, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int match_result;
+
+ if (iic_use_direct_match(ia, cf, compatible, &match_result))
+ return match_result;
+
+ /* indirect config - check typical address */
+ if (ia->ia_addr == PCF8563_ADDR)
+ return I2C_MATCH_ADDRESS_ONLY;
- if (ia->ia_name) {
- /* direct config - check name */
- return iic_compat_match(ia, compatible);
- } else {
- /* indirect config - check typical address */
- if (ia->ia_addr == PCF8563_ADDR)
- return 1;
- }
return 0;
}
Index: src/sys/dev/i2c/sgsmix.c
diff -u src/sys/dev/i2c/sgsmix.c:1.8 src/sys/dev/i2c/sgsmix.c:1.9
--- src/sys/dev/i2c/sgsmix.c:1.8 Fri Sep 22 04:07:34 2017
+++ src/sys/dev/i2c/sgsmix.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sgsmix.c,v 1.8 2017/09/22 04:07:34 macallan Exp $ */
+/* $NetBSD: sgsmix.c,v 1.9 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (C) 2005 Michael Lorenz.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sgsmix.c,v 1.8 2017/09/22 04:07:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sgsmix.c,v 1.9 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -81,21 +81,21 @@ sgsmix_match(device_t parent, cfdata_t c
struct i2c_attach_args *args = aux;
int ret = -1;
uint8_t out[2] = {1, 0x20};
+ int match_result;
- if (args->ia_name) {
- if (strcmp(args->ia_name, "sgsmix") == 0)
- return 1;
- } else {
- /* see if we can talk to something at address 0x8a */
- if (args->ia_addr == 0x8a) {
- iic_acquire_bus(args->ia_tag, 0);
- ret = iic_exec(args->ia_tag, I2C_OP_WRITE, args->ia_addr,
- out, 2, NULL, 0, 0);
- iic_release_bus(args->ia_tag, 0);
- }
- return (ret >= 0);
- }
- return 0;
+ if (iic_use_direct_match(args, cf, NULL, &match_result))
+ return match_result;
+
+ /* see if we can talk to something at address 0x8a */
+ if (args->ia_addr != 0x8a)
+ return 0;
+
+ iic_acquire_bus(args->ia_tag, 0);
+ ret = iic_exec(args->ia_tag, I2C_OP_WRITE, args->ia_addr,
+ out, 2, NULL, 0, 0);
+ iic_release_bus(args->ia_tag, 0);
+
+ return (ret >= 0) ? I2C_MATCH_ADDRESS_AND_PROBE : 0;
}
static void
Index: src/sys/dev/i2c/pcf8583.c
diff -u src/sys/dev/i2c/pcf8583.c:1.17 src/sys/dev/i2c/pcf8583.c:1.18
--- src/sys/dev/i2c/pcf8583.c:1.17 Sat Oct 28 04:53:55 2017
+++ src/sys/dev/i2c/pcf8583.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: pcf8583.c,v 1.17 2017/10/28 04:53:55 riastradh Exp $ */
+/* $NetBSD: pcf8583.c,v 1.18 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcf8583.c,v 1.17 2017/10/28 04:53:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8583.c,v 1.18 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -109,7 +109,7 @@ pcfrtc_match(device_t parent, cfdata_t c
struct i2c_attach_args *ia = aux;
if ((ia->ia_addr & PCF8583_ADDRMASK) == PCF8583_ADDR)
- return (1);
+ return (I2C_MATCH_ADDRESS_ONLY);
return (0);
}
Index: src/sys/dev/i2c/rs5c372.c
diff -u src/sys/dev/i2c/rs5c372.c:1.14 src/sys/dev/i2c/rs5c372.c:1.15
--- src/sys/dev/i2c/rs5c372.c:1.14 Thu Nov 20 16:34:26 2014
+++ src/sys/dev/i2c/rs5c372.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: rs5c372.c,v 1.14 2014/11/20 16:34:26 christos Exp $ */
+/* $NetBSD: rs5c372.c,v 1.15 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (C) 2005 NONAKA Kimihiro <[email protected]>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rs5c372.c,v 1.14 2014/11/20 16:34:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rs5c372.c,v 1.15 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -65,16 +65,15 @@ static int
rs5c372rtc_match(device_t parent, cfdata_t cf, void *arg)
{
struct i2c_attach_args *ia = arg;
+ int match_result;
+
+ if (iic_use_direct_match(ia, cf, NULL, &match_result))
+ return match_result;
+
+ /* indirect config - check typical address */
+ if (ia->ia_addr == RS5C372_ADDR)
+ return I2C_MATCH_ADDRESS_ONLY;
- if (ia->ia_name) {
- /* direct config - check name */
- if (strcmp(ia->ia_name, "rs5c372rtc") == 0)
- return 1;
- } else {
- /* indirect config - check typical address */
- if (ia->ia_addr == RS5C372_ADDR)
- return 1;
- }
return 0;
}
Index: src/sys/dev/i2c/spdmem_i2c.c
diff -u src/sys/dev/i2c/spdmem_i2c.c:1.14 src/sys/dev/i2c/spdmem_i2c.c:1.15
--- src/sys/dev/i2c/spdmem_i2c.c:1.14 Thu Mar 1 05:47:22 2018
+++ src/sys/dev/i2c/spdmem_i2c.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: spdmem_i2c.c,v 1.14 2018/03/01 05:47:22 pgoyette Exp $ */
+/* $NetBSD: spdmem_i2c.c,v 1.15 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2007 Nicolas Joly
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.14 2018/03/01 05:47:22 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.15 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -178,6 +178,15 @@ spdmem_i2c_match(device_t parent, cfdata
struct i2c_attach_args *ia = aux;
struct spdmem_i2c_softc sc;
+ /*
+ * XXXJRT
+ * Should do this with "compatible" strings. There are also
+ * other problems with this "match" routine. Specifically, if
+ * we are doing direct-config, we know the device is already
+ * there aren't do need to probe. I'll leave the logic for
+ * now and let someone who knows better clean it later.
+ */
+
if (ia->ia_name) {
/* add other names as we find more firmware variations */
if (strcmp(ia->ia_name, "dimm-spd") &&
@@ -201,7 +210,11 @@ spdmem_i2c_match(device_t parent, cfdata
if (spdmem_reset_page(&sc) != 0)
return 0;
- return spdmem_common_probe(&sc.sc_base);
+ if (spdmem_common_probe(&sc.sc_base)) {
+ return ia->ia_name ? I2C_MATCH_DIRECT_SPECIFIC
+ : I2C_MATCH_ADDRESS_AND_PROBE;
+ }
+ return 0;
}
static void
Index: src/sys/dev/i2c/sdtemp.c
diff -u src/sys/dev/i2c/sdtemp.c:1.33 src/sys/dev/i2c/sdtemp.c:1.34
--- src/sys/dev/i2c/sdtemp.c:1.33 Thu Feb 22 10:09:12 2018
+++ src/sys/dev/i2c/sdtemp.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sdtemp.c,v 1.33 2018/02/22 10:09:12 msaitoh Exp $ */
+/* $NetBSD: sdtemp.c,v 1.34 2018/06/16 21:22:13 thorpej Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.33 2018/02/22 10:09:12 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.34 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -240,7 +240,7 @@ sdtemp_match(device_t parent, cfdata_t c
if ((cap & SDTEMP_CAP_HAS_ALARM) == 0)
return 0;
- return 1;
+ return I2C_MATCH_ADDRESS_AND_PROBE;
}
static void
Index: src/sys/dev/i2c/tps65217pmic.c
diff -u src/sys/dev/i2c/tps65217pmic.c:1.11 src/sys/dev/i2c/tps65217pmic.c:1.12
--- src/sys/dev/i2c/tps65217pmic.c:1.11 Sat Oct 15 14:40:41 2016
+++ src/sys/dev/i2c/tps65217pmic.c Sat Jun 16 21:22:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: tps65217pmic.c,v 1.11 2016/10/15 14:40:41 kiyohara Exp $ */
+/* $NetBSD: tps65217pmic.c,v 1.12 2018/06/16 21:22:13 thorpej Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tps65217pmic.c,v 1.11 2016/10/15 14:40:41 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tps65217pmic.c,v 1.12 2018/06/16 21:22:13 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -280,10 +280,8 @@ tps65217pmic_match(device_t parent, cfda
/* we can only have one */
if (matched)
return 0;
- else
- matched = true;
- return 1;
+ return I2C_MATCH_ADDRESS_ONLY;
}
return 0;
}
@@ -296,6 +294,9 @@ tps65217pmic_attach(device_t parent, dev
prop_dictionary_t dict;
int isel, fdim, brightness;
+ /* XXXJRT But what if you have multiple i2c busses? */
+ matched = true;
+
sc->sc_dev = self;
sc->sc_addr = ia->ia_addr;
sc->sc_tag = ia->ia_tag;