diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-06-26 17:47:35 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-06-26 17:47:35 +0000 |
commit | ae7ea70b986e919e117c7c7495d3c6e8a1f16e67 (patch) | |
tree | 1fdc1468c32c220daa03335cadcc2bd7e640b5be /sys/dev/isa/nsclpcsio_isa.c | |
parent | 1fa4b7222abca95c47b9ce27c21e2af05a115c05 (diff) |
Avoid using the rfact member of 'struct sensor' which is on its way out.
Diffstat (limited to 'sys/dev/isa/nsclpcsio_isa.c')
-rw-r--r-- | sys/dev/isa/nsclpcsio_isa.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sys/dev/isa/nsclpcsio_isa.c b/sys/dev/isa/nsclpcsio_isa.c index f6533f53b04..9e895e5cfaf 100644 --- a/sys/dev/isa/nsclpcsio_isa.c +++ b/sys/dev/isa/nsclpcsio_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nsclpcsio_isa.c,v 1.8 2006/04/10 00:57:54 deraadt Exp $ */ +/* $OpenBSD: nsclpcsio_isa.c,v 1.9 2006/06/26 17:47:34 kettenis Exp $ */ /* $NetBSD: nsclpcsio_isa.c,v 1.5 2002/10/22 16:18:26 drochner Exp $ */ /* @@ -417,7 +417,7 @@ nsclpcsio_tms_update(struct nsclpcsio_softc *sc) void nsclpcsio_vlm_init(struct nsclpcsio_softc *sc) { - int scale, i; + int i; char *desc = NULL; VLM_WRITE(sc, SIO_VLMCFG, 0x00); @@ -428,22 +428,18 @@ nsclpcsio_vlm_init(struct nsclpcsio_softc *sc) VLM_WRITE(sc, SIO_VCHCFST, 0x01); desc = NULL; - scale = 1; switch (i) { case 7: desc = "VSB"; - scale = 2; break; case 8: desc = "VDD"; - scale = 2; break; case 9: desc = "VBAT"; break; case 10: desc = "AVDD"; - scale = 2; break; case 11: desc = "TS1"; @@ -463,9 +459,6 @@ nsclpcsio_vlm_init(struct nsclpcsio_softc *sc) sizeof(sc->sensors[SIO_VLM_OFF].desc), "VSENS%d", i); sc->sensors[SIO_VLM_OFF + i].type = SENSOR_VOLTS_DC; - /* Vi = (2.45±0.05)*VREF *RDCHVi / 256 */ - sc->sensors[SIO_VLM_OFF + i].rfact = - 10 * scale * ((245 * SIO_VREF) >> 8); } nsclpcsio_vlm_update(sc); } @@ -475,7 +468,7 @@ nsclpcsio_vlm_update(struct nsclpcsio_softc *sc) { u_int8_t status; u_int8_t data; - int i; + int scale, rfact, i; for (i = 0; i < 14; i++) { VLM_WRITE(sc, SIO_VLMBS, i); @@ -489,8 +482,18 @@ nsclpcsio_vlm_update(struct nsclpcsio_softc *sc) data = VLM_READ(sc, SIO_RDCHV); DPRINTF(("%s: status %d V %d\n", sc->sensors[SIO_VLM_OFF + i].desc, status, data)); - sc->sensors[SIO_VLM_OFF + i].value = - data * sc->sensors[SIO_VLM_OFF + i].rfact; + + scale = 1; + switch (i) { + case 7: + case 8: + case 10: + scale = 2; + } + + /* Vi = (2.45±0.05)*VREF *RDCHVi / 256 */ + rfact = 10 * scale * ((245 * SIO_VREF) >> 8); + sc->sensors[SIO_VLM_OFF + i].value = data * rfact; } } |