aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-08-21 15:36:52 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:55:18 -0400
commitdfd1e53777afe1050e3a0a3f0dd063a64242b818 (patch)
treeebd61076eb142ec969721aece9ddefbd05ff46bb /drivers/usb/host
parentaf1c51fcb2aea23ec2dfe73b7d66515d1622e689 (diff)
USB: minor fixes for r8a66597 driver
This patch (as967) makes a few relatively minor changes to the r8a66597 driver: finish_request() does nothing but call done(), so merge the two routines. Detect and report -EOVERFLOW errors. Fix the calculation that checks for short packets. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> CC: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/r8a66597-hcd.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 94bb229df3bc..49cf998c172a 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -1109,8 +1109,9 @@ static void set_td_timer(struct r8a66597 *r8a66597, struct r8a66597_td *td)
1109} 1109}
1110 1110
1111/* this function must be called with interrupt disabled */ 1111/* this function must be called with interrupt disabled */
1112static void done(struct r8a66597 *r8a66597, struct r8a66597_td *td, 1112static void finish_request(struct r8a66597 *r8a66597, struct r8a66597_td *td,
1113 u16 pipenum, struct urb *urb) 1113 u16 pipenum, struct urb *urb)
1114__releases(r8a66597->lock) __acquires(r8a66597->lock)
1114{ 1115{
1115 int restart = 0; 1116 int restart = 0;
1116 struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); 1117 struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597);
@@ -1151,14 +1152,6 @@ static void done(struct r8a66597 *r8a66597, struct r8a66597_td *td,
1151 } 1152 }
1152} 1153}
1153 1154
1154/* this function must be called with interrupt disabled */
1155static void finish_request(struct r8a66597 *r8a66597, struct r8a66597_td *td,
1156 u16 pipenum, struct urb *urb)
1157__releases(r8a66597->lock) __acquires(r8a66597->lock)
1158{
1159 done(r8a66597, td, pipenum, urb);
1160}
1161
1162static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) 1155static void packet_read(struct r8a66597 *r8a66597, u16 pipenum)
1163{ 1156{
1164 u16 tmp; 1157 u16 tmp;
@@ -1167,6 +1160,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum)
1167 struct r8a66597_td *td = r8a66597_get_td(r8a66597, pipenum); 1160 struct r8a66597_td *td = r8a66597_get_td(r8a66597, pipenum);
1168 struct urb *urb; 1161 struct urb *urb;
1169 int finish = 0; 1162 int finish = 0;
1163 int status = 0;
1170 1164
1171 if (unlikely(!td)) 1165 if (unlikely(!td))
1172 return; 1166 return;
@@ -1185,7 +1179,6 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum)
1185 1179
1186 /* prepare parameters */ 1180 /* prepare parameters */
1187 rcv_len = tmp & DTLN; 1181 rcv_len = tmp & DTLN;
1188 bufsize = td->maxpacket;
1189 if (usb_pipeisoc(urb->pipe)) { 1182 if (usb_pipeisoc(urb->pipe)) {
1190 buf = (u16 *)(urb->transfer_buffer + 1183 buf = (u16 *)(urb->transfer_buffer +
1191 urb->iso_frame_desc[td->iso_cnt].offset); 1184 urb->iso_frame_desc[td->iso_cnt].offset);
@@ -1194,25 +1187,30 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum)
1194 buf = (void *)urb->transfer_buffer + urb->actual_length; 1187 buf = (void *)urb->transfer_buffer + urb->actual_length;
1195 urb_len = urb->transfer_buffer_length - urb->actual_length; 1188 urb_len = urb->transfer_buffer_length - urb->actual_length;
1196 } 1189 }
1197 if (rcv_len < bufsize) 1190 bufsize = min(urb_len, (int) td->maxpacket);
1198 size = min(rcv_len, urb_len); 1191 if (rcv_len <= bufsize) {
1199 else 1192 size = rcv_len;
1200 size = min(bufsize, urb_len); 1193 } else {
1194 size = bufsize;
1195 status = -EOVERFLOW;
1196 finish = 1;
1197 }
1201 1198
1202 /* update parameters */ 1199 /* update parameters */
1203 urb->actual_length += size; 1200 urb->actual_length += size;
1204 if (rcv_len == 0) 1201 if (rcv_len == 0)
1205 td->zero_packet = 1; 1202 td->zero_packet = 1;
1206 if ((size % td->maxpacket) > 0) { 1203 if (rcv_len < bufsize) {
1207 td->short_packet = 1; 1204 td->short_packet = 1;
1208 if (urb->transfer_buffer_length != urb->actual_length && 1205 if (urb->transfer_buffer_length != urb->actual_length &&
1209 urb->transfer_flags & URB_SHORT_NOT_OK) 1206 urb->transfer_flags & URB_SHORT_NOT_OK)
1210 td->urb->status = -EREMOTEIO; 1207 status = -EREMOTEIO;
1211 } 1208 }
1212 if (usb_pipeisoc(urb->pipe)) { 1209 if (usb_pipeisoc(urb->pipe)) {
1213 urb->iso_frame_desc[td->iso_cnt].actual_length = size; 1210 urb->iso_frame_desc[td->iso_cnt].actual_length = size;
1214 urb->iso_frame_desc[td->iso_cnt].status = 0; 1211 urb->iso_frame_desc[td->iso_cnt].status = status;
1215 td->iso_cnt++; 1212 td->iso_cnt++;
1213 finish = 0;
1216 } 1214 }
1217 1215
1218 /* check transfer finish */ 1216 /* check transfer finish */
@@ -1233,7 +1231,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum)
1233 1231
1234 if (finish && pipenum != 0) { 1232 if (finish && pipenum != 0) {
1235 if (td->urb->status == -EINPROGRESS) 1233 if (td->urb->status == -EINPROGRESS)
1236 td->urb->status = 0; 1234 td->urb->status = status;
1237 finish_request(r8a66597, td, pipenum, urb); 1235 finish_request(r8a66597, td, pipenum, urb);
1238 } 1236 }
1239} 1237}
@@ -1807,7 +1805,7 @@ static int r8a66597_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
1807 pipe_stop(r8a66597, td->pipe); 1805 pipe_stop(r8a66597, td->pipe);
1808 pipe_irq_disable(r8a66597, td->pipenum); 1806 pipe_irq_disable(r8a66597, td->pipenum);
1809 disable_irq_empty(r8a66597, td->pipenum); 1807 disable_irq_empty(r8a66597, td->pipenum);
1810 done(r8a66597, td, td->pipenum, urb); 1808 finish_request(r8a66597, td, td->pipenum, urb);
1811 } 1809 }
1812 done: 1810 done:
1813 spin_unlock_irqrestore(&r8a66597->lock, flags); 1811 spin_unlock_irqrestore(&r8a66597->lock, flags);
@@ -1841,7 +1839,7 @@ static void r8a66597_endpoint_disable(struct usb_hcd *hcd,
1841 td = r8a66597_get_td(r8a66597, pipenum); 1839 td = r8a66597_get_td(r8a66597, pipenum);
1842 if (td) 1840 if (td)
1843 urb = td->urb; 1841 urb = td->urb;
1844 done(r8a66597, td, pipenum, urb); 1842 finish_request(r8a66597, td, pipenum, urb);
1845 kfree(hep->hcpriv); 1843 kfree(hep->hcpriv);
1846 hep->hcpriv = NULL; 1844 hep->hcpriv = NULL;
1847 spin_unlock_irqrestore(&r8a66597->lock, flags); 1845 spin_unlock_irqrestore(&r8a66597->lock, flags);