From 47c60726dd053b9975b716fb81fc8bad188d773d Mon Sep 17 00:00:00 2001 From: Joshua Stein Date: Sat, 25 Aug 2018 18:32:06 +0000 Subject: Move HID->bus constant conversion for HID report types out of ihidev into hidmt. The HID code uses hid_feature, hid_input, and hid_output constants to refer to report types internally that then need to be converted to their bus-level counterparts before actually getting sent out (so hid_feature becomes UHID_FEATURE_REPORT for USB, I2C_HID_REPORT_TYPE_FEATURE for i2c). This conversion was hard-coded in ihidev but ihidev_[gs]et_report should assume the type passed is already an i2c-level define, not a hid one. This is how uhidev does it. Add a conversion routine callback that any hidmt callers need to set so that hidmt can convert hid constants to the bus-level versions. Also add a similar conversion function to uhidev. ok deraadt --- sys/dev/usb/uhidev.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sys/dev/usb/uhidev.c') diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c index a61625e64c1..7c02c82f7d5 100644 --- a/sys/dev/usb/uhidev.c +++ b/sys/dev/usb/uhidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.c,v 1.75 2017/04/08 02:57:25 deraadt Exp $ */ +/* $OpenBSD: uhidev.c,v 1.76 2018/08/25 18:32:05 jcs Exp $ */ /* $NetBSD: uhidev.c,v 1.14 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -639,6 +639,21 @@ uhidev_close(struct uhidev *scd) } } +int +uhidev_report_type_conv(int hid_type_id) +{ + switch (hid_type_id) { + case hid_input: + return UHID_INPUT_REPORT; + case hid_output: + return UHID_OUTPUT_REPORT; + case hid_feature: + return UHID_FEATURE_REPORT; + default: + return -1; + } +} + int uhidev_set_report(struct uhidev_softc *sc, int type, int id, void *data, int len) -- cgit v1.2.3