Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c Chip matching improvements:



details:   https://anonhg.NetBSD.org/src/rev/9648796bf830
branches:  trunk
changeset: 967501:9648796bf830
user:      jdc <jdc%NetBSD.org@localhost>
date:      Wed Dec 11 21:00:11 2019 +0000

description:
Chip matching improvements:
  only match for currently known addresses
  don't generate messages when matching
Tested on Sun Blade 2500 by martin@.

diffstat:

 sys/dev/i2c/adm1026.c    |  25 +++++++++++++------------
 sys/dev/i2c/adm1026reg.h |   5 ++---
 2 files changed, 15 insertions(+), 15 deletions(-)

diffs (91 lines):

diff -r 327d1dbbdd80 -r 9648796bf830 sys/dev/i2c/adm1026.c
--- a/sys/dev/i2c/adm1026.c     Wed Dec 11 20:50:32 2019 +0000
+++ b/sys/dev/i2c/adm1026.c     Wed Dec 11 21:00:11 2019 +0000
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.5 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.6 2019/12/11 21:00:11 jdc Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -99,11 +99,11 @@
 };
 
 static int adm1026_match(device_t, cfdata_t, void *);
-static int adm1026_ident(struct adm1026_softc *sc);
+static int adm1026_ident(struct adm1026_softc *, int);
 static void adm1026_attach(device_t, device_t, void *);
 static int adm1026_detach(device_t, int);
-bool adm1026_pmf_suspend(device_t dev, const pmf_qual_t *qual);
-bool adm1026_pmf_resume(device_t dev, const pmf_qual_t *qual);
+bool adm1026_pmf_suspend(device_t, const pmf_qual_t *);
+bool adm1026_pmf_resume(device_t, const pmf_qual_t *);
 
 static void adm1026_setup_fans(struct adm1026_softc *sc, int div2_val);
 static void adm1026_setup_temps(struct adm1026_softc *sc);
@@ -141,15 +141,14 @@
        if (iic_use_direct_match(ia, cf, compat_data, &match_result))
                return match_result;
 
-       if ((ia->ia_addr & ADM1026_ADDRMASK) == ADM1026_ADDR &&
-           adm1026_ident(&sc))
+       if (ia->ia_addr == ADM1026_ADDR1 && adm1026_ident(&sc, 1))
                return I2C_MATCH_ADDRESS_AND_PROBE;
 
        return 0;
 }
 
 static int
-adm1026_ident(struct adm1026_softc *sc)
+adm1026_ident(struct adm1026_softc *sc, int probe_only)
 {
        uint8_t val;
        int err;
@@ -157,14 +156,16 @@
        /* Manufacturer ID and revision/stepping */
        err = adm1026_read_reg(sc, ADM1026_ID, &val);
        if (err || val != ADM1026_MANF_ID) {
-               aprint_verbose("adm1026_ident: "
-                   "manufacturer ID invalid or missing\n");
+               if (!probe_only)
+                       aprint_verbose("adm1026_ident: "
+                           "manufacturer ID invalid or missing\n");
                return 0;
        }
        err = adm1026_read_reg(sc, ADM1026_REV, &sc->sc_rev);
        if (err || ADM1026_REVISION(sc->sc_rev) != ADM1026_MANF_REV) {
-               aprint_verbose("adm1026_ident: "
-                   "manufacturer revision invalid or missing\n");
+               if (!probe_only)
+                       aprint_verbose("adm1026_ident: "
+                           "manufacturer revision invalid or missing\n");
                return 0;
        }
        return 1;
@@ -191,7 +192,7 @@
        else
                div2_val = -1;
 
-       (void) adm1026_ident(sc);
+       (void) adm1026_ident(sc, 0);
        aprint_normal(": ADM1026 hardware monitor: rev. 0x%x, step. 0x%x\n",
            ADM1026_REVISION(sc->sc_rev), ADM1026_STEPPING(sc->sc_rev));
 
diff -r 327d1dbbdd80 -r 9648796bf830 sys/dev/i2c/adm1026reg.h
--- a/sys/dev/i2c/adm1026reg.h  Wed Dec 11 20:50:32 2019 +0000
+++ b/sys/dev/i2c/adm1026reg.h  Wed Dec 11 21:00:11 2019 +0000
@@ -37,10 +37,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1026reg.h,v 1.2 2019/10/13 07:44:51 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026reg.h,v 1.3 2019/12/11 21:00:11 jdc Exp $");
 
-#define        ADM1026_ADDRMASK        0x2f    /* 010 11xx */
-#define ADM1026_ADDR           0x2c
+#define ADM1026_ADDR1          0x2c
 
 #define ADM1026_CONF1          0x00
 #define ADM1026_CONF2          0x01



Home | Main Index | Thread Index | Old Index