Module Name: src Committed By: pgoyette Date: Sun Feb 14 23:07:22 UTC 2010
Modified Files: src/sys/dev/i2c: sdtemp.c Log Message: Adapt to changes in sysmon's limit structure To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/i2c/sdtemp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/i2c/sdtemp.c diff -u src/sys/dev/i2c/sdtemp.c:1.9 src/sys/dev/i2c/sdtemp.c:1.10 --- src/sys/dev/i2c/sdtemp.c:1.9 Fri Jan 8 20:04:31 2010 +++ src/sys/dev/i2c/sdtemp.c Sun Feb 14 23:07:22 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: sdtemp.c,v 1.9 2010/01/08 20:04:31 dyoung Exp $ */ +/* $NetBSD: sdtemp.c,v 1.10 2010/02/14 23:07:22 pgoyette Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.9 2010/01/08 20:04:31 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.10 2010/02/14 23:07:22 pgoyette Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -63,9 +63,9 @@ static void sdtemp_refresh(struct sysmon_envsys *, envsys_data_t *); static void sdtemp_get_limits(struct sysmon_envsys *, envsys_data_t *, - sysmon_envsys_lim_t *); + sysmon_envsys_lim_t *, uint32_t *); static void sdtemp_set_limits(struct sysmon_envsys *, envsys_data_t *, - sysmon_envsys_lim_t *); + sysmon_envsys_lim_t *, uint32_t *); #ifdef NOT_YET static int sdtemp_read_8(struct sdtemp_softc *, uint8_t, uint8_t *); static int sdtemp_write_8(struct sdtemp_softc *, uint8_t, uint8_t); @@ -172,6 +172,7 @@ struct sdtemp_softc *sc = device_private(self); struct i2c_attach_args *ia = aux; sysmon_envsys_lim_t limits; + uint32_t props; uint16_t mfgid, devid; int i, error; @@ -272,19 +273,19 @@ aprint_error_dev(self, "couldn't establish power handler\n"); /* Retrieve and display hardware monitor limits */ - sdtemp_get_limits(sc->sc_sme, sc->sc_sensor, &limits); + sdtemp_get_limits(sc->sc_sme, sc->sc_sensor, &limits, &props); aprint_normal_dev(self, ""); i = 0; - if (limits.sel_flags & PROP_WARNMIN) { + if (props & PROP_WARNMIN) { aprint_normal("low limit %dC", __UK2C(limits.sel_warnmin)); i++; } - if (limits.sel_flags & PROP_WARNMAX) { + if (props & PROP_WARNMAX) { aprint_normal("%shigh limit %dC ", (i)?", ":"", __UK2C(limits.sel_warnmax)); i++; } - if (limits.sel_flags & PROP_CRITMAX) { + if (props & PROP_CRITMAX) { aprint_normal("%scritical limit %dC ", (i)?", ":"", __UK2C(limits.sel_critmax)); i++; @@ -305,50 +306,50 @@ /* Retrieve current limits from device, and encode in uKelvins */ static void sdtemp_get_limits(struct sysmon_envsys *sme, envsys_data_t *edata, - sysmon_envsys_lim_t *limits) + sysmon_envsys_lim_t *limits, uint32_t *props) { struct sdtemp_softc *sc = sme->sme_cookie; uint16_t lim; - limits->sel_flags = 0; + *props = 0; iic_acquire_bus(sc->sc_tag, 0); if (sdtemp_read_16(sc, SDTEMP_REG_LOWER_LIM, &lim) == 0 && lim != 0) { limits->sel_warnmin = sdtemp_decode_temp(sc, lim); - limits->sel_flags |= PROP_WARNMIN; + *props |= PROP_WARNMIN; } if (sdtemp_read_16(sc, SDTEMP_REG_UPPER_LIM, &lim) == 0 && lim != 0) { limits->sel_warnmax = sdtemp_decode_temp(sc, lim); - limits->sel_flags |= PROP_WARNMAX; + *props |= PROP_WARNMAX; } if (sdtemp_read_16(sc, SDTEMP_REG_CRIT_LIM, &lim) == 0 && lim != 0) { limits->sel_critmax = sdtemp_decode_temp(sc, lim); - limits->sel_flags |= PROP_CRITMAX; + *props |= PROP_CRITMAX; } iic_release_bus(sc->sc_tag, 0); - if (limits->sel_flags != 0) - limits->sel_flags |= PROP_DRIVER_LIMITS; + if (*props != 0) + *props |= PROP_DRIVER_LIMITS; } /* Send current limit values to the device */ static void sdtemp_set_limits(struct sysmon_envsys *sme, envsys_data_t *edata, - sysmon_envsys_lim_t *limits) + sysmon_envsys_lim_t *limits, uint32_t *props) { uint16_t val; struct sdtemp_softc *sc = sme->sme_cookie; iic_acquire_bus(sc->sc_tag, 0); - if (limits->sel_flags & PROP_WARNMIN) { + if (*props & PROP_WARNMIN) { val = __UK2C(limits->sel_warnmin); (void)sdtemp_write_16(sc, SDTEMP_REG_LOWER_LIM, (val << 4) & SDTEMP_TEMP_MASK); } - if (limits->sel_flags & PROP_WARNMAX) { + if (*props & PROP_WARNMAX) { val = __UK2C(limits->sel_warnmax); (void)sdtemp_write_16(sc, SDTEMP_REG_UPPER_LIM, (val << 4) & SDTEMP_TEMP_MASK); } - if (limits->sel_flags & PROP_CRITMAX) { + if (*props & PROP_CRITMAX) { val = __UK2C(limits->sel_critmax); (void)sdtemp_write_16(sc, SDTEMP_REG_CRIT_LIM, (val << 4) & SDTEMP_TEMP_MASK); @@ -360,12 +361,12 @@ * limits are set that we cannot handle, tell sysmon that * the driver will take care of monitoring the limits! */ - if (limits->sel_flags & (PROP_CRITMIN | PROP_BATTCAP | PROP_BATTWARN)) - limits->sel_flags &= ~PROP_DRIVER_LIMITS; - else if (limits->sel_flags & PROP_LIMITS) - limits->sel_flags |= PROP_DRIVER_LIMITS; + if (*props & (PROP_CRITMIN | PROP_BATTCAP | PROP_BATTWARN)) + *props &= ~PROP_DRIVER_LIMITS; + else if (*props & PROP_LIMITS) + *props |= PROP_DRIVER_LIMITS; else - limits->sel_flags &= ~PROP_DRIVER_LIMITS; + *props &= ~PROP_DRIVER_LIMITS; } #ifdef NOT_YET /* All registers on these sensors are 16-bits */