ow_temp: better scopes for the lock
The lock is used only for start / stop signaling. It is used only for 'flags' field and the related condition variable. This change is a follow-up to r354067, it was suggested by Warner in D22107. Suggested by: imp MFC after: 1 week
This commit is contained in:
parent
f17aea5366
commit
46ecf8e0bc
@ -145,9 +145,9 @@ ow_temp_event_thread(void *arg)
|
|||||||
sc->flags |= OW_TEMP_RUNNING;
|
sc->flags |= OW_TEMP_RUNNING;
|
||||||
mtx_unlock(&sc->temp_lock);
|
mtx_unlock(&sc->temp_lock);
|
||||||
ow_temp_read_power_supply(sc->dev, &sc->parasite);
|
ow_temp_read_power_supply(sc->dev, &sc->parasite);
|
||||||
mtx_lock(&sc->temp_lock);
|
|
||||||
if (sc->parasite)
|
if (sc->parasite)
|
||||||
device_printf(sc->dev, "Running in parasitic mode unsupported\n");
|
device_printf(sc->dev, "Running in parasitic mode unsupported\n");
|
||||||
|
mtx_lock(&sc->temp_lock);
|
||||||
while ((sc->flags & OW_TEMP_DONE) == 0) {
|
while ((sc->flags & OW_TEMP_DONE) == 0) {
|
||||||
mtx_unlock(&sc->temp_lock);
|
mtx_unlock(&sc->temp_lock);
|
||||||
ow_temp_convert_t(sc->dev);
|
ow_temp_convert_t(sc->dev);
|
||||||
@ -155,10 +155,9 @@ ow_temp_event_thread(void *arg)
|
|||||||
msleep(sc, &sc->temp_lock, 0, "owtcvt", hz);
|
msleep(sc, &sc->temp_lock, 0, "owtcvt", hz);
|
||||||
if (sc->flags & OW_TEMP_DONE)
|
if (sc->flags & OW_TEMP_DONE)
|
||||||
break;
|
break;
|
||||||
|
mtx_unlock(&sc->temp_lock);
|
||||||
for (retries = 5; retries > 0; retries--) {
|
for (retries = 5; retries > 0; retries--) {
|
||||||
mtx_unlock(&sc->temp_lock);
|
|
||||||
rv = ow_temp_read_scratchpad(sc->dev, scratch, sizeof(scratch));
|
rv = ow_temp_read_scratchpad(sc->dev, scratch, sizeof(scratch));
|
||||||
mtx_lock(&sc->temp_lock);
|
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
crc = own_crc(sc->dev, scratch, sizeof(scratch) - 1);
|
crc = own_crc(sc->dev, scratch, sizeof(scratch) - 1);
|
||||||
if (crc == scratch[8]) {
|
if (crc == scratch[8]) {
|
||||||
@ -182,6 +181,7 @@ ow_temp_event_thread(void *arg)
|
|||||||
} else
|
} else
|
||||||
sc->bad_reads++;
|
sc->bad_reads++;
|
||||||
}
|
}
|
||||||
|
mtx_lock(&sc->temp_lock);
|
||||||
msleep(sc, &sc->temp_lock, 0, "owtcvt", sc->reading_interval);
|
msleep(sc, &sc->temp_lock, 0, "owtcvt", sc->reading_interval);
|
||||||
}
|
}
|
||||||
sc->flags &= ~OW_TEMP_RUNNING;
|
sc->flags &= ~OW_TEMP_RUNNING;
|
||||||
|
Loading…
Reference in New Issue
Block a user