diff options
author | Andreas Bombe <aeb@debian.org> | 2010-03-21 15:02:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-19 11:57:13 -0400 |
commit | dab7e3106ddd6cbc3b55301228407b9d17ce7773 (patch) | |
tree | 1b6caa87522844e7ea8cc01932365201271f1afd | |
parent | 0a062033f727dc041691bfd768f4cf0598f559a1 (diff) |
V4L/DVB: V4L2: Replace loops for finding max buffers in VIDIOC_REQBUFS callbacks
Due to obvious copy and paste coding a number of video capture drivers
which implement a limit on the buffer memory decremented the user
supplied buffer count in a while loop until it reaches an acceptable
value.
This is a silly thing to do when the maximum value can be directly
computed.
Signed-off-by: Andreas Bombe <aeb@debian.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/bt8xx/bttv-driver.c | 4 | ||||
-rw-r--r-- | drivers/media/video/cx23885/cx23885-video.c | 4 | ||||
-rw-r--r-- | drivers/media/video/cx88/cx88-video.c | 4 | ||||
-rw-r--r-- | drivers/media/video/mx1_camera.c | 4 | ||||
-rw-r--r-- | drivers/media/video/omap24xxcam.c | 4 | ||||
-rw-r--r-- | drivers/media/video/pxa_camera.c | 4 | ||||
-rw-r--r-- | drivers/media/video/s2255drv.c | 4 | ||||
-rw-r--r-- | drivers/media/video/sh_mobile_ceu_camera.c | 4 | ||||
-rw-r--r-- | drivers/media/video/vivi.c | 4 | ||||
-rw-r--r-- | drivers/media/video/zr364xx.c | 4 | ||||
-rw-r--r-- | drivers/staging/cx25821/cx25821-video.c | 4 |
11 files changed, 22 insertions, 22 deletions
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index f4860f03dfc3..350e7af75884 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
@@ -1806,8 +1806,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) | |||
1806 | *size = fh->fmt->depth*fh->width*fh->height >> 3; | 1806 | *size = fh->fmt->depth*fh->width*fh->height >> 3; |
1807 | if (0 == *count) | 1807 | if (0 == *count) |
1808 | *count = gbuffers; | 1808 | *count = gbuffers; |
1809 | while (*size * *count > gbuffers * gbufsize) | 1809 | if (*size * *count > gbuffers * gbufsize) |
1810 | (*count)--; | 1810 | *count = (gbuffers * gbufsize) / *size; |
1811 | return 0; | 1811 | return 0; |
1812 | } | 1812 | } |
1813 | 1813 | ||
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index 2d3ac8b83dc3..543b854f6a62 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
@@ -514,8 +514,8 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count, | |||
514 | *size = fh->fmt->depth*fh->width*fh->height >> 3; | 514 | *size = fh->fmt->depth*fh->width*fh->height >> 3; |
515 | if (0 == *count) | 515 | if (0 == *count) |
516 | *count = 32; | 516 | *count = 32; |
517 | while (*size * *count > vid_limit * 1024 * 1024) | 517 | if (*size * *count > vid_limit * 1024 * 1024) |
518 | (*count)--; | 518 | *count = (vid_limit * 1024 * 1024) / *size; |
519 | return 0; | 519 | return 0; |
520 | } | 520 | } |
521 | 521 | ||
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 8e414f7aa76e..0a3849c710f8 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -561,8 +561,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) | |||
561 | *size = fh->fmt->depth*fh->width*fh->height >> 3; | 561 | *size = fh->fmt->depth*fh->width*fh->height >> 3; |
562 | if (0 == *count) | 562 | if (0 == *count) |
563 | *count = 32; | 563 | *count = 32; |
564 | while (*size * *count > vid_limit * 1024 * 1024) | 564 | if (*size * *count > vid_limit * 1024 * 1024) |
565 | (*count)--; | 565 | *count = (vid_limit * 1024 * 1024) / *size; |
566 | return 0; | 566 | return 0; |
567 | } | 567 | } |
568 | 568 | ||
diff --git a/drivers/media/video/mx1_camera.c b/drivers/media/video/mx1_camera.c index 34a66019190e..5c17f9ec3d7c 100644 --- a/drivers/media/video/mx1_camera.c +++ b/drivers/media/video/mx1_camera.c | |||
@@ -139,8 +139,8 @@ static int mx1_videobuf_setup(struct videobuf_queue *vq, unsigned int *count, | |||
139 | if (!*count) | 139 | if (!*count) |
140 | *count = 32; | 140 | *count = 32; |
141 | 141 | ||
142 | while (*size * *count > MAX_VIDEO_MEM * 1024 * 1024) | 142 | if (*size * *count > MAX_VIDEO_MEM * 1024 * 1024) |
143 | (*count)--; | 143 | *count = (MAX_VIDEO_MEM * 1024 * 1024) / *size; |
144 | 144 | ||
145 | dev_dbg(icd->dev.parent, "count=%d, size=%d\n", *count, *size); | 145 | dev_dbg(icd->dev.parent, "count=%d, size=%d\n", *count, *size); |
146 | 146 | ||
diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c index ce76d952e161..f85b2ed8a2d8 100644 --- a/drivers/media/video/omap24xxcam.c +++ b/drivers/media/video/omap24xxcam.c | |||
@@ -452,8 +452,8 @@ static int omap24xxcam_vbq_setup(struct videobuf_queue *vbq, unsigned int *cnt, | |||
452 | *size = fh->pix.sizeimage; | 452 | *size = fh->pix.sizeimage; |
453 | 453 | ||
454 | /* accessing fh->cam->capture_mem is ok, it's constant */ | 454 | /* accessing fh->cam->capture_mem is ok, it's constant */ |
455 | while (*size * *cnt > fh->cam->capture_mem) | 455 | if (*size * *cnt > fh->cam->capture_mem) |
456 | (*cnt)--; | 456 | *cnt = fh->cam->capture_mem / *size; |
457 | 457 | ||
458 | return 0; | 458 | return 0; |
459 | } | 459 | } |
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c index 04bf5c11308d..7fe70e718656 100644 --- a/drivers/media/video/pxa_camera.c +++ b/drivers/media/video/pxa_camera.c | |||
@@ -253,8 +253,8 @@ static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count, | |||
253 | 253 | ||
254 | if (0 == *count) | 254 | if (0 == *count) |
255 | *count = 32; | 255 | *count = 32; |
256 | while (*size * *count > vid_limit * 1024 * 1024) | 256 | if (*size * *count > vid_limit * 1024 * 1024) |
257 | (*count)--; | 257 | *count = (vid_limit * 1024 * 1024) / *size; |
258 | 258 | ||
259 | return 0; | 259 | return 0; |
260 | } | 260 | } |
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c index 0092ff52bb27..5ecd41b3bf3e 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c | |||
@@ -702,8 +702,8 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned int *count, | |||
702 | if (0 == *count) | 702 | if (0 == *count) |
703 | *count = S2255_DEF_BUFS; | 703 | *count = S2255_DEF_BUFS; |
704 | 704 | ||
705 | while (*size * (*count) > vid_limit * 1024 * 1024) | 705 | if (*size * *count > vid_limit * 1024 * 1024) |
706 | (*count)--; | 706 | *count = (vid_limit * 1024 * 1024) / *size; |
707 | 707 | ||
708 | return 0; | 708 | return 0; |
709 | } | 709 | } |
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index 7a229ebe6923..9a46f0a0c1bb 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c | |||
@@ -213,8 +213,8 @@ static int sh_mobile_ceu_videobuf_setup(struct videobuf_queue *vq, | |||
213 | *count = 2; | 213 | *count = 2; |
214 | 214 | ||
215 | if (pcdev->video_limit) { | 215 | if (pcdev->video_limit) { |
216 | while (PAGE_ALIGN(*size) * *count > pcdev->video_limit) | 216 | if (PAGE_ALIGN(*size) * *count > pcdev->video_limit) |
217 | (*count)--; | 217 | *count = pcdev->video_limit / PAGE_ALIGN(*size); |
218 | } | 218 | } |
219 | 219 | ||
220 | dev_dbg(icd->dev.parent, "count=%d, size=%d\n", *count, *size); | 220 | dev_dbg(icd->dev.parent, "count=%d, size=%d\n", *count, *size); |
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index cdbe70385c12..5a736b8a5a33 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -749,8 +749,8 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) | |||
749 | if (0 == *count) | 749 | if (0 == *count) |
750 | *count = 32; | 750 | *count = 32; |
751 | 751 | ||
752 | while (*size * *count > vid_limit * 1024 * 1024) | 752 | if (*size * *count > vid_limit * 1024 * 1024) |
753 | (*count)--; | 753 | *count = (vid_limit * 1024 * 1024) / *size; |
754 | 754 | ||
755 | dprintk(dev, 1, "%s, count=%d, size=%d\n", __func__, | 755 | dprintk(dev, 1, "%s, count=%d, size=%d\n", __func__, |
756 | *count, *size); | 756 | *count, *size); |
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c index 3d4bac252902..a82b5bd18d26 100644 --- a/drivers/media/video/zr364xx.c +++ b/drivers/media/video/zr364xx.c | |||
@@ -376,8 +376,8 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned int *count, | |||
376 | if (*count == 0) | 376 | if (*count == 0) |
377 | *count = ZR364XX_DEF_BUFS; | 377 | *count = ZR364XX_DEF_BUFS; |
378 | 378 | ||
379 | while (*size * (*count) > ZR364XX_DEF_BUFS * 1024 * 1024) | 379 | if (*size * *count > ZR364XX_DEF_BUFS * 1024 * 1024) |
380 | (*count)--; | 380 | *count = (ZR364XX_DEF_BUFS * 1024 * 1024) / *size; |
381 | 381 | ||
382 | return 0; | 382 | return 0; |
383 | } | 383 | } |
diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 91e0db2e37f9..a3bea2739cef 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c | |||
@@ -516,8 +516,8 @@ int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count, | |||
516 | if (0 == *count) | 516 | if (0 == *count) |
517 | *count = 32; | 517 | *count = 32; |
518 | 518 | ||
519 | while (*size * *count > vid_limit * 1024 * 1024) | 519 | if (*size * *count > vid_limit * 1024 * 1024) |
520 | (*count)--; | 520 | *count = (vid_limit * 1024 * 1024) / *size; |
521 | 521 | ||
522 | return 0; | 522 | return 0; |
523 | } | 523 | } |