svn commit: r337289 - head/sys/dev/usb/input
Vladimir Kondratyev
wulf at FreeBSD.org
Sat Aug 4 12:31:20 UTC 2018
Author: wulf
Date: Sat Aug 4 12:31:19 2018
New Revision: 337289
URL: https://svnweb.freebsd.org/changeset/base/337289
Log:
wmt(4): Use internal function to calculate input report size
Usbhid's hid_report_size() calculates integral size of all reports of given
kind found in the HID descriptor rather then exact size of report with given
ID as its userland counterpart does. As all input data processed by the
driver is located within the same report, calculate required driver's buffer
size with userland version, imported in one of the previous commits.
This allows us to skip zeroing of buffer on processing of each report.
While here do some minor refactoring.
MFC after: 2 weeks
Modified:
head/sys/dev/usb/input/wmt.c
Modified: head/sys/dev/usb/input/wmt.c
==============================================================================
--- head/sys/dev/usb/input/wmt.c Sat Aug 4 12:29:08 2018 (r337288)
+++ head/sys/dev/usb/input/wmt.c Sat Aug 4 12:31:19 2018 (r337289)
@@ -286,6 +286,7 @@ wmt_attach(device_t dev)
uint16_t d_len;
size_t i;
int err;
+ bool hid_ok;
device_set_usb_desc(dev);
sc->dev = dev;
@@ -298,15 +299,14 @@ wmt_attach(device_t dev)
return (ENXIO);
}
- if (!wmt_hid_parse(sc, d_ptr, d_len)) {
+ hid_ok = wmt_hid_parse(sc, d_ptr, d_len);
+ free(d_ptr, M_TEMP);
+ if (!hid_ok) {
DPRINTF("multi-touch HID descriptor not found\n");
- free(d_ptr, M_TEMP);
return (ENXIO);
}
- /* Get HID report length */
- sc->isize = hid_report_size(d_ptr, d_len, hid_input, NULL);
- free(d_ptr, M_TEMP);
+ /* Check HID report length */
if (sc->isize <= 0 || sc->isize > WMT_BSIZE) {
DPRINTF("Input size invalid or too large: %d\n", sc->isize);
return (ENXIO);
@@ -337,7 +337,7 @@ wmt_attach(device_t dev)
err = usbd_transfer_setup(uaa->device, &uaa->info.bIfaceIndex,
sc->xfer, wmt_config, WMT_N_TRANSFER, sc, &sc->mtx);
- if (err) {
+ if (err != USB_ERR_NORMAL_COMPLETION) {
DPRINTF("usbd_transfer_setup error=%s\n", usbd_errstr(err));
goto detach;
}
@@ -777,6 +777,7 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr,
sc->ai[WMT_ORIENTATION].max = 1;
}
+ sc->isize = wmt_hid_report_size(d_ptr, d_len, hid_input, report_id);
sc->cont_max_rlen = wmt_hid_report_size(d_ptr, d_len, hid_feature,
cont_max_rid);
if (thqa_cert_rid > 0)
More information about the svn-src-all
mailing list