diff options
Diffstat (limited to 'sys/dev/usb/utrh.c')
-rw-r--r-- | sys/dev/usb/utrh.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/dev/usb/utrh.c b/sys/dev/usb/utrh.c index 719b27249f0..cd6f43c06d9 100644 --- a/sys/dev/usb/utrh.c +++ b/sys/dev/usb/utrh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utrh.c,v 1.22 2019/11/12 07:47:30 mpi Exp $ */ +/* $OpenBSD: utrh.c,v 1.23 2020/02/25 10:03:39 mpi Exp $ */ /* * Copyright (c) 2009 Yojiro UO <yuo@nui.org> @@ -203,21 +203,24 @@ utrh_refresh(void *arg) { struct utrh_softc *sc = arg; unsigned int temp_tick, humidity_tick; - int temp, rh; + int temp, rh, flen, olen; uint8_t ledbuf[7]; + flen = MIN(sc->sc_flen, sizeof(ledbuf)); + /* turn on LED 1*/ bzero(ledbuf, sizeof(ledbuf)); ledbuf[0] = 0x3; ledbuf[1] = 0x1; if (uhidev_set_report(sc->sc_hdev.sc_parent, UHID_FEATURE_REPORT, - sc->sc_hdev.sc_report_id, ledbuf, sc->sc_flen) != sc->sc_flen) + sc->sc_hdev.sc_report_id, ledbuf, flen) != flen) printf("LED request failed\n"); /* issue query */ uint8_t cmdbuf[] = {0x31, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00}; + olen = MIN(sc->sc_olen, sizeof(cmdbuf)); if (uhidev_set_report(sc->sc_hdev.sc_parent, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen) != sc->sc_flen) + sc->sc_hdev.sc_report_id, cmdbuf, olen) != olen) return; /* wait till sensor data are updated, 1s will be enough */ @@ -226,7 +229,7 @@ utrh_refresh(void *arg) /* turn off LED 1 */ ledbuf[1] = 0x0; if (uhidev_set_report(sc->sc_hdev.sc_parent, UHID_FEATURE_REPORT, - sc->sc_hdev.sc_report_id, ledbuf, sc->sc_flen) != sc->sc_flen) + sc->sc_hdev.sc_report_id, ledbuf, flen) != flen) printf("LED request failed\n"); temp_tick = (sc->sc_ibuf[2] * 256 + sc->sc_ibuf[3]) & 0x3fff; |