Date: Thu, 22 Dec 2016 00:09:54 +0000 (UTC) From: Gavin Atkinson <gavin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310381 - head/sys/dev/ow Message-ID: <201612220009.uBM09s5M029258@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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++;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612220009.uBM09s5M029258>