提交 17d65554 编写于 作者: M Mathias Nyman 提交者: Sarah Sharp

xhci: remove BUG() in xhci_get_endpoint_type()

If the endpoint type is unknown, set it to 0 and fail gracefully
instead of causing a kernel panic.
Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
上级 bd18fd5c
...@@ -1329,7 +1329,7 @@ static u32 xhci_get_endpoint_type(struct usb_device *udev, ...@@ -1329,7 +1329,7 @@ static u32 xhci_get_endpoint_type(struct usb_device *udev,
else else
type = EP_TYPE(INT_OUT_EP); type = EP_TYPE(INT_OUT_EP);
} else { } else {
BUG(); type = 0;
} }
return type; return type;
} }
...@@ -1375,10 +1375,16 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, ...@@ -1375,10 +1375,16 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
unsigned int max_burst; unsigned int max_burst;
enum xhci_ring_type type; enum xhci_ring_type type;
u32 max_esit_payload; u32 max_esit_payload;
u32 endpoint_type;
ep_index = xhci_get_endpoint_index(&ep->desc); ep_index = xhci_get_endpoint_index(&ep->desc);
ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
endpoint_type = xhci_get_endpoint_type(udev, ep);
if (!endpoint_type)
return -EINVAL;
ep_ctx->ep_info2 = cpu_to_le32(endpoint_type);
type = usb_endpoint_type(&ep->desc); type = usb_endpoint_type(&ep->desc);
/* Set up the endpoint ring */ /* Set up the endpoint ring */
virt_dev->eps[ep_index].new_ring = virt_dev->eps[ep_index].new_ring =
...@@ -1407,11 +1413,9 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, ...@@ -1407,11 +1413,9 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
* CErr shall be set to 0 for Isoch endpoints. * CErr shall be set to 0 for Isoch endpoints.
*/ */
if (!usb_endpoint_xfer_isoc(&ep->desc)) if (!usb_endpoint_xfer_isoc(&ep->desc))
ep_ctx->ep_info2 = cpu_to_le32(ERROR_COUNT(3)); ep_ctx->ep_info2 |= cpu_to_le32(ERROR_COUNT(3));
else else
ep_ctx->ep_info2 = cpu_to_le32(ERROR_COUNT(0)); ep_ctx->ep_info2 |= cpu_to_le32(ERROR_COUNT(0));
ep_ctx->ep_info2 |= cpu_to_le32(xhci_get_endpoint_type(udev, ep));
/* Set the max packet size and max burst */ /* Set the max packet size and max burst */
max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc)); max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册