aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/stk1160
diff options
context:
space:
mode:
authorEzequiel Garcia <elezegarcia@gmail.com>2012-10-23 20:20:30 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-11-21 09:04:22 -0500
commit2902fb7e0c74c9c3ed921acdaad447ef178fd32e (patch)
treecc875f44567cae81294ef4921df28a99924ce922 /drivers/media/usb/stk1160
parent2948b0b3ebbae98601c9b38e9841dbc754ca488c (diff)
[media] stk1160: Try to continue with fewer transfer buffers
Many people are trying to use stk1160 on low memory devices. Instead of failing if one allocation fails, we allow the driver to continue working if fewer transfer buffers are available. Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb/stk1160')
-rw-r--r--drivers/media/usb/stk1160/stk1160-video.c23
-rw-r--r--drivers/media/usb/stk1160/stk1160.h5
2 files changed, 24 insertions, 4 deletions
diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c
index 8bdfb0275313..fa3671de02aa 100644
--- a/drivers/media/usb/stk1160/stk1160-video.c
+++ b/drivers/media/usb/stk1160/stk1160-video.c
@@ -475,7 +475,11 @@ int stk1160_alloc_isoc(struct stk1160 *dev)
475 if (!dev->isoc_ctl.transfer_buffer[i]) { 475 if (!dev->isoc_ctl.transfer_buffer[i]) {
476 stk1160_err("cannot alloc %d bytes for tx[%d] buffer\n", 476 stk1160_err("cannot alloc %d bytes for tx[%d] buffer\n",
477 sb_size, i); 477 sb_size, i);
478 goto free_i_bufs; 478
479 /* Not enough transfer buffers, so just give up */
480 if (i < STK1160_MIN_BUFS)
481 goto free_i_bufs;
482 goto nomore_tx_bufs;
479 } 483 }
480 memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size); 484 memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size);
481 485
@@ -506,13 +510,28 @@ int stk1160_alloc_isoc(struct stk1160 *dev)
506 } 510 }
507 } 511 }
508 512
509 stk1160_dbg("urbs allocated\n"); 513 stk1160_dbg("%d urbs allocated\n", num_bufs);
510 514
511 /* At last we can say we have some buffers */ 515 /* At last we can say we have some buffers */
512 dev->isoc_ctl.num_bufs = num_bufs; 516 dev->isoc_ctl.num_bufs = num_bufs;
513 517
514 return 0; 518 return 0;
515 519
520nomore_tx_bufs:
521 /*
522 * Failed to allocate desired buffer count. However, we may have
523 * enough to work fine, so we just free the extra urb,
524 * store the allocated count and keep going, fingers crossed!
525 */
526 usb_free_urb(dev->isoc_ctl.urb[i]);
527 dev->isoc_ctl.urb[i] = NULL;
528
529 stk1160_warn("%d urbs allocated. Trying to continue...\n", i - 1);
530
531 dev->isoc_ctl.num_bufs = i - 1;
532
533 return 0;
534
516free_i_bufs: 535free_i_bufs:
517 /* Save the allocated buffers so far, so we can properly free them */ 536 /* Save the allocated buffers so far, so we can properly free them */
518 dev->isoc_ctl.num_bufs = i+1; 537 dev->isoc_ctl.num_bufs = i+1;
diff --git a/drivers/media/usb/stk1160/stk1160.h b/drivers/media/usb/stk1160/stk1160.h
index 68c8707d36ab..05b05b160e1e 100644
--- a/drivers/media/usb/stk1160/stk1160.h
+++ b/drivers/media/usb/stk1160/stk1160.h
@@ -30,11 +30,12 @@
30#define STK1160_VERSION "0.9.5" 30#define STK1160_VERSION "0.9.5"
31#define STK1160_VERSION_NUM 0x000905 31#define STK1160_VERSION_NUM 0x000905
32 32
33/* TODO: Decide on number of packets for each buffer */ 33/* Decide on number of packets for each buffer */
34#define STK1160_NUM_PACKETS 64 34#define STK1160_NUM_PACKETS 64
35 35
36/* Number of buffers for isoc transfers */ 36/* Number of buffers for isoc transfers */
37#define STK1160_NUM_BUFS 16 /* TODO */ 37#define STK1160_NUM_BUFS 16
38#define STK1160_MIN_BUFS 1
38 39
39/* TODO: This endpoint address should be retrieved */ 40/* TODO: This endpoint address should be retrieved */
40#define STK1160_EP_VIDEO 0x82 41#define STK1160_EP_VIDEO 0x82