Author: gavin Date: Thu Dec 22 00:09:53 2016 New Revision: 310381 URL: https://svnweb.freebsd.org/changeset/base/310381
Log: ow_temp: Update the temperature visible via the sysctl atomically, rather than using it as temporary calculation space. Modified: head/sys/dev/ow/ow_temp.c Modified: head/sys/dev/ow/ow_temp.c ============================================================================== --- head/sys/dev/ow/ow_temp.c Wed Dec 21 23:59:58 2016 (r310380) +++ head/sys/dev/ow/ow_temp.c Thu Dec 22 00:09:53 2016 (r310381) @@ -137,7 +137,7 @@ ow_temp_event_thread(void *arg) struct ow_temp_softc *sc; uint8_t scratch[8 + 1]; uint8_t crc; - int retries, rv; + int retries, rv, tmp; sc = arg; pause("owtstart", device_get_unit(sc->dev) * hz / 100); // 10ms stagger @@ -166,14 +166,14 @@ ow_temp_event_thread(void *arg) * Formula from DS18S20 datasheet, page 6 * DS18S20 datasheet says count_per_c is 16, DS1820 does not */ - sc->temp = (int16_t)((scratch[0] & 0xfe) | + tmp = (int16_t)((scratch[0] & 0xfe) | (scratch[1] << 8)) << 3; - sc->temp += 16 - scratch[6] - 4; /* count_per_c == 16 */ + tmp += 16 - scratch[6] - 4; /* count_per_c == 16 */ } else - sc->temp = (int16_t)(scratch[0] | (scratch[1] << 8)) << 3; + tmp = (int16_t)(scratch[0] | (scratch[1] << 8)) << 3; } else - sc->temp = (int16_t)(scratch[0] | (scratch[1] << 8)); - sc->temp = sc->temp * 1000 / 16 + 273150; + tmp = (int16_t)(scratch[0] | (scratch[1] << 8)); + sc->temp = tmp * 1000 / 16 + 273150; break; } sc->bad_crc++; _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"