Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c Don't use I2C_F_POLL when getting/setting limits.



details:   https://anonhg.NetBSD.org/src/rev/6c25698432be
branches:  trunk
changeset: 342863:6c25698432be
user:      jdc <jdc%NetBSD.org@localhost>
date:      Mon Jan 11 18:23:11 2016 +0000

description:
Don't use I2C_F_POLL when getting/setting limits.
Save/restore the correct values for LM77.

diffstat:

 sys/dev/i2c/lm75.c |  48 ++++++++++++++++++++++++++++--------------------
 1 files changed, 28 insertions(+), 20 deletions(-)

diffs (134 lines):

diff -r 622a37075ba1 -r 6c25698432be sys/dev/i2c/lm75.c
--- a/sys/dev/i2c/lm75.c        Mon Jan 11 17:09:25 2016 +0000
+++ b/sys/dev/i2c/lm75.c        Mon Jan 11 18:23:11 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lm75.c,v 1.28 2016/01/03 17:27:57 jdc Exp $    */
+/*     $NetBSD: lm75.c,v 1.29 2016/01/11 18:23:11 jdc Exp $    */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.28 2016/01/03 17:27:57 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.29 2016/01/11 18:23:11 jdc Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -206,16 +206,16 @@
        iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
 
        /* Read temperature limit(s) and remember initial value(s). */
-       if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT, &sc->sc_smax, 1)
-           != 0) {
-               aprint_error_dev(self, "unable to read Tos register\n");
-               iic_release_bus(sc->sc_tag, I2C_F_POLL);
-               return;
-       }
-       sc->sc_tmax = sc->sc_smax;
        if (i == lmtemp_lm77) {
+               if (lmtemp_temp_read(sc, LM77_REG_TCRIT_SET_POINT,
+                   &sc->sc_scrit, 1) != 0) {
+                       aprint_error_dev(self,
+                           "unable to read low register\n");
+                       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                       return;
+               }
                if (lmtemp_temp_read(sc, LM77_REG_TLOW_SET_POINT,
-                   &sc->sc_smax, 1) != 0) {
+                   &sc->sc_smin, 1) != 0) {
                        aprint_error_dev(self,
                            "unable to read low register\n");
                        iic_release_bus(sc->sc_tag, I2C_F_POLL);
@@ -228,7 +228,15 @@
                        iic_release_bus(sc->sc_tag, I2C_F_POLL);
                        return;
                }
+       } else {        /* LM75 or compatible */
+               if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT,
+                   &sc->sc_smax, 1) != 0) {
+                       aprint_error_dev(self, "unable to read Tos register\n");
+                       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                       return;
+               }
        }
+       sc->sc_tmax = sc->sc_smax;
 
        if (i == lmtemp_lm75)
                lmtemp_setup_sysctl(sc);
@@ -349,12 +357,12 @@
 
        *props &= ~(PROP_CRITMAX);
 
-       iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+       iic_acquire_bus(sc->sc_tag, 0);
        if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT, &val, 0) == 0) {
                limits->sel_critmax = val;
                *props |= PROP_CRITMAX;
        }
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 }
 
 static void
@@ -366,7 +374,7 @@
 
        *props &= ~(PROP_CRITMAX | PROP_WARNMAX | PROP_WARNMIN);
 
-       iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+       iic_acquire_bus(sc->sc_tag, 0);
        if (lmtemp_temp_read(sc, LM77_REG_TCRIT_SET_POINT, &val, 0) == 0) {
                limits->sel_critmax = val;
                *props |= PROP_CRITMAX;
@@ -379,7 +387,7 @@
                limits->sel_warnmin = val;
                *props |= PROP_WARNMIN;
        }
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 }
 
 static void
@@ -394,11 +402,11 @@
                        limit = sc->sc_smax;
                else
                        limit = limits->sel_critmax;
-               iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+               iic_acquire_bus(sc->sc_tag, 0);
                lmtemp_temp_write(sc, LM75_REG_THYST_SET_POINT,
                    limit - 5000000, 0);
                lmtemp_temp_write(sc, LM75_REG_TOS_SET_POINT, limit, 0);
-               iic_release_bus(sc->sc_tag, I2C_F_POLL);
+               iic_release_bus(sc->sc_tag, 0);
 
                /* Synchronise sysctl */
                sc->sc_tmax = (limit - 273150000) / 1000000;
@@ -412,10 +420,10 @@
        struct lmtemp_softc *sc = sme->sme_cookie;
        int32_t limit;
 
-       iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+       iic_acquire_bus(sc->sc_tag, 0);
        if (*props & PROP_CRITMAX) {
                if (limits == NULL)     /* Restore defaults */
-                       limit = sc->sc_smax;
+                       limit = sc->sc_scrit;
                else
                        limit = limits->sel_critmax;
                lmtemp_temp_write(sc, LM77_REG_TCRIT_SET_POINT, limit, 0);
@@ -429,12 +437,12 @@
        }
        if (*props & PROP_WARNMIN) {
                if (limits == NULL)     /* Restore defaults */
-                       limit = sc->sc_smax;
+                       limit = sc->sc_smin;
                else
                        limit = limits->sel_warnmin;
                lmtemp_temp_write(sc, LM77_REG_TLOW_SET_POINT, limit, 0);
        }
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 }
 
 static uint32_t



Home | Main Index | Thread Index | Old Index