diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-04-15 09:14:28 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-04-15 09:14:28 +0000 |
commit | 7b3d33ade85bbb91644090b39e1d10645747a407 (patch) | |
tree | 067cb6ae84b43262aee298b2502debdca9eb4e9c /sys/dev | |
parent | a26bb7a1ed69631c46838721abd3907e153d0a98 (diff) |
Modify the uhidev_*_report() methods to always take a report ID argument
instead of using the default, per-driver, one. This is a step to move
away from the 1 report ID <-> 1 driver design which is no longer true
since the addition of upd(4).
ok andre@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/ucycom.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/ugold.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/uhid.c | 10 | ||||
-rw-r--r-- | sys/dev/usb/uhidev.c | 35 | ||||
-rw-r--r-- | sys/dev/usb/uhidev.h | 8 | ||||
-rw-r--r-- | sys/dev/usb/ukbd.c | 4 | ||||
-rw-r--r-- | sys/dev/usb/uoak_subr.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/upd.c | 16 | ||||
-rw-r--r-- | sys/dev/usb/uthum.c | 12 | ||||
-rw-r--r-- | sys/dev/usb/utrh.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/utwitch.c | 14 |
11 files changed, 64 insertions, 63 deletions
diff --git a/sys/dev/usb/ucycom.c b/sys/dev/usb/ucycom.c index 80fa2e1b13e..10ee32d5f18 100644 --- a/sys/dev/usb/ucycom.c +++ b/sys/dev/usb/ucycom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucycom.c,v 1.25 2014/03/19 08:59:36 mpi Exp $ */ +/* $OpenBSD: ucycom.c,v 1.26 2014/04/15 09:14:27 mpi Exp $ */ /* $NetBSD: ucycom.c,v 1.3 2005/08/05 07:27:47 skrll Exp $ */ /* @@ -459,7 +459,7 @@ ucycom_param(void *addr, int portno, struct termios *t) report[3] = (baud >> 24) & 0xff; report[4] = cfg; err = uhidev_set_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - report, sc->sc_flen); + 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))); @@ -562,7 +562,7 @@ ucycom_get_cfg(struct ucycom_softc *sc) uint8_t report[5]; err = uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - report, sc->sc_flen); + 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]; DPRINTF(("ucycom_configure: device reports %d baud, %d-%c-%d (%d)\n", baud, diff --git a/sys/dev/usb/ugold.c b/sys/dev/usb/ugold.c index ad688c9d688..3679424bf66 100644 --- a/sys/dev/usb/ugold.c +++ b/sys/dev/usb/ugold.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ugold.c,v 1.4 2014/03/19 08:59:37 mpi Exp $ */ +/* $OpenBSD: ugold.c,v 1.5 2014/04/15 09:14:27 mpi Exp $ */ /* * Copyright (c) 2013 Takayoshi SASANO <sasano@openbsd.org> @@ -257,6 +257,6 @@ 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, - cmd, len); + return uhidev_set_report_async(&sc->sc_hdev, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, cmd, len); } diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index a2966a1ecf9..51b3e89a8ba 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhid.c,v 1.56 2014/03/19 08:59:37 mpi Exp $ */ +/* $OpenBSD: uhid.c,v 1.57 2014/04/15 09:14:27 mpi Exp $ */ /* $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -269,7 +269,8 @@ uhid_do_read(struct uhid_softc *sc, struct uio *uio, int flag) DPRINTFN(1, ("uhidread immed\n")); extra = sc->sc_hdev.sc_report_id != 0; err = uhidev_get_report(&sc->sc_hdev, UHID_INPUT_REPORT, - buffer, sc->sc_hdev.sc_isize + extra); + sc->sc_hdev.sc_report_id, buffer, + sc->sc_hdev.sc_isize + extra); if (err) return (EIO); return (uiomove(buffer+extra, sc->sc_hdev.sc_isize, uio)); @@ -346,7 +347,7 @@ uhid_do_write(struct uhid_softc *sc, struct uio *uio, int flag) error = uiomove(sc->sc_obuf, size, uio); if (!error) { err = uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - sc->sc_obuf, size); + sc->sc_hdev.sc_report_id, sc->sc_obuf, size); if (err) error = EIO; } @@ -410,7 +411,8 @@ uhid_do_ioctl(struct uhid_softc *sc, u_long cmd, caddr_t addr, if (*(int *)addr) { extra = sc->sc_hdev.sc_report_id != 0; err = uhidev_get_report(&sc->sc_hdev, UHID_INPUT_REPORT, - buffer, sc->sc_hdev.sc_isize + extra); + sc->sc_hdev.sc_report_id, buffer, + sc->sc_hdev.sc_isize + extra); if (err) return (EOPNOTSUPP); diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c index af9bec6696e..e7c87d30d07 100644 --- a/sys/dev/usb/uhidev.c +++ b/sys/dev/usb/uhidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.c,v 1.57 2014/03/23 12:20:14 andre Exp $ */ +/* $OpenBSD: uhidev.c,v 1.58 2014/04/15 09:14:27 mpi Exp $ */ /* $NetBSD: uhidev.c,v 1.14 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -602,21 +602,21 @@ uhidev_close(struct uhidev *scd) } usbd_status -uhidev_set_report(struct uhidev *scd, int type, void *data, int len) +uhidev_set_report(struct uhidev *scd, int type, int id, void *data, int len) { char *buf; usbd_status retstat; - if (scd->sc_report_id == 0) + if (id == 0) return usbd_set_report(scd->sc_parent->sc_iface, type, - scd->sc_report_id, data, len); + id, data, len); buf = malloc(len + 1, M_TEMP, M_WAITOK); - buf[0] = scd->sc_report_id; + buf[0] = id; memcpy(buf+1, data, len); retstat = usbd_set_report(scd->sc_parent->sc_iface, type, - scd->sc_report_id, buf, len + 1); + id, buf, len + 1); free(buf, M_TEMP); @@ -624,23 +624,24 @@ uhidev_set_report(struct uhidev *scd, int type, void *data, int len) } usbd_status -uhidev_set_report_async(struct uhidev *scd, int type, void *data, int len) +uhidev_set_report_async(struct uhidev *scd, int type, int id, void *data, + int len) { char *buf; usbd_status retstat; - if (scd->sc_report_id == 0) + if (id == 0) return usbd_set_report_async(scd->sc_parent->sc_iface, type, - scd->sc_report_id, data, len); + id, data, len); buf = malloc(len + 1, M_TEMP, M_NOWAIT); if (buf == NULL) return (USBD_NOMEM); - buf[0] = scd->sc_report_id; + buf[0] = id; memcpy(buf+1, data, len); retstat = usbd_set_report_async(scd->sc_parent->sc_iface, type, - scd->sc_report_id, buf, len + 1); + id, buf, len + 1); /* * Since report requests are write-only it is safe to free @@ -653,10 +654,9 @@ uhidev_set_report_async(struct uhidev *scd, int type, void *data, int len) } usbd_status -uhidev_get_report(struct uhidev *scd, int type, void *data, int len) +uhidev_get_report(struct uhidev *scd, int type, int id, void *data, int len) { - return usbd_get_report(scd->sc_parent->sc_iface, type, - scd->sc_report_id, data, len); + return usbd_get_report(scd->sc_parent->sc_iface, type, id, data, len); } usbd_status @@ -724,8 +724,8 @@ uhidev_ioctl(struct uhidev *sc, u_long cmd, caddr_t addr, int flag, return EINVAL; } extra = sc->sc_report_id != 0; - err = uhidev_get_report(sc, re->ucr_report, re->ucr_data, - size + extra); + 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) @@ -746,7 +746,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, re->ucr_data, size); + err = uhidev_set_report(sc, re->ucr_report, + sc->sc_report_id, re->ucr_data, size); if (err) return EIO; break; diff --git a/sys/dev/usb/uhidev.h b/sys/dev/usb/uhidev.h index eb8f97a285d..f0568ecbf82 100644 --- a/sys/dev/usb/uhidev.h +++ b/sys/dev/usb/uhidev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.h,v 1.18 2014/03/19 08:59:37 mpi Exp $ */ +/* $OpenBSD: uhidev.h,v 1.19 2014/04/15 09:14:27 mpi Exp $ */ /* $NetBSD: uhidev.h,v 1.3 2002/10/08 09:56:17 dan Exp $ */ /* @@ -87,7 +87,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, void *, int); -usbd_status uhidev_set_report_async(struct uhidev *, int, void *, int); -usbd_status uhidev_get_report(struct uhidev *scd, int type, void *data,int len); +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); usbd_status uhidev_write(struct uhidev_softc *, void *, int); diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index 1774a3142f4..1ae3679bb52 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukbd.c,v 1.63 2014/01/26 17:48:08 miod Exp $ */ +/* $OpenBSD: ukbd.c,v 1.64 2014/04/15 09:14:27 mpi Exp $ */ /* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -373,7 +373,7 @@ ukbd_set_leds(void *v, int leds) if (sc->sc_ledsize && hidkbd_set_leds(kbd, leds, &res) != 0) uhidev_set_report_async(&sc->sc_hdev, UHID_OUTPUT_REPORT, - &res, 1); + 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 bd4eef13d2c..da061a06eb0 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.3 2013/03/28 03:58:03 tedu Exp $ */ +/* $OpenBSD: uoak_subr.c,v 1.4 2014/04/15 09:14:27 mpi Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -52,7 +52,7 @@ int uoak_check_device_ready(struct uoak_softc *sc) { if (uhidev_get_report(sc->sc_hdev, UHID_FEATURE_REPORT, - &sc->sc_buf, sc->sc_flen)) + sc->sc_hdev->sc_report_id, &sc->sc_buf, sc->sc_flen)) return EIO; if (sc->sc_buf[0] != 0xff) @@ -70,7 +70,7 @@ uoak_set_cmd(struct uoak_softc *sc) usbd_delay_ms(sc->sc_udev, UOAK_RETRY_DELAY); if (uhidev_set_report(sc->sc_hdev, UHID_FEATURE_REPORT, - &sc->sc_rcmd, sc->sc_flen)) + sc->sc_hdev->sc_report_id, &sc->sc_rcmd, sc->sc_flen)) return EIO; return 0; @@ -87,7 +87,7 @@ uoak_get_cmd(struct uoak_softc *sc) /* issue request */ if (uhidev_set_report(sc->sc_hdev, UHID_FEATURE_REPORT, - &sc->sc_rcmd, sc->sc_flen)) + sc->sc_hdev->sc_report_id, &sc->sc_rcmd, 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 c843aa4de3e..17a4a0053cc 100644 --- a/sys/dev/usb/upd.c +++ b/sys/dev/usb/upd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: upd.c,v 1.6 2014/04/07 21:54:13 andre Exp $ */ +/* $OpenBSD: upd.c,v 1.7 2014/04/15 09:14:27 mpi Exp $ */ /* * Copyright (c) 2014 Andre de Oliveira <andre@openbsd.org> @@ -307,14 +307,12 @@ upd_refresh(void *arg) continue; memset(buf, 0x0, sizeof(buf)); - sc->sc_hdev.sc_report_id = repid; - err = uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, buf, - report->size + 1); /* - * cheating with an extra byte on size - * here, hid_report_size() * is - * incorrectly telling us report lengths - * are 1 byte smaller - */ + /* + * 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)); diff --git a/sys/dev/usb/uthum.c b/sys/dev/usb/uthum.c index 8abbb0ad4f0..71ad19c5583 100644 --- a/sys/dev/usb/uthum.c +++ b/sys/dev/usb/uthum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthum.c,v 1.26 2014/03/19 08:59:37 mpi Exp $ */ +/* $OpenBSD: uthum.c,v 1.27 2014/04/15 09:14:27 mpi Exp $ */ /* * Copyright (c) 2009, 2010 Yojiro UO <yuo@nui.org> @@ -291,19 +291,19 @@ uthum_issue_cmd(struct uthum_softc *sc, uint8_t target_cmd, int delay) bzero(cmdbuf, sizeof(cmdbuf)); memcpy(cmdbuf, cmd_issue, sizeof(cmd_issue)); if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - cmdbuf, sc->sc_olen)) + sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen)) return EIO; bzero(cmdbuf, sizeof(cmdbuf)); cmdbuf[0] = target_cmd; if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, - cmdbuf, sc->sc_olen)) + sc->sc_hdev.sc_report_id, cmdbuf, 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, - cmdbuf, sc->sc_olen)) + sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen)) return EIO; } @@ -330,7 +330,7 @@ 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, - cmdbuf, sc->sc_olen)) + sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen)) return EIO; /* wait if required */ @@ -339,7 +339,7 @@ uthum_read_data(struct uthum_softc *sc, uint8_t target_cmd, uint8_t *buf, /* get answer */ if (uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - report, sc->sc_flen)) + sc->sc_hdev.sc_report_id, report, 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 5fc8b92e5d2..17eb6a87665 100644 --- a/sys/dev/usb/utrh.c +++ b/sys/dev/usb/utrh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utrh.c,v 1.13 2014/03/19 08:59:37 mpi Exp $ */ +/* $OpenBSD: utrh.c,v 1.14 2014/04/15 09:14:27 mpi Exp $ */ /* * Copyright (c) 2009 Yojiro UO <yuo@nui.org> @@ -209,13 +209,13 @@ utrh_refresh(void *arg) ledbuf[0] = 0x3; ledbuf[1] = 0x1; if (uhidev_set_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - ledbuf, sc->sc_flen)) + sc->sc_hdev.sc_report_id, ledbuf, 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, - cmdbuf, sc->sc_olen)) + sc->sc_hdev.sc_report_id, cmdbuf, sc->sc_olen)) return; /* wait till sensor data are updated, 1s will be enough */ @@ -224,7 +224,7 @@ utrh_refresh(void *arg) /* turn off LED 1 */ ledbuf[1] = 0x0; if (uhidev_set_report(&sc->sc_hdev, UHID_FEATURE_REPORT, - ledbuf, sc->sc_flen)) + sc->sc_hdev.sc_report_id, ledbuf, 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 2230211f092..69dd6359f13 100644 --- a/sys/dev/usb/utwitch.c +++ b/sys/dev/usb/utwitch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utwitch.c,v 1.10 2014/03/19 08:59:37 mpi Exp $ */ +/* $OpenBSD: utwitch.c,v 1.11 2014/04/15 09:14:27 mpi Exp $ */ /* * Copyright (c) 2010 Yojiro UO <yuo@nui.org> @@ -270,8 +270,8 @@ utwitch_set_mode(struct utwitch_softc *sc, uint8_t val) req[0] = CMD_MODE; req[1] = val; req[2] = CMD_EOF; - err = uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, req, - sc->sc_olen); + err = uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, req, sc->sc_olen); if (err) { printf("uhidev_set_report error:EIO\n"); return; @@ -291,8 +291,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, req, - sc->sc_olen)) + if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, req, sc->sc_olen)) return; /* wait till sensor data are updated, 500ms will be enough */ @@ -314,8 +314,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, req, - sc->sc_olen)) + if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, + sc->sc_hdev.sc_report_id, req, sc->sc_olen)) return; /* wait till sensor data are updated, 250ms will be enough */ |