Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/khorben-n900]: src/sys/dev/i2c Added a refresh callback for the temperat...
details: https://anonhg.NetBSD.org/src/rev/8cd582581690
branches: khorben-n900
changeset: 786713:8cd582581690
user: khorben <khorben%NetBSD.org@localhost>
date: Thu May 16 15:51:29 2013 +0000
description:
Added a refresh callback for the temperature sensor.
diffstat:
sys/dev/i2c/lp5523.c | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
diffs (82 lines):
diff -r e070bf1c6055 -r 8cd582581690 sys/dev/i2c/lp5523.c
--- a/sys/dev/i2c/lp5523.c Thu May 16 15:36:50 2013 +0000
+++ b/sys/dev/i2c/lp5523.c Thu May 16 15:51:29 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lp5523.c,v 1.1.2.1 2013/05/16 15:36:50 khorben Exp $ */
+/* $NetBSD: lp5523.c,v 1.1.2.2 2013/05/16 15:51:29 khorben Exp $ */
/*
* Texas Instruments LP5523 Programmable 9-Output LED Driver
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lp5523.c,v 1.1.2.1 2013/05/16 15:36:50 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lp5523.c,v 1.1.2.2 2013/05/16 15:51:29 khorben Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -83,6 +83,9 @@
static int lp5523_sysctl(SYSCTLFN_ARGS);
+static void lp5523_refresh_temperature(struct sysmon_envsys *,
+ envsys_data_t *);
+
static int lp5523_read_1(struct lp5523_softc *, uint8_t, uint8_t *);
static int lp5523_write_1(struct lp5523_softc *, uint8_t, uint8_t);
@@ -125,13 +128,12 @@
{
const int flags = ENVSYS_FMONNOTSUPP | ENVSYS_FHAS_ENTROPY
| ENVSYS_FVALID_MIN | ENVSYS_FVALID_MAX;
- int8_t s8;
sc->sc_sme = sysmon_envsys_create();
sc->sc_sme->sme_cookie = sc;
sc->sc_sme->sme_name = device_xname(sc->sc_dev);
- sc->sc_sme->sme_flags = SME_DISABLE_REFRESH;
+ sc->sc_sme->sme_refresh = lp5523_refresh_temperature;
sc->sc_temp_sensor.flags = flags;
sc->sc_temp_sensor.units = ENVSYS_STEMP;
@@ -152,13 +154,7 @@
return;
}
- iic_acquire_bus(sc->sc_i2c, 0);
- lp5523_read_1(sc, LP5523_REG_TEMP_READ, &s8);
- iic_release_bus(sc->sc_i2c, 0);
- if (s8 >= -41 && s8 <= 89) {
- sc->sc_temp_sensor.state = ENVSYS_SVALID;
- sc->sc_temp_sensor.value_cur = LP5523_DEGC2UK(s8);
- }
+ lp5523_refresh_temperature(sc->sc_sme, &sc->sc_temp_sensor);
}
static void
@@ -238,6 +234,23 @@
return error;
}
+static void
+lp5523_refresh_temperature(struct sysmon_envsys *sme, envsys_data_t *edata)
+{
+ struct lp5523_softc *sc = sme->sme_cookie;
+ int8_t s8;
+
+ iic_acquire_bus(sc->sc_i2c, 0);
+ lp5523_read_1(sc, LP5523_REG_TEMP_READ, &s8);
+ iic_release_bus(sc->sc_i2c, 0);
+ if (s8 >= -41 && s8 <= 89) {
+ sc->sc_temp_sensor.state = ENVSYS_SVALID;
+ sc->sc_temp_sensor.value_cur = LP5523_DEGC2UK(s8);
+ } else {
+ sc->sc_temp_sensor.state = ENVSYS_SINVALID;
+ }
+}
+
static int
lp5523_read_1(struct lp5523_softc *sc, uint8_t reg, uint8_t *val)
{
Home |
Main Index |
Thread Index |
Old Index