[PATCH] This patch fixes endian issue in xHCI for scratchpad buffer.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Scratchpad buffer is an array of pointers every of which must be
in little endian format.

Signed-off-by: Aleksey Kuleshov <rndfax@xxxxxxxxx>
---
 drivers/usb/host/xhci-mem.c | 6 +++---
 drivers/usb/host/xhci.h     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index cf5e179..ffc3236 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1677,7 +1677,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
 		if (!buf)
 			goto fail_sp4;
 
-		xhci->scratchpad->sp_array[i] = dma;
+		xhci->scratchpad->sp_array[i] = cpu_to_le64(dma);
 		xhci->scratchpad->sp_buffers[i] = buf;
 	}
 
@@ -1687,7 +1687,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
 	for (i = i - 1; i >= 0; i--) {
 		dma_free_coherent(dev, xhci->page_size,
 				    xhci->scratchpad->sp_buffers[i],
-				    xhci->scratchpad->sp_array[i]);
+				    le64_to_cpu(xhci->scratchpad->sp_array[i]));
 	}
 
 	kfree(xhci->scratchpad->sp_buffers);
@@ -1719,7 +1719,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
 	for (i = 0; i < num_sp; i++) {
 		dma_free_coherent(dev, xhci->page_size,
 				    xhci->scratchpad->sp_buffers[i],
-				    xhci->scratchpad->sp_array[i]);
+				    le64_to_cpu(xhci->scratchpad->sp_array[i]));
 	}
 	kfree(xhci->scratchpad->sp_buffers);
 	dma_free_coherent(dev, num_sp * sizeof(u64),
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 9334cde..385fa70 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1621,7 +1621,7 @@ struct xhci_erst {
 };
 
 struct xhci_scratchpad {
-	u64 *sp_array;
+	__le64 *sp_array;
 	dma_addr_t sp_dma;
 	void **sp_buffers;
 };
-- 
1.8.3.1




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux