aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2009-08-19 10:19:08 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-08-19 21:30:44 -0400
commitef5ce3b69028ea32aa87e98c9a3802e7c9f824b6 (patch)
treedddda44be0639cb6c49b7d066394c9b41b33a391 /drivers/usb
parentd2e27bdf2870e507dd4abba1f56ca84ee6ae7232 (diff)
usb: r8a66597-udc buffer management update
This patch updates the r8a66597-udc buffer management code. Use fixed buffers for bulk and isochronous pipes, also make sure to handle the isochronous-as-bulk case. With fixed buffers there is no need to keep track of used buffers with bi_bufnum. Also, this fixes a potential buffer offset problem where the base offset incorrectly varies with the number of pipes used. The m66592 driver recently got fixed in a similar way. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/r8a66597-udc.c32
-rw-r--r--drivers/usb/gadget/r8a66597-udc.h1
2 files changed, 11 insertions, 22 deletions
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index c65753ffe0f0..956618400a7c 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -252,24 +252,27 @@ static int pipe_buffer_setting(struct r8a66597 *r8a66597,
252 buf_bsize = 0; 252 buf_bsize = 0;
253 break; 253 break;
254 case R8A66597_BULK: 254 case R8A66597_BULK:
255 bufnum = r8a66597->bi_bufnum + 255 /* isochronous pipes may be used as bulk pipes */
256 (info->pipe - R8A66597_BASE_PIPENUM_BULK) * 16; 256 if (info->pipe > R8A66597_BASE_PIPENUM_BULK)
257 r8a66597->bi_bufnum += 16; 257 bufnum = info->pipe - R8A66597_BASE_PIPENUM_BULK;
258 else
259 bufnum = info->pipe - R8A66597_BASE_PIPENUM_ISOC;
260
261 bufnum = R8A66597_BASE_BUFNUM + (bufnum * 16);
258 buf_bsize = 7; 262 buf_bsize = 7;
259 pipecfg |= R8A66597_DBLB; 263 pipecfg |= R8A66597_DBLB;
260 if (!info->dir_in) 264 if (!info->dir_in)
261 pipecfg |= R8A66597_SHTNAK; 265 pipecfg |= R8A66597_SHTNAK;
262 break; 266 break;
263 case R8A66597_ISO: 267 case R8A66597_ISO:
264 bufnum = r8a66597->bi_bufnum + 268 bufnum = R8A66597_BASE_BUFNUM +
265 (info->pipe - R8A66597_BASE_PIPENUM_ISOC) * 16; 269 (info->pipe - R8A66597_BASE_PIPENUM_ISOC) * 16;
266 r8a66597->bi_bufnum += 16;
267 buf_bsize = 7; 270 buf_bsize = 7;
268 break; 271 break;
269 } 272 }
270 if (r8a66597->bi_bufnum > R8A66597_MAX_BUFNUM) { 273
271 printk(KERN_ERR "r8a66597 pipe memory is insufficient(%d)\n", 274 if (buf_bsize && ((bufnum + 16) >= R8A66597_MAX_BUFNUM)) {
272 r8a66597->bi_bufnum); 275 pr_err(KERN_ERR "r8a66597 pipe memory is insufficient\n");
273 return -ENOMEM; 276 return -ENOMEM;
274 } 277 }
275 278
@@ -289,17 +292,6 @@ static void pipe_buffer_release(struct r8a66597 *r8a66597,
289 if (info->pipe == 0) 292 if (info->pipe == 0)
290 return; 293 return;
291 294
292 switch (info->type) {
293 case R8A66597_BULK:
294 if (is_bulk_pipe(info->pipe))
295 r8a66597->bi_bufnum -= 16;
296 break;
297 case R8A66597_ISO:
298 if (is_isoc_pipe(info->pipe))
299 r8a66597->bi_bufnum -= 16;
300 break;
301 }
302
303 if (is_bulk_pipe(info->pipe)) 295 if (is_bulk_pipe(info->pipe))
304 r8a66597->bulk--; 296 r8a66597->bulk--;
305 else if (is_interrupt_pipe(info->pipe)) 297 else if (is_interrupt_pipe(info->pipe))
@@ -1553,8 +1545,6 @@ static int __init r8a66597_probe(struct platform_device *pdev)
1553 r8a66597->timer.data = (unsigned long)r8a66597; 1545 r8a66597->timer.data = (unsigned long)r8a66597;
1554 r8a66597->reg = (unsigned long)reg; 1546 r8a66597->reg = (unsigned long)reg;
1555 1547
1556 r8a66597->bi_bufnum = R8A66597_BASE_BUFNUM;
1557
1558#ifdef CONFIG_HAVE_CLK 1548#ifdef CONFIG_HAVE_CLK
1559 if (r8a66597->pdata->on_chip) { 1549 if (r8a66597->pdata->on_chip) {
1560 snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); 1550 snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id);
diff --git a/drivers/usb/gadget/r8a66597-udc.h b/drivers/usb/gadget/r8a66597-udc.h
index 7d9a325e7b6d..e653575d4ceb 100644
--- a/drivers/usb/gadget/r8a66597-udc.h
+++ b/drivers/usb/gadget/r8a66597-udc.h
@@ -112,7 +112,6 @@ struct r8a66597 {
112 u16 old_dvsq; 112 u16 old_dvsq;
113 113
114 /* pipe config */ 114 /* pipe config */
115 unsigned short bi_bufnum; /* bulk and isochronous's bufnum */
116 unsigned char bulk; 115 unsigned char bulk;
117 unsigned char interrupt; 116 unsigned char interrupt;
118 unsigned char isochronous; 117 unsigned char isochronous;