aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Nyman <mathias.nyman@linux.intel.com>2013-04-24 10:24:58 -0400
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2013-06-14 16:53:23 -0400
commit17d655543716791ebf8bb396b674fe95c07e55e4 (patch)
treeaa5696acf99be46a253cd3ac9859ac8c37f2fd1c
parentbd18fd5c21b2e60d9b79a9d2ce8f38a672f560a6 (diff)
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: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
-rw-r--r--drivers/usb/host/xhci-mem.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 6072f1166de9..b0d789e31f96 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1329,7 +1329,7 @@ static u32 xhci_get_endpoint_type(struct usb_device *udev,
1329 else 1329 else
1330 type = EP_TYPE(INT_OUT_EP); 1330 type = EP_TYPE(INT_OUT_EP);
1331 } else { 1331 } else {
1332 BUG(); 1332 type = 0;
1333 } 1333 }
1334 return type; 1334 return type;
1335} 1335}
@@ -1375,10 +1375,16 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1375 unsigned int max_burst; 1375 unsigned int max_burst;
1376 enum xhci_ring_type type; 1376 enum xhci_ring_type type;
1377 u32 max_esit_payload; 1377 u32 max_esit_payload;
1378 u32 endpoint_type;
1378 1379
1379 ep_index = xhci_get_endpoint_index(&ep->desc); 1380 ep_index = xhci_get_endpoint_index(&ep->desc);
1380 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); 1381 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
1381 1382
1383 endpoint_type = xhci_get_endpoint_type(udev, ep);
1384 if (!endpoint_type)
1385 return -EINVAL;
1386 ep_ctx->ep_info2 = cpu_to_le32(endpoint_type);
1387
1382 type = usb_endpoint_type(&ep->desc); 1388 type = usb_endpoint_type(&ep->desc);
1383 /* Set up the endpoint ring */ 1389 /* Set up the endpoint ring */
1384 virt_dev->eps[ep_index].new_ring = 1390 virt_dev->eps[ep_index].new_ring =
@@ -1407,11 +1413,9 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1407 * CErr shall be set to 0 for Isoch endpoints. 1413 * CErr shall be set to 0 for Isoch endpoints.
1408 */ 1414 */
1409 if (!usb_endpoint_xfer_isoc(&ep->desc)) 1415 if (!usb_endpoint_xfer_isoc(&ep->desc))
1410 ep_ctx->ep_info2 = cpu_to_le32(ERROR_COUNT(3)); 1416 ep_ctx->ep_info2 |= cpu_to_le32(ERROR_COUNT(3));
1411 else 1417 else
1412 ep_ctx->ep_info2 = cpu_to_le32(ERROR_COUNT(0)); 1418 ep_ctx->ep_info2 |= cpu_to_le32(ERROR_COUNT(0));
1413
1414 ep_ctx->ep_info2 |= cpu_to_le32(xhci_get_endpoint_type(udev, ep));
1415 1419
1416 /* Set the max packet size and max burst */ 1420 /* Set the max packet size and max burst */
1417 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc)); 1421 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));