diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-12-28 22:04:29 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-12-28 22:04:29 +0000 |
commit | 5e078371465e8940304c56163e5e6aab738c24d6 (patch) | |
tree | 7a8692662943831ef86cec3bbec438cb99ac9a3b /sys/dev/i2c/adm1024.c | |
parent | 2181786877d4dc162a12e4a07a8441ac6d24a44b (diff) |
I think this is better fan support
Diffstat (limited to 'sys/dev/i2c/adm1024.c')
-rw-r--r-- | sys/dev/i2c/adm1024.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sys/dev/i2c/adm1024.c b/sys/dev/i2c/adm1024.c index 9e63c248212..9108357df8e 100644 --- a/sys/dev/i2c/adm1024.c +++ b/sys/dev/i2c/adm1024.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1024.c,v 1.6 2005/12/28 20:35:42 deraadt Exp $ */ +/* $OpenBSD: adm1024.c,v 1.7 2005/12/28 22:04:28 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -124,8 +124,8 @@ admlc_attach(struct device *parent, struct device *self, void *aux) printf(", unable to read fan setting\n"); return; } - sc->sc_fan1mul = 8800 * (1 << (data >> 4) & 0x3); - sc->sc_fan2mul = 8800 * (1 << (data >> 6) & 0x3); + sc->sc_fan1mul = (1 << (data >> 4) & 0x3); + sc->sc_fan2mul = (1 << (data >> 6) & 0x3); iic_release_bus(sc->sc_tag, 0); @@ -186,6 +186,17 @@ admlc_attach(struct device *parent, struct device *self, void *aux) printf("\n"); } +static void +fanval(struct sensor *sens, int mul, u_int8_t data) +{ + int tmp = data * mul; + + if (tmp == 0) + sens->flags |= SENSOR_FINVALID; + else + sens->value = 1350000 / tmp; +} + void admlc_refresh(void *arg) { @@ -247,12 +258,11 @@ admlc_refresh(void *arg) cmd = ADM1024_FAN1; if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) - sc->sc_sensor[ADMLC_FAN1].value = sc->sc_fan1mul * data; + fanval(&sc->sc_sensor[ADMLC_FAN1], sc->sc_fan1mul, data); cmd = ADM1024_FAN2; if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) - sc->sc_sensor[ADMLC_FAN2].value = sc->sc_fan2mul * data; - + fanval(&sc->sc_sensor[ADMLC_FAN2], sc->sc_fan2mul, data); iic_release_bus(sc->sc_tag, 0); } |