diff options
author | Gavin Atkinson <gavin@FreeBSD.org> | 2016-12-22 00:09:53 +0000 |
---|---|---|
committer | Gavin Atkinson <gavin@FreeBSD.org> | 2016-12-22 00:09:53 +0000 |
commit | 716911af3e9165221bb77246bce75a5f041b405b (patch) | |
tree | b5cc2e3f590d31f9f046e03577a4fe167fc8b7cc /sys/dev/ow | |
parent | 3c175909e7a1da7b2c703e6a9bacec190ac819bd (diff) | |
download | src-716911af3e9165221bb77246bce75a5f041b405b.tar.gz src-716911af3e9165221bb77246bce75a5f041b405b.zip |
ow_temp: Update the temperature visible via the sysctl atomically, rather
than using it as temporary calculation space.
Notes
Notes:
svn path=/head/; revision=310381
Diffstat (limited to 'sys/dev/ow')
-rw-r--r-- | sys/dev/ow/ow_temp.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/dev/ow/ow_temp.c b/sys/dev/ow/ow_temp.c index b89265bc6352..a91ecf87a62f 100644 --- a/sys/dev/ow/ow_temp.c +++ b/sys/dev/ow/ow_temp.c @@ -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++; |