diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-12-11 18:39:29 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-12-11 18:39:29 +0000 |
commit | 477855b2148747cf0d884fbb75161e499ca2e59b (patch) | |
tree | 355e99d084405d2b06ae181119aaf6f669ff74ee /sys/dev/usb/utwitch.c | |
parent | a43ef9f4e1de588a8b9d1d58f293c60cc514c11a (diff) |
Change uhidev(4) set/get report functions in various way.
Always pass the parent uhidev(4) descriptor corresponding to the single
USB device with multiple reportIDs instead of a child.
Make uhidev_get_report() aware of non NUL reportID by prepending a byte
to the given buffer, just like uhidev_set_report{,async}() already do.
Return the number of bytes written or read upon success and -1 otherwise.
This allow callers to deal with short reads without having do mess with
xfer error codes madness.
Reviewed and tested by David Higgs.
Diffstat (limited to 'sys/dev/usb/utwitch.c')
-rw-r--r-- | sys/dev/usb/utwitch.c | 16 |
1 files changed, 7 insertions, 9 deletions
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 */ |