Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c Add direct configuration support via compatible ...



details:   https://anonhg.NetBSD.org/src/rev/097a41bdd00a
branches:  trunk
changeset: 812455:097a41bdd00a
user:      jdc <jdc%NetBSD.org@localhost>
date:      Wed Dec 16 08:05:38 2015 +0000

description:
Add direct configuration support via compatible names.

diffstat:

 sys/dev/i2c/dbcool.c |  27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diffs (55 lines):

diff -r 2eb4a525a327 -r 097a41bdd00a sys/dev/i2c/dbcool.c
--- a/sys/dev/i2c/dbcool.c      Wed Dec 16 08:04:58 2015 +0000
+++ b/sys/dev/i2c/dbcool.c      Wed Dec 16 08:05:38 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dbcool.c,v 1.43 2015/04/23 23:23:00 pgoyette Exp $ */
+/*     $NetBSD: dbcool.c,v 1.44 2015/12/16 08:05:38 jdc Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.43 2015/04/23 23:23:00 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.44 2015/12/16 08:05:38 jdc Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -731,6 +731,10 @@
 CFATTACH_DECL_NEW(dbcool, sizeof(struct dbcool_softc),
     dbcool_match, dbcool_attach, dbcool_detach, NULL);
 
+static const char * dbcool_compats[] = {
+       "i2c-adm1031",
+       NULL
+};
 int
 dbcool_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -742,12 +746,19 @@
        dc.dc_readreg = dbcool_readreg;
        dc.dc_writereg = dbcool_writereg;
 
-       /* no probing if we attach to iic, but verify chip id  and address */
-       if ((ia->ia_addr & DBCOOL_ADDRMASK) != DBCOOL_ADDR)
-               return 0;
-       if (dbcool_chip_ident(&dc) >= 0)
-               return 1;
-
+       /* 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;
 }
 



Home | Main Index | Thread Index | Old Index