aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci-mem.c
diff options
context:
space:
mode:
authorMatt Evans <matt@ozlabs.org>2011-05-31 20:22:55 -0400
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2011-06-02 19:37:47 -0400
commitf5960b698eb50a39fce1a066dc19a6a5a1148e16 (patch)
treed1f08656be5ffd40f4268d874801f91016508e3e /drivers/usb/host/xhci-mem.c
parent55922c9d1b84b89cb946c777fddccb3247e7df2c (diff)
xhci: Remove some unnecessary casts and tidy some endian swap code
Some of the recently-added cpu_to_leXX and leXX_to_cpu made things somewhat messy; this patch neatens some of these areas, removing unnecessary casts in those parts also. In some places (where Y & Z are constants) a comparison of (leXX_to_cpu(X) & Y) == Z has been replaced with (X & cpu_to_leXX(Y)) == cpu_to_leXX(Z). The endian reversal of the constants should wash out at compile time. Signed-off-by: Matt Evans <matt@ozlabs.org> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/host/xhci-mem.c')
-rw-r--r--drivers/usb/host/xhci-mem.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 26caba4c1950..596d8fbb9e18 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -89,8 +89,8 @@ static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev,
89 return; 89 return;
90 prev->next = next; 90 prev->next = next;
91 if (link_trbs) { 91 if (link_trbs) {
92 prev->trbs[TRBS_PER_SEGMENT-1].link. 92 prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr =
93 segment_ptr = cpu_to_le64(next->dma); 93 cpu_to_le64(next->dma);
94 94
95 /* Set the last TRB in the segment to have a TRB type ID of Link TRB */ 95 /* Set the last TRB in the segment to have a TRB type ID of Link TRB */
96 val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control); 96 val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control);
@@ -187,8 +187,8 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
187 187
188 if (link_trbs) { 188 if (link_trbs) {
189 /* See section 4.9.2.1 and 6.4.4.1 */ 189 /* See section 4.9.2.1 and 6.4.4.1 */
190 prev->trbs[TRBS_PER_SEGMENT-1].link. 190 prev->trbs[TRBS_PER_SEGMENT-1].link.control |=
191 control |= cpu_to_le32(LINK_TOGGLE); 191 cpu_to_le32(LINK_TOGGLE);
192 xhci_dbg(xhci, "Wrote link toggle flag to" 192 xhci_dbg(xhci, "Wrote link toggle flag to"
193 " segment %p (virtual), 0x%llx (DMA)\n", 193 " segment %p (virtual), 0x%llx (DMA)\n",
194 prev, (unsigned long long)prev->dma); 194 prev, (unsigned long long)prev->dma);
@@ -549,8 +549,8 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci,
549 addr = cur_ring->first_seg->dma | 549 addr = cur_ring->first_seg->dma |
550 SCT_FOR_CTX(SCT_PRI_TR) | 550 SCT_FOR_CTX(SCT_PRI_TR) |
551 cur_ring->cycle_state; 551 cur_ring->cycle_state;
552 stream_info->stream_ctx_array[cur_stream]. 552 stream_info->stream_ctx_array[cur_stream].stream_ring =
553 stream_ring = cpu_to_le64(addr); 553 cpu_to_le64(addr);
554 xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", 554 xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n",
555 cur_stream, (unsigned long long) addr); 555 cur_stream, (unsigned long long) addr);
556 556
@@ -786,7 +786,7 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
786 xhci_dbg(xhci, "Set slot id %d dcbaa entry %p to 0x%llx\n", 786 xhci_dbg(xhci, "Set slot id %d dcbaa entry %p to 0x%llx\n",
787 slot_id, 787 slot_id,
788 &xhci->dcbaa->dev_context_ptrs[slot_id], 788 &xhci->dcbaa->dev_context_ptrs[slot_id],
789 (unsigned long long) le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id])); 789 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id]));
790 790
791 return 1; 791 return 1;
792fail: 792fail:
@@ -890,19 +890,19 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
890 ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG); 890 ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG);
891 891
892 /* 3) Only the control endpoint is valid - one endpoint context */ 892 /* 3) Only the control endpoint is valid - one endpoint context */
893 slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | (u32) udev->route); 893 slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route);
894 switch (udev->speed) { 894 switch (udev->speed) {
895 case USB_SPEED_SUPER: 895 case USB_SPEED_SUPER:
896 slot_ctx->dev_info |= cpu_to_le32((u32) SLOT_SPEED_SS); 896 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS);
897 break; 897 break;
898 case USB_SPEED_HIGH: 898 case USB_SPEED_HIGH:
899 slot_ctx->dev_info |= cpu_to_le32((u32) SLOT_SPEED_HS); 899 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_HS);
900 break; 900 break;
901 case USB_SPEED_FULL: 901 case USB_SPEED_FULL:
902 slot_ctx->dev_info |= cpu_to_le32((u32) SLOT_SPEED_FS); 902 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_FS);
903 break; 903 break;
904 case USB_SPEED_LOW: 904 case USB_SPEED_LOW:
905 slot_ctx->dev_info |= cpu_to_le32((u32) SLOT_SPEED_LS); 905 slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_LS);
906 break; 906 break;
907 case USB_SPEED_WIRELESS: 907 case USB_SPEED_WIRELESS:
908 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); 908 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n");
@@ -916,7 +916,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
916 port_num = xhci_find_real_port_number(xhci, udev); 916 port_num = xhci_find_real_port_number(xhci, udev);
917 if (!port_num) 917 if (!port_num)
918 return -EINVAL; 918 return -EINVAL;
919 slot_ctx->dev_info2 |= cpu_to_le32((u32) ROOT_HUB_PORT(port_num)); 919 slot_ctx->dev_info2 |= cpu_to_le32(ROOT_HUB_PORT(port_num));
920 /* Set the port number in the virtual_device to the faked port number */ 920 /* Set the port number in the virtual_device to the faked port number */
921 for (top_dev = udev; top_dev->parent && top_dev->parent->parent; 921 for (top_dev = udev; top_dev->parent && top_dev->parent->parent;
922 top_dev = top_dev->parent) 922 top_dev = top_dev->parent)