FreeBSD Bugzilla – Attachment 220564 Details for
Bug 251856
set interface command doesn't follow USB spec 9.4.10
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to fix this bug.
usb_set_intf.diff (text/plain), 2.70 KB, created by
Horse Ma
on 2020-12-15 02:57:35 UTC
(
hide
)
Description:
patch to fix this bug.
Filename:
MIME Type:
Creator:
Horse Ma
Created:
2020-12-15 02:57:35 UTC
Size:
2.70 KB
patch
obsolete
>diff --git a/sys/compat/linuxkpi/common/src/linux_usb.c b/sys/compat/linuxkpi/common/src/linux_usb.c >index e35cca5216b..e93559f9526 100644 >--- a/sys/compat/linuxkpi/common/src/linux_usb.c >+++ b/sys/compat/linuxkpi/common/src/linux_usb.c >@@ -931,17 +931,12 @@ usb_linux_create_usb_device(struct usb_device *udev, device_t dev) > if (p_ui) { > p_ui->altsetting = p_uhi - 1; > p_ui->cur_altsetting = p_uhi - 1; >- p_ui->num_altsetting = 1; > p_ui->bsd_iface_index = iface_index; > p_ui->linux_udev = udev; > p_ui++; > } > iface_no_curr = iface_no; > iface_index++; >- } else { >- if (p_ui) { >- (p_ui - 1)->num_altsetting++; >- } > } > break; > >diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c >index 3499516c91e..34812d55870 100644 >--- a/sys/dev/usb/usb_device.c >+++ b/sys/dev/usb/usb_device.c >@@ -826,14 +826,18 @@ usb_config_parse(struct usb_device *udev, uint8_t iface_index, uint8_t cmd) > uint8_t temp; > uint8_t do_init; > uint8_t alt_index; >+ uint8_t update_alt_num; > > if (iface_index != USB_IFACE_INDEX_ANY) { > /* parameter overload */ > alt_index = cmd; > cmd = USB_CFG_INIT; >+ update_alt_num = 0; > } else { > /* not used */ > alt_index = 0; >+ if (cmd == USB_CFG_INIT) >+ update_alt_num = 1; > } > > err = 0; >@@ -918,6 +922,9 @@ usb_config_parse(struct usb_device *udev, uint8_t iface_index, uint8_t cmd) > } > } > >+ if ((cmd == USB_CFG_INIT) && update_alt_num) { >+ iface->num_altsetting++; >+ } > DPRINTFN(5, "found idesc nendpt=%d\n", id->bNumEndpoints); > > ed = (struct usb_endpoint_descriptor *)id; >diff --git a/sys/dev/usb/usb_request.c b/sys/dev/usb/usb_request.c >index 36c6a28124c..4cb755bf9a4 100644 >--- a/sys/dev/usb/usb_request.c >+++ b/sys/dev/usb/usb_request.c >@@ -1436,6 +1436,7 @@ usbd_req_set_alt_interface_no(struct usb_device *udev, struct mtx *mtx, > { > struct usb_interface *iface = usbd_get_iface(udev, iface_index); > struct usb_device_request req; >+ usb_error_t err; > > if ((iface == NULL) || (iface->idesc == NULL)) > return (USB_ERR_INVAL); >@@ -1447,7 +1448,16 @@ usbd_req_set_alt_interface_no(struct usb_device *udev, struct mtx *mtx, > req.wIndex[0] = iface->idesc->bInterfaceNumber; > req.wIndex[1] = 0; > USETW(req.wLength, 0); >- return (usbd_do_request(udev, mtx, &req, 0)); >+ err = usbd_do_request(udev, mtx, &req, 0); >+ if ((err == USB_ERR_STALLED) && (iface->num_altsetting <= 1)) { >+ /* USB spec 9.4.10 says devices don't need this and are free to STALL the >+ * request if the interface only has one alternate setting. >+ */ >+ err = 0; >+ DPRINTF("iface %p, %d, %d\n", >+ iface, err, iface->num_altsetting); >+ } >+ return (err); > } > > /*------------------------------------------------------------------------*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 251856
: 220564