Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys More cleanup to i2c autoconfiguration:
details: https://anonhg.NetBSD.org/src/rev/8a1c20f99fb6
branches: trunk
changeset: 319958:8a1c20f99fb6
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Jun 16 21:22:13 2018 +0000
description:
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.
diffstat:
sys/arch/evbmips/loongson/dev/stvii.c | 6 +-
sys/arch/hpcarm/dev/nbppcon.c | 6 +-
sys/arch/macppc/dev/deq.c | 20 +++----
sys/arch/macppc/dev/smusat.c | 16 +++---
sys/arch/macppc/dev/videopll.c | 11 ++-
sys/arch/sparc64/dev/pcf8591_envctrl.c | 11 ++-
sys/arch/sparc64/dev/tda.c | 8 +-
sys/arch/zaurus/dev/ioexp.c | 21 +++----
sys/arch/zaurus/dev/wm8731_zaudio.c | 21 +++----
sys/arch/zaurus/dev/wm8750_zaudio.c | 21 +++----
sys/dev/i2c/ac100.c | 6 +-
sys/dev/i2c/act8846.c | 6 +-
sys/dev/i2c/adadc.c | 29 +++++-----
sys/dev/i2c/adm1021.c | 38 +++++---------
sys/dev/i2c/adm1026.c | 22 +++-----
sys/dev/i2c/am2315.c | 43 +++------------
sys/dev/i2c/as3722.c | 34 +++++++-----
sys/dev/i2c/at24cxx.c | 24 +++-----
sys/dev/i2c/axp20x.c | 15 +++-
sys/dev/i2c/axp22x.c | 13 +++-
sys/dev/i2c/axp809.c | 14 ++++-
sys/dev/i2c/axppmic.c | 23 ++++++--
sys/dev/i2c/dbcool.c | 26 ++++-----
sys/dev/i2c/ddc.c | 6 +-
sys/dev/i2c/dstemp.c | 20 +++---
sys/dev/i2c/em3027.c | 6 +-
sys/dev/i2c/fcu.c | 20 +++---
sys/dev/i2c/g760a.c | 6 +-
sys/dev/i2c/i2c.c | 88 ++++++++++++++++++++++++++-------
sys/dev/i2c/i2cvar.h | 14 ++++-
sys/dev/i2c/ibmhawk.c | 5 +-
sys/dev/i2c/ihidev.c | 12 ++--
sys/dev/i2c/lm75.c | 44 ++++++----------
sys/dev/i2c/lm87.c | 57 ++++++++-------------
sys/dev/i2c/lm_i2c.c | 8 +-
sys/dev/i2c/m41st84.c | 21 +++----
sys/dev/i2c/m41t00.c | 6 +-
sys/dev/i2c/max6900.c | 6 +-
sys/dev/i2c/max77620.c | 11 ++-
sys/dev/i2c/mcp980x.c | 14 ++--
sys/dev/i2c/mpl115a.c | 6 +-
sys/dev/i2c/pcf8563.c | 20 +++---
sys/dev/i2c/pcf8583.c | 6 +-
sys/dev/i2c/r2025.c | 6 +-
sys/dev/i2c/rs5c372.c | 21 +++----
sys/dev/i2c/s390.c | 21 +++----
sys/dev/i2c/sdtemp.c | 6 +-
sys/dev/i2c/sgsmix.c | 32 ++++++------
sys/dev/i2c/si70xx.c | 25 +++-----
sys/dev/i2c/smscmon.c | 6 +-
sys/dev/i2c/spdmem_i2c.c | 19 ++++++-
sys/dev/i2c/sy8106a.c | 13 ++--
sys/dev/i2c/tcagpio.c | 11 ++-
sys/dev/i2c/tcakp.c | 18 +++---
sys/dev/i2c/titemp.c | 33 ++++++------
sys/dev/i2c/tps65217pmic.c | 11 ++-
sys/dev/i2c/tps65950.c | 6 +-
sys/dev/i2c/tsl256x.c | 57 ++++++++++-----------
sys/dev/i2c/w83795g.c | 6 +-
sys/dev/i2c/x1226.c | 6 +-
60 files changed, 570 insertions(+), 537 deletions(-)
diffs (truncated from 2504 to 300 lines):
diff -r 3e148c9cd7a0 -r 8a1c20f99fb6 sys/arch/evbmips/loongson/dev/stvii.c
--- a/sys/arch/evbmips/loongson/dev/stvii.c Sat Jun 16 21:00:12 2018 +0000
+++ b/sys/arch/evbmips/loongson/dev/stvii.c Sat Jun 16 21:22:13 2018 +0000
@@ -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 @@
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
diff -r 3e148c9cd7a0 -r 8a1c20f99fb6 sys/arch/hpcarm/dev/nbppcon.c
--- a/sys/arch/hpcarm/dev/nbppcon.c Sat Jun 16 21:00:12 2018 +0000
+++ b/sys/arch/hpcarm/dev/nbppcon.c Sat Jun 16 21:22:13 2018 +0000
@@ -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 @@
!platid_match(&platid, &platid_mask_MACH_PSIONTEKLOGIX_NETBOOK_PRO))
return 0;
- return 1;
+ return I2C_MATCH_ADDRESS_AND_PROBE;
}
/* ARGSUSED */
diff -r 3e148c9cd7a0 -r 8a1c20f99fb6 sys/arch/macppc/dev/deq.c
--- a/sys/arch/macppc/dev/deq.c Sat Jun 16 21:00:12 2018 +0000
+++ b/sys/arch/macppc/dev/deq.c Sat Jun 16 21:22:13 2018 +0000
@@ -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 @@
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;
}
diff -r 3e148c9cd7a0 -r 8a1c20f99fb6 sys/arch/macppc/dev/smusat.c
--- a/sys/arch/macppc/dev/smusat.c Sat Jun 16 21:00:12 2018 +0000
+++ b/sys/arch/macppc/dev/smusat.c Sat Jun 16 21:22:13 2018 +0000
@@ -115,15 +115,15 @@
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
diff -r 3e148c9cd7a0 -r 8a1c20f99fb6 sys/arch/macppc/dev/videopll.c
--- a/sys/arch/macppc/dev/videopll.c Sat Jun 16 21:00:12 2018 +0000
+++ b/sys/arch/macppc/dev/videopll.c Sat Jun 16 21:22:13 2018 +0000
@@ -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 @@
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;
}
diff -r 3e148c9cd7a0 -r 8a1c20f99fb6 sys/arch/sparc64/dev/pcf8591_envctrl.c
--- a/sys/arch/sparc64/dev/pcf8591_envctrl.c Sat Jun 16 21:00:12 2018 +0000
+++ b/sys/arch/sparc64/dev/pcf8591_envctrl.c Sat Jun 16 21:22:13 2018 +0000
@@ -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 @@
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;
}
diff -r 3e148c9cd7a0 -r 8a1c20f99fb6 sys/arch/sparc64/dev/tda.c
--- a/sys/arch/sparc64/dev/tda.c Sat Jun 16 21:00:12 2018 +0000
+++ b/sys/arch/sparc64/dev/tda.c Sat Jun 16 21:22:13 2018 +0000
@@ -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 @@
*/
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
diff -r 3e148c9cd7a0 -r 8a1c20f99fb6 sys/arch/zaurus/dev/ioexp.c
--- a/sys/arch/zaurus/dev/ioexp.c Sat Jun 16 21:00:12 2018 +0000
+++ b/sys/arch/zaurus/dev/ioexp.c Sat Jun 16 21:22:13 2018 +0000
@@ -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 @@
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;
}
diff -r 3e148c9cd7a0 -r 8a1c20f99fb6 sys/arch/zaurus/dev/wm8731_zaudio.c
--- a/sys/arch/zaurus/dev/wm8731_zaudio.c Sat Jun 16 21:00:12 2018 +0000
+++ b/sys/arch/zaurus/dev/wm8731_zaudio.c Sat Jun 16 21:22:13 2018 +0000
@@ -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 @@
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;
- }
Home |
Main Index |
Thread Index |
Old Index