aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/isp116x-hcd.c
diff options
context:
space:
mode:
authorJulien May <mailinglist@miromico.ch>2008-06-27 09:01:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-21 18:16:48 -0400
commit28874b7ec47e1e5cfe2b67420c4d07c6297a43a9 (patch)
tree3e86dd66bb7ab04d086ba080e456a71bbe5daf31 /drivers/usb/host/isp116x-hcd.c
parentdf3e1ab7334279bc744344bcf05272dc8b985d3d (diff)
USB: Fix bug with byte order in isp116x-hcd.c fio write/read
URB payload data are transfered in wrong byte order on a big endinan architecture (AVR32). Signed-off-by: Julien May <mailinglist@miromico.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/isp116x-hcd.c')
-rw-r--r--drivers/usb/host/isp116x-hcd.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 109dee82a37..31178e10cbb 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -94,6 +94,10 @@ static void write_ptddata_to_fifo(struct isp116x *isp116x, void *buf, int len)
94 u16 w; 94 u16 w;
95 int quot = len % 4; 95 int quot = len % 4;
96 96
97 /* buffer is already in 'usb data order', which is LE. */
98 /* When reading buffer as u16, we have to take care byte order */
99 /* doesn't get mixed up */
100
97 if ((unsigned long)dp2 & 1) { 101 if ((unsigned long)dp2 & 1) {
98 /* not aligned */ 102 /* not aligned */
99 for (; len > 1; len -= 2) { 103 for (; len > 1; len -= 2) {
@@ -105,8 +109,11 @@ static void write_ptddata_to_fifo(struct isp116x *isp116x, void *buf, int len)
105 isp116x_write_data16(isp116x, (u16) * dp); 109 isp116x_write_data16(isp116x, (u16) * dp);
106 } else { 110 } else {
107 /* aligned */ 111 /* aligned */
108 for (; len > 1; len -= 2) 112 for (; len > 1; len -= 2) {
109 isp116x_raw_write_data16(isp116x, *dp2++); 113 /* Keep byte order ! */
114 isp116x_raw_write_data16(isp116x, cpu_to_le16(*dp2++));
115 }
116
110 if (len) 117 if (len)
111 isp116x_write_data16(isp116x, 0xff & *((u8 *) dp2)); 118 isp116x_write_data16(isp116x, 0xff & *((u8 *) dp2));
112 } 119 }
@@ -124,6 +131,10 @@ static void read_ptddata_from_fifo(struct isp116x *isp116x, void *buf, int len)
124 u16 w; 131 u16 w;
125 int quot = len % 4; 132 int quot = len % 4;
126 133
134 /* buffer is already in 'usb data order', which is LE. */
135 /* When reading buffer as u16, we have to take care byte order */
136 /* doesn't get mixed up */
137
127 if ((unsigned long)dp2 & 1) { 138 if ((unsigned long)dp2 & 1) {
128 /* not aligned */ 139 /* not aligned */
129 for (; len > 1; len -= 2) { 140 for (; len > 1; len -= 2) {
@@ -131,12 +142,16 @@ static void read_ptddata_from_fifo(struct isp116x *isp116x, void *buf, int len)
131 *dp++ = w & 0xff; 142 *dp++ = w & 0xff;
132 *dp++ = (w >> 8) & 0xff; 143 *dp++ = (w >> 8) & 0xff;
133 } 144 }
145
134 if (len) 146 if (len)
135 *dp = 0xff & isp116x_read_data16(isp116x); 147 *dp = 0xff & isp116x_read_data16(isp116x);
136 } else { 148 } else {
137 /* aligned */ 149 /* aligned */
138 for (; len > 1; len -= 2) 150 for (; len > 1; len -= 2) {
139 *dp2++ = isp116x_raw_read_data16(isp116x); 151 /* Keep byte order! */
152 *dp2++ = le16_to_cpu(isp116x_raw_read_data16(isp116x));
153 }
154
140 if (len) 155 if (len)
141 *(u8 *) dp2 = 0xff & isp116x_read_data16(isp116x); 156 *(u8 *) dp2 = 0xff & isp116x_read_data16(isp116x);
142 } 157 }