summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Nyman <mathias.nyman@linux.intel.com>2013-04-23 17:17:40 -0700
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2013-06-14 13:52:39 -0700
commitbd18fd5c21b2e60d9b79a9d2ce8f38a672f560a6 (patch)
tree33945a76ed7c8161c282a1b57e788987f533d234
parent92f8e76769c687a7c38c5067ff375c187666ac18 (diff)
xhci: Remove BUG in xhci_setup_addressable_virt_dev
We may have more speed types in the future, so fail gracefully, rather than causing the kernel to panic. BUG() was called if the device speed was unknown when setting max packet size. Set the max packet size at the same time as the slot speed and get rid of one switch statement with BUG() option completely. [Note: Sarah merged a patch that she wrote that touched the xhci_setup_addressable_virt_dev function with this patch from Mathias for clarity.] 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.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index b7487a10d7bc..6072f1166de9 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1055,6 +1055,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
struct xhci_ep_ctx *ep0_ctx;
struct xhci_slot_ctx *slot_ctx;
u32 port_num;
+ u32 max_packets;
struct usb_device *top_dev;
dev = xhci->devs[udev->slot_id];
@@ -1072,15 +1073,20 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
switch (udev->speed) {
case USB_SPEED_SUPER:
slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS);
+ max_packets = MAX_PACKET(512);
break;
case USB_SPEED_HIGH:
slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_HS);
+ max_packets = MAX_PACKET(64);
break;
+ /* USB core guesses at a 64-byte max packet first for FS devices */
case USB_SPEED_FULL:
slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_FS);
+ max_packets = MAX_PACKET(64);
break;
case USB_SPEED_LOW:
slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_LS);
+ max_packets = MAX_PACKET(8);
break;
case USB_SPEED_WIRELESS:
xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n");
@@ -1088,7 +1094,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
break;
default:
/* Speed was set earlier, this shouldn't happen. */
- BUG();
+ return -EINVAL;
}
/* Find the root hub port this device is under */
port_num = xhci_find_real_port_number(xhci, udev);
@@ -1147,31 +1153,10 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
/* Step 4 - ring already allocated */
/* Step 5 */
ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
- /*
- * XXX: Not sure about wireless USB devices.
- */
- switch (udev->speed) {
- case USB_SPEED_SUPER:
- ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(512));
- break;
- case USB_SPEED_HIGH:
- /* USB core guesses at a 64-byte max packet first for FS devices */
- case USB_SPEED_FULL:
- ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(64));
- break;
- case USB_SPEED_LOW:
- ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(8));
- break;
- case USB_SPEED_WIRELESS:
- xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n");
- return -EINVAL;
- break;
- default:
- /* New speed? */
- BUG();
- }
+
/* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */
- ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3));
+ ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3) |
+ max_packets);
ep0_ctx->deq = cpu_to_le64(dev->eps[0].ring->first_seg->dma |
dev->eps[0].ring->cycle_state);