diff options
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/ucycom.c | 14 | ||||
-rw-r--r-- | sys/dev/usb/ugold.c | 9 | ||||
-rw-r--r-- | sys/dev/usb/uhid.c | 32 | ||||
-rw-r--r-- | sys/dev/usb/uhidev.c | 77 | ||||
-rw-r--r-- | sys/dev/usb/uhidev.h | 8 | ||||
-rw-r--r-- | sys/dev/usb/ukbd.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/uoak_subr.c | 21 | ||||
-rw-r--r-- | sys/dev/usb/upd.c | 23 | ||||
-rw-r--r-- | sys/dev/usb/uthum.c | 28 | ||||
-rw-r--r-- | sys/dev/usb/utrh.c | 14 | ||||
-rw-r--r-- | sys/dev/usb/utwitch.c | 16 |
11 files changed, 126 insertions, 122 deletions
diff --git a/sys/dev/usb/ucycom.c b/sys/dev/usb/ucycom.c index 587d5872e7f..311f1501756 100644 --- a/sys/dev/usb/ucycom.c +++ b/sys/dev/usb/ucycom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucycom.c,v 1.29 2014/07/12 20:26:33 mpi Exp $ */ +/* $OpenBSD: ucycom.c,v 1.30 2014/12/11 18:39:27 mpi Exp $ */ /* $NetBSD: ucycom.c,v 1.3 2005/08/05 07:27:47 skrll Exp $ */ /* @@ -453,13 +453,9 @@ ucycom_param(void *addr, int portno, struct termios *t) 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 reg, int onoff) 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]; diff --git a/sys/dev/usb/ugold.c b/sys/dev/usb/ugold.c index 56d1d36cf92..21c55b0a428 100644 --- a/sys/dev/usb/ugold.c +++ b/sys/dev/usb/ugold.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ugold.c,v 1.6 2014/04/29 12:53:33 mpi Exp $ */ +/* $OpenBSD: ugold.c,v 1.7 2014/12/11 18:39:27 mpi Exp $ */ /* * Copyright (c) 2013 Takayoshi SASANO <sasano@openbsd.org> @@ -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); } diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index 429282c8f06..d0f53a50425 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhid.c,v 1.58 2014/07/12 18:48:52 tedu Exp $ */ +/* $OpenBSD: uhid.c,v 1.59 2014/12/11 18:39:27 mpi Exp $ */ /* $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -259,21 +259,17 @@ uhid_do_read(struct uhid_softc *sc, struct uio *uio, int flag) { 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, struct uio *uio, int flag) { int error; int size; - usbd_status err; DPRINTFN(1, ("uhidwrite\n")); @@ -346,9 +341,9 @@ uhid_do_write(struct uhid_softc *sc, struct uio *uio, int flag) 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_long cmd, caddr_t addr, 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_long cmd, caddr_t addr, 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; diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c index 2dd88657444..c4ef58db6cd 100644 --- a/sys/dev/usb/uhidev.c +++ b/sys/dev/usb/uhidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.c,v 1.64 2014/12/08 22:00:11 mpi Exp $ */ +/* $OpenBSD: uhidev.c,v 1.65 2014/12/11 18:39:27 mpi Exp $ */ /* $NetBSD: uhidev.c,v 1.14 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -270,11 +270,6 @@ uhidev_use_rdesc(struct uhidev_softc *sc, int vendor, int product, 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, int vendor, int product, 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, int type, int id, void *data, int len) 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 *scd, int type, int id, void *data, 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 *scd, int type, int id, void *data, 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, int type, int id, void *data, int len) 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 cmd, caddr_t addr, int flag, { 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 cmd, caddr_t addr, int flag, 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 cmd, caddr_t addr, int flag, 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: diff --git a/sys/dev/usb/uhidev.h b/sys/dev/usb/uhidev.h index 4a5f9b05f82..434cc76a1fb 100644 --- a/sys/dev/usb/uhidev.h +++ b/sys/dev/usb/uhidev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.h,v 1.20 2014/04/24 09:40:28 mpi Exp $ */ +/* $OpenBSD: uhidev.h,v 1.21 2014/12/11 18:39:27 mpi Exp $ */ /* $NetBSD: uhidev.h,v 1.3 2002/10/08 09:56:17 dan Exp $ */ /* @@ -88,7 +88,7 @@ void uhidev_get_report_desc(struct uhidev_softc *, void **, int *); 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); diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index 856bbe50671..5420ceec78e 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukbd.c,v 1.68 2014/08/21 14:52:55 mpi Exp $ */ +/* $OpenBSD: ukbd.c,v 1.69 2014/12/11 18:39:27 mpi Exp $ */ /* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -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 diff --git a/sys/dev/usb/uoak_subr.c b/sys/dev/usb/uoak_subr.c index da061a06eb0..791fdd653c1 100644 --- a/sys/dev/usb/uoak_subr.c +++ b/sys/dev/usb/uoak_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoak_subr.c,v 1.4 2014/04/15 09:14:27 mpi Exp $ */ +/* $OpenBSD: uoak_subr.c,v 1.5 2014/12/11 18:39:27 mpi Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -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_softc *sc) 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 */ diff --git a/sys/dev/usb/upd.c b/sys/dev/usb/upd.c index 1772d1fa47f..cc6a3adf13e 100644 --- a/sys/dev/usb/upd.c +++ b/sys/dev/usb/upd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: upd.c,v 1.10 2014/07/12 18:48:52 tedu Exp $ */ +/* $OpenBSD: upd.c,v 1.11 2014/12/11 18:39:27 mpi Exp $ */ /* * Copyright (c) 2014 Andre de Oliveira <andre@openbsd.org> @@ -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,15 +271,11 @@ 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 != report->size) { + DPRINTF(("upd: failed to get report id=%02x\n", repid)); continue; } @@ -358,13 +354,12 @@ upd_update_sensors(struct upd_softc *sc, uint8_t *buf, unsigned int len, 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)); } } diff --git a/sys/dev/usb/uthum.c b/sys/dev/usb/uthum.c index 71ad19c5583..1cedef76b35 100644 --- a/sys/dev/usb/uthum.c +++ b/sys/dev/usb/uthum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthum.c,v 1.27 2014/04/15 09:14:27 mpi Exp $ */ +/* $OpenBSD: uthum.c,v 1.28 2014/12/11 18:39:27 mpi Exp $ */ /* * Copyright (c) 2009, 2010 Yojiro UO <yuo@nui.org> @@ -285,25 +285,29 @@ uthum_intr(struct uhidev *addr, void *ibuf, u_int len) 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, uint8_t target_cmd, uint8_t *buf, 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, uint8_t target_cmd, uint8_t *buf, 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; diff --git a/sys/dev/usb/utrh.c b/sys/dev/usb/utrh.c index a60af099744..9c1c79b5450 100644 --- a/sys/dev/usb/utrh.c +++ b/sys/dev/usb/utrh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utrh.c,v 1.16 2014/07/12 18:48:53 tedu Exp $ */ +/* $OpenBSD: utrh.c,v 1.17 2014/12/11 18:39:28 mpi Exp $ */ /* * Copyright (c) 2009 Yojiro UO <yuo@nui.org> @@ -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; diff --git a/sys/dev/usb/utwitch.c b/sys/dev/usb/utwitch.c index 62d7f73ffd0..b3a60ca9633 100644 --- a/sys/dev/usb/utwitch.c +++ b/sys/dev/usb/utwitch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utwitch.c,v 1.13 2014/07/12 18:48:53 tedu Exp $ */ +/* $OpenBSD: utwitch.c,v 1.14 2014/12/11 18:39:28 mpi Exp $ */ /* * Copyright (c) 2010 Yojiro UO <yuo@nui.org> @@ -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 utwitch_softc *sc) 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 utwitch_softc *sc, uint32_t val) 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 */ |