From owner-svn-src-head@freebsd.org Sat Aug 4 12:31:20 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D66F610698F6; Sat, 4 Aug 2018 12:31:19 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8C651733D0; Sat, 4 Aug 2018 12:31:19 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6D835786E; Sat, 4 Aug 2018 12:31:19 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w74CVJZ5057328; Sat, 4 Aug 2018 12:31:19 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w74CVJX0057327; Sat, 4 Aug 2018 12:31:19 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201808041231.w74CVJX0057327@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sat, 4 Aug 2018 12:31:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337289 - head/sys/dev/usb/input X-SVN-Group: head X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: head/sys/dev/usb/input X-SVN-Commit-Revision: 337289 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Aug 2018 12:31:20 -0000 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)