summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/dev/usb
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-01-21 10:13:58 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-01-21 10:13:58 +0100
commit1354d9bf97e49525282529e43dff50427f420f80 (patch)
treef0900858ccb90aedf7b66c400d90f3a3f93c0019 /freebsd/sys/dev/usb
parentUpdate to FreeBSD stable/12 2019-01-16 (diff)
downloadrtems-libbsd-1354d9bf97e49525282529e43dff50427f420f80.tar.bz2
Update to FreeBSD stable/12 2019-01-21
Git mirror commit 3a48f3689d65c5304cf706bbf2c5576daeb60a96. Update #3472.
Diffstat (limited to 'freebsd/sys/dev/usb')
-rw-r--r--freebsd/sys/dev/usb/input/uhid.c21
-rw-r--r--freebsd/sys/dev/usb/usb_generic.c11
-rw-r--r--freebsd/sys/dev/usb/usb_hub.c22
-rw-r--r--freebsd/sys/dev/usb/usb_request.c5
4 files changed, 51 insertions, 8 deletions
diff --git a/freebsd/sys/dev/usb/input/uhid.c b/freebsd/sys/dev/usb/input/uhid.c
index 90761ab7..8570f676 100644
--- a/freebsd/sys/dev/usb/input/uhid.c
+++ b/freebsd/sys/dev/usb/input/uhid.c
@@ -677,6 +677,8 @@ uhid_probe(device_t dev)
{
struct usb_attach_arg *uaa = device_get_ivars(dev);
int error;
+ void *buf;
+ uint16_t len;
DPRINTFN(11, "\n");
@@ -703,6 +705,25 @@ uhid_probe(device_t dev)
!usb_test_quirk(uaa, UQ_UMS_IGNORE))))
return (ENXIO);
+ /* Check for mandatory multitouch usages to give wmt(4) a chance */
+ if (!usb_test_quirk(uaa, UQ_WMT_IGNORE)) {
+ error = usbd_req_get_hid_desc(uaa->device, NULL,
+ &buf, &len, M_USBDEV, uaa->info.bIfaceIndex);
+ /* Let HID decscriptor-less devices to be handled at attach */
+ if (!error) {
+ if (hid_locate(buf, len,
+ HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACT_MAX),
+ hid_feature, 0, NULL, NULL, NULL) &&
+ hid_locate(buf, len,
+ HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACTID),
+ hid_input, 0, NULL, NULL, NULL)) {
+ free(buf, M_USBDEV);
+ return (ENXIO);
+ }
+ free(buf, M_USBDEV);
+ }
+ }
+
return (BUS_PROBE_GENERIC);
}
diff --git a/freebsd/sys/dev/usb/usb_generic.c b/freebsd/sys/dev/usb/usb_generic.c
index 29a27d53..364b8cc5 100644
--- a/freebsd/sys/dev/usb/usb_generic.c
+++ b/freebsd/sys/dev/usb/usb_generic.c
@@ -185,7 +185,10 @@ ugen_open(struct usb_fifo *f, int fflags)
struct usb_endpoint_descriptor *ed = ep->edesc;
uint8_t type;
- DPRINTFN(6, "flag=0x%x\n", fflags);
+#ifndef __rtems__
+ DPRINTFN(1, "flag=0x%x pid=%d name=%s\n", fflags,
+ curthread->td_proc->p_pid, curthread->td_proc->p_comm);
+#endif /* __rtems__ */
mtx_lock(f->priv_mtx);
switch (usbd_get_speed(f->udev)) {
@@ -215,7 +218,11 @@ ugen_open(struct usb_fifo *f, int fflags)
static void
ugen_close(struct usb_fifo *f, int fflags)
{
- DPRINTFN(6, "flag=0x%x\n", fflags);
+
+#ifndef __rtems__
+ DPRINTFN(1, "flag=0x%x pid=%d name=%s\n", fflags,
+ curthread->td_proc->p_pid, curthread->td_proc->p_comm);
+#endif /* __rtems__ */
/* cleanup */
diff --git a/freebsd/sys/dev/usb/usb_hub.c b/freebsd/sys/dev/usb/usb_hub.c
index a0ad462f..7afe5d9e 100644
--- a/freebsd/sys/dev/usb/usb_hub.c
+++ b/freebsd/sys/dev/usb/usb_hub.c
@@ -131,6 +131,8 @@ struct uhub_softc {
int sc_disable_enumeration;
int sc_disable_port_power;
#endif
+ uint8_t sc_usb_port_errors; /* error counter */
+#define UHUB_USB_PORT_ERRORS_MAX 4
uint8_t sc_flags;
#define UHUB_FLAG_DID_EXPLORE 0x01
};
@@ -589,13 +591,25 @@ uhub_read_port_status(struct uhub_softc *sc, uint8_t portno)
struct usb_port_status ps;
usb_error_t err;
+ if (sc->sc_usb_port_errors >= UHUB_USB_PORT_ERRORS_MAX) {
+ DPRINTFN(4, "port %d, HUB looks dead, too many errors\n", portno);
+ sc->sc_st.port_status = 0;
+ sc->sc_st.port_change = 0;
+ return (USB_ERR_TIMEOUT);
+ }
+
err = usbd_req_get_port_status(
sc->sc_udev, NULL, &ps, portno);
- /* update status regardless of error */
-
- sc->sc_st.port_status = UGETW(ps.wPortStatus);
- sc->sc_st.port_change = UGETW(ps.wPortChange);
+ if (err == 0) {
+ sc->sc_st.port_status = UGETW(ps.wPortStatus);
+ sc->sc_st.port_change = UGETW(ps.wPortChange);
+ sc->sc_usb_port_errors = 0;
+ } else {
+ sc->sc_st.port_status = 0;
+ sc->sc_st.port_change = 0;
+ sc->sc_usb_port_errors++;
+ }
/* debugging print */
diff --git a/freebsd/sys/dev/usb/usb_request.c b/freebsd/sys/dev/usb/usb_request.c
index d2a15f3c..f288378e 100644
--- a/freebsd/sys/dev/usb/usb_request.c
+++ b/freebsd/sys/dev/usb/usb_request.c
@@ -1603,8 +1603,9 @@ usbd_req_get_port_status(struct usb_device *udev, struct mtx *mtx,
USETW(req.wValue, 0);
req.wIndex[0] = port;
req.wIndex[1] = 0;
- USETW(req.wLength, sizeof *ps);
- return (usbd_do_request(udev, mtx, &req, ps));
+ USETW(req.wLength, sizeof(*ps));
+
+ return (usbd_do_request_flags(udev, mtx, &req, ps, 0, NULL, 1000));
}
/*------------------------------------------------------------------------*