aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2020-11-10 13:21:02 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2020-11-10 13:21:02 +0000
commitc985e1a4cdf3023c4f500da8ad34cffb35cd8724 (patch)
treebd4a48524a6aadb2d1809aa28bfbb49874bbc357
parentca7f570097cc9cf45566ec4353d6b064359eb0e5 (diff)
downloadsrc-c985e1a4cdf3023c4f500da8ad34cffb35cd8724.tar.gz
src-c985e1a4cdf3023c4f500da8ad34cffb35cd8724.zip
MFC r367236:
Implement the USB_GET_DEVICEINFO ioctl(2) for uhid(4). Submitted by: pedro martelletto <pedro@ambientworks.net> Sponsored by: Mellanox Technologies // NVIDIA Networking
Notes
Notes: svn path=/stable/11/; revision=367561
-rw-r--r--share/man/man4/uhid.47
-rw-r--r--sys/dev/usb/input/uhid.c21
-rw-r--r--sys/dev/usb/usb_generic.c10
-rw-r--r--sys/dev/usb/usb_generic.h1
4 files changed, 32 insertions, 7 deletions
diff --git a/share/man/man4/uhid.4 b/share/man/man4/uhid.4
index fc90fff40350..badb2f59d31d 100644
--- a/share/man/man4/uhid.4
+++ b/share/man/man4/uhid.4
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 22, 2006
+.Dd Oct 31, 2020
.Dt UHID 4
.Os
.Sh NAME
@@ -114,6 +114,11 @@ It should be
or
.Dv UHID_FEATURE_REPORT .
This call may fail if the device does not support this feature.
+.It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info"
+Returns information about the device, like USB vendor ID and USB product ID.
+This call will not issue any USB transactions.
+Also refer to
+.Xr ugen 4 .
.El
.Pp
Use
diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c
index 71aae5d30988..11ec2b7092bc 100644
--- a/sys/dev/usb/input/uhid.c
+++ b/sys/dev/usb/input/uhid.c
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
#include <dev/usb/usb_ioctl.h>
+#include <dev/usb/usb_generic.h>
#define USB_DEBUG_VAR uhid_debug
#include <dev/usb/usb_debug.h>
@@ -141,11 +142,13 @@ static usb_fifo_cmd_t uhid_stop_write;
static usb_fifo_open_t uhid_open;
static usb_fifo_close_t uhid_close;
static usb_fifo_ioctl_t uhid_ioctl;
+static usb_fifo_ioctl_t uhid_ioctl_post;
static struct usb_fifo_methods uhid_fifo_methods = {
.f_open = &uhid_open,
.f_close = &uhid_close,
.f_ioctl = &uhid_ioctl,
+ .f_ioctl_post = &uhid_ioctl_post,
.f_start_read = &uhid_start_read,
.f_stop_read = &uhid_stop_read,
.f_start_write = &uhid_start_write,
@@ -645,6 +648,24 @@ uhid_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr,
break;
default:
+ error = ENOIOCTL;
+ break;
+ }
+ return (error);
+}
+
+static int
+uhid_ioctl_post(struct usb_fifo *fifo, u_long cmd, void *addr,
+ int fflags)
+{
+ int error;
+
+ switch (cmd) {
+ case USB_GET_DEVICEINFO:
+ error = ugen_fill_deviceinfo(fifo, addr);
+ break;
+
+ default:
error = EINVAL;
break;
}
diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c
index 1d1513d10ef4..a256376bf9f9 100644
--- a/sys/dev/usb/usb_generic.c
+++ b/sys/dev/usb/usb_generic.c
@@ -107,8 +107,6 @@ static int ugen_set_interface(struct usb_fifo *, uint8_t, uint8_t);
static int ugen_get_cdesc(struct usb_fifo *, struct usb_gen_descriptor *);
static int ugen_get_sdesc(struct usb_fifo *, struct usb_gen_descriptor *);
static int ugen_get_iface_driver(struct usb_fifo *f, struct usb_gen_descriptor *ugd);
-static int usb_gen_fill_deviceinfo(struct usb_fifo *,
- struct usb_device_info *);
static int ugen_re_enumerate(struct usb_fifo *);
static int ugen_iface_ioctl(struct usb_fifo *, u_long, void *, int);
static uint8_t ugen_fs_get_complete(struct usb_fifo *, uint8_t *);
@@ -815,7 +813,7 @@ ugen_get_iface_driver(struct usb_fifo *f, struct usb_gen_descriptor *ugd)
}
/*------------------------------------------------------------------------*
- * usb_gen_fill_deviceinfo
+ * ugen_fill_deviceinfo
*
* This function dumps information about an USB device to the
* structure pointed to by the "di" argument.
@@ -824,8 +822,8 @@ ugen_get_iface_driver(struct usb_fifo *f, struct usb_gen_descriptor *ugd)
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
-static int
-usb_gen_fill_deviceinfo(struct usb_fifo *f, struct usb_device_info *di)
+int
+ugen_fill_deviceinfo(struct usb_fifo *f, struct usb_device_info *di)
{
struct usb_device *udev;
struct usb_device *hub;
@@ -2214,7 +2212,7 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void *addr, int fflags)
case USB_DEVICEINFO:
case USB_GET_DEVICEINFO:
- error = usb_gen_fill_deviceinfo(f, addr);
+ error = ugen_fill_deviceinfo(f, addr);
break;
case USB_DEVICESTATS:
diff --git a/sys/dev/usb/usb_generic.h b/sys/dev/usb/usb_generic.h
index 835ec72afd09..4d3ef764b963 100644
--- a/sys/dev/usb/usb_generic.h
+++ b/sys/dev/usb/usb_generic.h
@@ -29,5 +29,6 @@
extern struct usb_fifo_methods usb_ugen_methods;
int ugen_do_request(struct usb_fifo *f, struct usb_ctl_request *ur);
+int ugen_fill_deviceinfo(struct usb_fifo *f, struct usb_device_info *di);
#endif /* _USB_GENERIC_H_ */