On 09/12/14(Tue) 10:57, David Higgs wrote: > On Dec 8, 2014, at 6:07 PM, Martin Pieuchot <mpieuc...@nolizard.org> wrote: > > > On 08/12/14(Mon) 09:35, David Higgs wrote: > >> On Mon, Dec 8, 2014 at 9:29 AM, Martin Pieuchot <mpieuc...@nolizard.org> > >> wrote: > >> [...] > >>> Now I'd like to finish the transition that started with the import of > >>> upd(4) and move away from the actual 1 reportID = 1 driver model. > >>> Because in the end they are all sharing the same USB device actually > >>> represented by an uhidev(4) instance. So I'll ride the refactoring > >>> needed by your buggy firmware to also change that. Since all the > >>> uhidev_*_report() will be modified, we can also pass a pointer to > >>> the uhidev(4) device instead of one of its children. Is it clearer? > >> > >> Sounds great to me. > > > > As promised, here's a second and last diff that changes the various > > uhidev_*_report() functions to provide the transfered length to the > > caller if requested. > > > > The *get* variant now also handles the first byte required for non-0 > > reportID. > > > > And last but not least, it includes the hack from apcupsd to deal with > > buggy firmwares like yours. > > > > Could you try it and let me know how it goes? > > Seems to work just fine on my -current VM after adding the diff below (I > didn’t try without). See my previous email in this thread for other comments > re: your diff.
Thanks for all your comments. I though a bit more about this change and decided to: - Simply return the number of bytes written/read upon success and -1 otherwise (à la read/write). This allows us to remove some usages of "usbd_status" when we are not directly manipulating a "xfer" object. - Always consider a short transfer for SET requests as failures. So the diff below includes your changes to upd(4) that I'll commit separately if you're ok. Concerning your remark about the USB_SET_IMMED ioctl(2), it doesn't really matter, this interface is not used and should be removed. Index: ucycom.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/ucycom.c,v retrieving revision 1.29 diff -u -p -r1.29 ucycom.c --- ucycom.c 12 Jul 2014 20:26:33 -0000 1.29 +++ ucycom.c 11 Dec 2014 09:50:14 -0000 @@ -453,13 +453,9 @@ ucycom_param(void *addr, int portno, str report[2] = (baud >> 16) & 0xff; report[3] = (baud >> 24) & 0xff; report[4] = cfg; - err = uhidev_set_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - sc->sc_hdev.sc_report_id, report, sc->sc_flen); - if (err != 0) { - DPRINTF(("ucycom_param: uhidev_set_report %d %s\n", - err, usbd_errstr(err))); + if (uhidev_set_report(sc->sc_hdev.sc_parent, UHID_FEATURE_REPORT, + sc->sc_hdev.sc_report_id, report, sc->sc_flen) != sc->sc_flen) return EIO; - } sc->sc_baud = baud; return (err); } @@ -553,10 +549,10 @@ ucycom_set(void *addr, int portno, int r void ucycom_get_cfg(struct ucycom_softc *sc) { - int err, cfg, baud; + int cfg, baud; uint8_t report[5]; - err = uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, + uhidev_get_report(sc->sc_hdev.sc_parent, UHID_FEATURE_REPORT, sc->sc_hdev.sc_report_id, report, sc->sc_flen); cfg = report[4]; baud = (report[3] << 24) + (report[2] << 16) + (report[1] << 8) + report[0]; Index: ugold.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/ugold.c,v retrieving revision 1.6 diff -u -p -r1.6 ugold.c --- ugold.c 29 Apr 2014 12:53:33 -0000 1.6 +++ ugold.c 11 Dec 2014 09:50:14 -0000 @@ -260,6 +260,9 @@ ugold_refresh(void *arg) int ugold_issue_cmd(struct ugold_softc *sc, uint8_t *cmd, int len) { - return uhidev_set_report_async(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, cmd, len); + int actlen; + + actlen = uhidev_set_report_async(sc->sc_hdev.sc_parent, + UHID_OUTPUT_REPORT, sc->sc_hdev.sc_report_id, cmd, len); + return (actlen != len); } Index: uhid.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/uhid.c,v retrieving revision 1.58 diff -u -p -r1.58 uhid.c --- uhid.c 12 Jul 2014 18:48:52 -0000 1.58 +++ uhid.c 11 Dec 2014 09:50:14 -0000 @@ -259,21 +259,17 @@ uhid_do_read(struct uhid_softc *sc, stru { int s; int error = 0; - int extra; size_t length; u_char buffer[UHID_CHUNK]; - usbd_status err; DPRINTFN(1, ("uhidread\n")); if (sc->sc_state & UHID_IMMED) { DPRINTFN(1, ("uhidread immed\n")); - extra = sc->sc_hdev.sc_report_id != 0; - err = uhidev_get_report(&sc->sc_hdev, UHID_INPUT_REPORT, - sc->sc_hdev.sc_report_id, buffer, - sc->sc_hdev.sc_isize + extra); - if (err) + if (uhidev_get_report(sc->sc_hdev.sc_parent, + UHID_INPUT_REPORT, sc->sc_hdev.sc_report_id, buffer, + sc->sc_hdev.sc_isize) != sc->sc_hdev.sc_isize) return (EIO); - return (uiomove(buffer+extra, sc->sc_hdev.sc_isize, uio)); + return (uiomove(buffer, sc->sc_hdev.sc_isize, uio)); } s = splusb(); @@ -333,7 +329,6 @@ uhid_do_write(struct uhid_softc *sc, str { int error; int size; - usbd_status err; DPRINTFN(1, ("uhidwrite\n")); @@ -346,9 +341,9 @@ uhid_do_write(struct uhid_softc *sc, str return (EINVAL); error = uiomove(sc->sc_obuf, size, uio); if (!error) { - err = uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, sc->sc_obuf, size); - if (err) + if (uhidev_set_report(sc->sc_hdev.sc_parent, + UHID_OUTPUT_REPORT, sc->sc_hdev.sc_report_id, sc->sc_obuf, + size) != size) error = EIO; } @@ -375,9 +370,8 @@ uhid_do_ioctl(struct uhid_softc *sc, u_l int flag, struct proc *p) { u_char buffer[UHID_CHUNK]; - int size, extra; usbd_status err; - int rc; + int rc, size; DPRINTFN(2, ("uhidioctl: cmd=%lx\n", cmd)); @@ -409,11 +403,9 @@ uhid_do_ioctl(struct uhid_softc *sc, u_l case USB_SET_IMMED: if (*(int *)addr) { - extra = sc->sc_hdev.sc_report_id != 0; - err = uhidev_get_report(&sc->sc_hdev, UHID_INPUT_REPORT, - sc->sc_hdev.sc_report_id, buffer, - sc->sc_hdev.sc_isize + extra); - if (err) + if (uhidev_get_report(sc->sc_hdev.sc_parent, + UHID_INPUT_REPORT, sc->sc_hdev.sc_report_id, buffer, + sc->sc_hdev.sc_isize) != sc->sc_hdev.sc_isize) return (EOPNOTSUPP); sc->sc_state |= UHID_IMMED; Index: uhidev.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/uhidev.c,v retrieving revision 1.64 diff -u -p -r1.64 uhidev.c --- uhidev.c 8 Dec 2014 22:00:11 -0000 1.64 +++ uhidev.c 11 Dec 2014 09:50:14 -0000 @@ -270,11 +270,6 @@ uhidev_use_rdesc(struct uhidev_softc *sc int size; if (vendor == USB_VENDOR_WACOM) { - struct uhidev wacom; - - /* XXX until we pass the parent directly. */ - wacom.sc_parent = sc; - /* The report descriptor for the Wacom Graphire is broken. */ switch (product) { case USB_PRODUCT_WACOM_GRAPHIRE: @@ -283,7 +278,7 @@ uhidev_use_rdesc(struct uhidev_softc *sc break; case USB_PRODUCT_WACOM_GRAPHIRE3_4X5: case USB_PRODUCT_WACOM_GRAPHIRE4_4X5: - uhidev_set_report(&wacom, UHID_FEATURE_REPORT, + uhidev_set_report(sc, UHID_FEATURE_REPORT, 2, &reportbuf, sizeof(reportbuf)); size = sizeof(uhid_graphire3_4x5_report_descr); descptr = uhid_graphire3_4x5_report_descr; @@ -628,13 +623,13 @@ uhidev_close(struct uhidev *scd) } } -usbd_status -uhidev_set_report(struct uhidev *scd, int type, int id, void *data, int len) +int +uhidev_set_report(struct uhidev_softc *sc, int type, int id, void *data, + int len) { - struct uhidev_softc *sc = scd->sc_parent; usb_device_request_t req; - usbd_status err; char *buf = data; + int actlen = len; /* Prepend the reportID. */ if (id > 0) { @@ -650,22 +645,22 @@ uhidev_set_report(struct uhidev *scd, in USETW(req.wIndex, sc->sc_ifaceno); USETW(req.wLength, len); - err = usbd_do_request(sc->sc_udev, &req, buf); + if (usbd_do_request(sc->sc_udev, &req, buf)) + actlen = -1; if (id > 0) free(buf, M_TEMP, len); - return (err); + return (actlen); } -usbd_status -uhidev_set_report_async(struct uhidev *scd, int type, int id, void *data, +int +uhidev_set_report_async(struct uhidev_softc *sc, int type, int id, void *data, int len) { - struct uhidev_softc *sc = scd->sc_parent; usb_device_request_t req; - usbd_status err; char *buf = data; + int actlen = len; /* Prepend the reportID. */ if (id > 0) { @@ -683,7 +678,8 @@ uhidev_set_report_async(struct uhidev *s USETW(req.wIndex, sc->sc_ifaceno); USETW(req.wLength, len); - err = usbd_do_request_async(sc->sc_udev, &req, buf); + if (usbd_do_request_async(sc->sc_udev, &req, buf)) + actlen = -1; /* * Since report requests are write-only it is safe to free @@ -693,14 +689,22 @@ uhidev_set_report_async(struct uhidev *s if (id > 0) free(buf, M_TEMP, len); - return (err); + return (actlen); } -usbd_status -uhidev_get_report(struct uhidev *scd, int type, int id, void *data, int len) +int +uhidev_get_report(struct uhidev_softc *sc, int type, int id, void *data, + int len) { - struct uhidev_softc *sc = scd->sc_parent; usb_device_request_t req; + char *buf = data; + usbd_status err; + int actlen; + + if (id > 0) { + len++; + buf = malloc(len, M_TEMP, M_WAITOK|M_ZERO); + } req.bmRequestType = UT_READ_CLASS_INTERFACE; req.bRequest = UR_GET_REPORT; @@ -708,7 +712,18 @@ uhidev_get_report(struct uhidev *scd, in USETW(req.wIndex, sc->sc_ifaceno); USETW(req.wLength, len); - return (usbd_do_request(sc->sc_udev, &req, data)); + err = usbd_do_request_flags(sc->sc_udev, &req, buf, 0, &actlen, + USBD_DEFAULT_TIMEOUT); + if (err != USBD_NORMAL_COMPLETION && err != USBD_SHORT_XFER) + actlen = -1; + + /* Skip the reportID. */ + if (id > 0) { + memcpy(data, buf + 1, len - 1); + free(buf, M_TEMP, len); + } + + return (actlen); } usbd_status @@ -748,8 +763,7 @@ uhidev_ioctl(struct uhidev *sc, u_long c { struct usb_ctl_report_desc *rd; struct usb_ctl_report *re; - int size, extra; - usbd_status err; + int size; void *desc; switch (cmd) { @@ -775,12 +789,8 @@ uhidev_ioctl(struct uhidev *sc, u_long c default: return EINVAL; } - extra = sc->sc_report_id != 0; - err = uhidev_get_report(sc, re->ucr_report, sc->sc_report_id, - re->ucr_data, size + extra); - if (extra) - memcpy(re->ucr_data, re->ucr_data + 1, size); - if (err) + if (uhidev_get_report(sc->sc_parent, re->ucr_report, + sc->sc_report_id, re->ucr_data, size) != size) return EIO; break; case USB_SET_REPORT: @@ -798,9 +808,8 @@ uhidev_ioctl(struct uhidev *sc, u_long c default: return EINVAL; } - err = uhidev_set_report(sc, re->ucr_report, - sc->sc_report_id, re->ucr_data, size); - if (err) + if (uhidev_set_report(sc->sc_parent, re->ucr_report, + sc->sc_report_id, re->ucr_data, size) != size) return EIO; break; case USB_GET_REPORT_ID: Index: uhidev.h =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/uhidev.h,v retrieving revision 1.20 diff -u -p -r1.20 uhidev.h --- uhidev.h 24 Apr 2014 09:40:28 -0000 1.20 +++ uhidev.h 11 Dec 2014 09:50:14 -0000 @@ -88,7 +88,7 @@ void uhidev_get_report_desc(struct uhide int uhidev_open(struct uhidev *); void uhidev_close(struct uhidev *); int uhidev_ioctl(struct uhidev *, u_long, caddr_t, int, struct proc *); -usbd_status uhidev_set_report(struct uhidev *, int, int, void *, int); -usbd_status uhidev_set_report_async(struct uhidev *, int, int, void *, int); -usbd_status uhidev_get_report(struct uhidev *, int, int, void *, int); +int uhidev_set_report(struct uhidev_softc *, int, int, void *, int); +int uhidev_set_report_async(struct uhidev_softc *, int, int, void *, int); +int uhidev_get_report(struct uhidev_softc *, int, int, void *, int); usbd_status uhidev_write(struct uhidev_softc *, void *, int); Index: ukbd.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/ukbd.c,v retrieving revision 1.68 diff -u -p -r1.68 ukbd.c --- ukbd.c 21 Aug 2014 14:52:55 -0000 1.68 +++ ukbd.c 11 Dec 2014 09:50:14 -0000 @@ -363,8 +363,8 @@ ukbd_set_leds(void *v, int leds) return; if (sc->sc_ledsize && hidkbd_set_leds(kbd, leds, &res) != 0) - uhidev_set_report_async(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, &res, 1); + uhidev_set_report_async(sc->sc_hdev.sc_parent, + UHID_OUTPUT_REPORT, sc->sc_hdev.sc_report_id, &res, 1); } int Index: uoak_subr.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/uoak_subr.c,v retrieving revision 1.4 diff -u -p -r1.4 uoak_subr.c --- uoak_subr.c 15 Apr 2014 09:14:27 -0000 1.4 +++ uoak_subr.c 11 Dec 2014 09:50:14 -0000 @@ -51,8 +51,11 @@ int uoak_check_device_ready(struct uoak_softc *sc) { - if (uhidev_get_report(sc->sc_hdev, UHID_FEATURE_REPORT, - sc->sc_hdev->sc_report_id, &sc->sc_buf, sc->sc_flen)) + int actlen; + + actlen = uhidev_get_report(sc->sc_hdev->sc_parent, UHID_FEATURE_REPORT, + sc->sc_hdev->sc_report_id, &sc->sc_buf, sc->sc_flen); + if (actlen != sc->sc_flen) return EIO; if (sc->sc_buf[0] != 0xff) @@ -64,13 +67,15 @@ uoak_check_device_ready(struct uoak_soft int uoak_set_cmd(struct uoak_softc *sc) { + int actlen; sc->sc_rcmd.dir = OAK_SET; while (uoak_check_device_ready(sc) < 0) usbd_delay_ms(sc->sc_udev, UOAK_RETRY_DELAY); - if (uhidev_set_report(sc->sc_hdev, UHID_FEATURE_REPORT, - sc->sc_hdev->sc_report_id, &sc->sc_rcmd, sc->sc_flen)) + actlen = uhidev_set_report(sc->sc_hdev->sc_parent, UHID_FEATURE_REPORT, + sc->sc_hdev->sc_report_id, &sc->sc_rcmd, sc->sc_flen); + if (actlen != sc->sc_flen) return EIO; return 0; @@ -79,6 +84,7 @@ uoak_set_cmd(struct uoak_softc *sc) int uoak_get_cmd(struct uoak_softc *sc) { + int actlen; sc->sc_rcmd.dir = OAK_GET; /* check the device is ready to request */ @@ -86,8 +92,9 @@ uoak_get_cmd(struct uoak_softc *sc) usbd_delay_ms(sc->sc_udev, UOAK_RETRY_DELAY); /* issue request */ - if (uhidev_set_report(sc->sc_hdev, UHID_FEATURE_REPORT, - sc->sc_hdev->sc_report_id, &sc->sc_rcmd, sc->sc_flen)) + actlen = uhidev_set_report(sc->sc_hdev->sc_parent, UHID_FEATURE_REPORT, + sc->sc_hdev->sc_report_id, &sc->sc_rcmd, sc->sc_flen); + if (actlen != sc->sc_flen) return EIO; /* wait till the device ready to return the request */ Index: upd.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/upd.c,v retrieving revision 1.10 diff -u -p -r1.10 upd.c --- upd.c 12 Jul 2014 18:48:52 -0000 1.10 +++ upd.c 11 Dec 2014 09:50:14 -0000 @@ -263,7 +263,7 @@ upd_refresh(void *arg) struct upd_softc *sc = (struct upd_softc *)arg; struct upd_report *report; uint8_t buf[256]; - int repid, err; + int repid, actlen; for (repid = 0; repid < sc->sc_max_repid; repid++) { report = &sc->sc_reports[repid]; @@ -271,18 +271,18 @@ upd_refresh(void *arg) continue; memset(buf, 0x0, sizeof(buf)); - /* - * XXX uhidev_get_report() is not clever enough to handle - * non-NUl reportID, so add an extra byte for it. - */ - err = uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - repid, buf, report->size + 1); - if (err) { - DPRINTF(("read failure: reportid=%02x err=%d\n", repid, - err)); + actlen = uhidev_get_report(sc->sc_hdev.sc_parent, + UHID_FEATURE_REPORT, repid, buf, 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); } } @@ -358,13 +358,12 @@ upd_update_sensors(struct upd_softc *sc, break; } - /* XXX first byte which is the report id */ - hdata = hid_get_data(buf + 1, len, &sensor->hitem.loc); + hdata = hid_get_data(buf, len, &sensor->hitem.loc); sensor->ksensor.value = hdata * adjust; sensor->ksensor.status = SENSOR_S_OK; sensor->ksensor.flags &= ~SENSOR_FINVALID; - DPRINTF(("%s: hidget data: %d\n", + DPRINTF(("%s: hidget data: %lu\n", sc->sc_sensordev.xname, hdata)); } } Index: uthum.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/uthum.c,v retrieving revision 1.27 diff -u -p -r1.27 uthum.c --- uthum.c 15 Apr 2014 09:14:27 -0000 1.27 +++ uthum.c 11 Dec 2014 09:50:14 -0000 @@ -285,25 +285,29 @@ uthum_intr(struct uhidev *addr, void *ib int uthum_issue_cmd(struct uthum_softc *sc, uint8_t target_cmd, int delay) { - int i; uint8_t cmdbuf[32]; + int i, actlen; bzero(cmdbuf, sizeof(cmdbuf)); memcpy(cmdbuf, cmd_issue, sizeof(cmd_issue)); - if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen)) + actlen = uhidev_set_report(sc->sc_hdev.sc_parent, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen); + if (actlen != sc->sc_olen) return EIO; bzero(cmdbuf, sizeof(cmdbuf)); cmdbuf[0] = target_cmd; - if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen)) + actlen = uhidev_set_report(sc->sc_hdev.sc_parent, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen); + if (actlen != sc->sc_olen) return EIO; bzero(cmdbuf, sizeof(cmdbuf)); for (i = 0; i < 7; i++) { - if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen)) + actlen = uhidev_set_report(sc->sc_hdev.sc_parent, + UHID_OUTPUT_REPORT, sc->sc_hdev.sc_report_id, cmdbuf, + sc->sc_olen); + if (actlen != sc->sc_olen) return EIO; } @@ -329,8 +333,8 @@ uthum_read_data(struct uthum_softc *sc, bzero(cmdbuf, sizeof(cmdbuf)); memcpy(cmdbuf, cmd_query, sizeof(cmd_query)); - if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen)) + if (uhidev_set_report(sc->sc_hdev.sc_parent, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen) != sc->sc_olen) return EIO; /* wait if required */ @@ -338,8 +342,8 @@ uthum_read_data(struct uthum_softc *sc, tsleep(&sc->sc_sensortask, 0, "uthum", (delay*hz+999)/1000 + 1); /* get answer */ - if (uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - sc->sc_hdev.sc_report_id, report, sc->sc_flen)) + if (uhidev_get_report(sc->sc_hdev.sc_parent, UHID_FEATURE_REPORT, + sc->sc_hdev.sc_report_id, report, sc->sc_flen) != sc->sc_flen) return EIO; memcpy(buf, report, len); return 0; Index: utrh.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/utrh.c,v retrieving revision 1.16 diff -u -p -r1.16 utrh.c --- utrh.c 12 Jul 2014 18:48:53 -0000 1.16 +++ utrh.c 11 Dec 2014 09:50:14 -0000 @@ -211,14 +211,14 @@ utrh_refresh(void *arg) bzero(ledbuf, sizeof(ledbuf)); ledbuf[0] = 0x3; ledbuf[1] = 0x1; - if (uhidev_set_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - sc->sc_hdev.sc_report_id, ledbuf, sc->sc_flen)) + 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) printf("LED request failed\n"); /* issue query */ uint8_t cmdbuf[] = {0x31, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00}; - if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen)) + 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) return; /* wait till sensor data are updated, 1s will be enough */ @@ -226,8 +226,8 @@ utrh_refresh(void *arg) /* turn off LED 1 */ ledbuf[1] = 0x0; - if (uhidev_set_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - sc->sc_hdev.sc_report_id, ledbuf, sc->sc_flen)) + 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) printf("LED request failed\n"); temp_tick = (sc->sc_ibuf[2] * 256 + sc->sc_ibuf[3]) & 0x3fff; Index: utwitch.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/utwitch.c,v retrieving revision 1.13 diff -u -p -r1.13 utwitch.c --- utwitch.c 12 Jul 2014 18:48:53 -0000 1.13 +++ utwitch.c 11 Dec 2014 09:50:14 -0000 @@ -267,15 +267,13 @@ void utwitch_set_mode(struct utwitch_softc *sc, uint8_t val) { uint8_t req[8]; - usbd_status err; memset(req, CMD_PADDING, sizeof(req)); req[0] = CMD_MODE; req[1] = val; req[2] = CMD_EOF; - err = uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, req, sc->sc_olen); - if (err) { + if (uhidev_set_report(sc->sc_hdev.sc_parent, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, req, sc->sc_olen) != sc->sc_olen) { printf("uhidev_set_report error:EIO\n"); return; } @@ -294,8 +292,8 @@ utwitch_read_value_request(struct utwitc req[1] = CMD_EOF; sc->issueing_cmd = CMD_READ; sc->accepted_cmd = CMD_NONE; - if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, req, sc->sc_olen)) + if (uhidev_set_report(sc->sc_hdev.sc_parent, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, req, sc->sc_olen) != sc->sc_olen) return; /* wait till sensor data are updated, 500ms will be enough */ @@ -317,8 +315,8 @@ utwitch_write_value_request(struct utwit sc->issueing_cmd = CMD_WRITE; sc->accepted_cmd = CMD_NONE; - if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_hdev.sc_report_id, req, sc->sc_olen)) + if (uhidev_set_report(sc->sc_hdev.sc_parent, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, req, sc->sc_olen) != sc->sc_olen) return; /* wait till sensor data are updated, 250ms will be enough */