summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2014-12-11 18:50:33 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2014-12-11 18:50:33 +0000
commit23be8eb25e0fc0e9cc1274c0dafa4f9c03526f36 (patch)
treedf4f097d7039cbcc6530b8c6eeaab484a8e66009 /sys/dev
parent477855b2148747cf0d884fbb75161e499ca2e59b (diff)
Handle UPSes with broken report descriptors.
As reported by David Higgs some UPSes might send fewer bytes than requested. When such thing happens, do like apcupsd and adjust the size of the given descriptor. Based on a diff provided by David Higgs, thanks!
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/upd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/dev/usb/upd.c b/sys/dev/usb/upd.c
index cc6a3adf13e..e63cc462117 100644
--- a/sys/dev/usb/upd.c
+++ b/sys/dev/usb/upd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: upd.c,v 1.11 2014/12/11 18:39:27 mpi Exp $ */
+/* $OpenBSD: upd.c,v 1.12 2014/12/11 18:50:32 mpi Exp $ */
/*
* Copyright (c) 2014 Andre de Oliveira <andre@openbsd.org>
@@ -274,11 +274,15 @@ upd_refresh(void *arg)
actlen = uhidev_get_report(sc->sc_hdev.sc_parent,
UHID_FEATURE_REPORT, repid, buf, report->size);
- if (actlen != report->size) {
+ if (actlen == -1) {
DPRINTF(("upd: failed to get report id=%02x\n", repid));
continue;
}
+ /* Deal with buggy firmwares. */
+ if (actlen < report->size)
+ report->size = actlen;
+
upd_update_sensors(sc, buf, report->size, repid);
}
}