Skip to content

Commit

Permalink
V4L/DVB: V4L2: Replace loops for finding max buffers in VIDIOC_REQBUF…
Browse files Browse the repository at this point in the history
…S 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>
  • Loading branch information
Andreas Bombe authored and Mauro Carvalho Chehab committed May 19, 2010
1 parent 0a06203 commit dab7e31
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions drivers/media/video/bt8xx/bttv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1806,8 +1806,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
*size = fh->fmt->depth*fh->width*fh->height >> 3;
if (0 == *count)
*count = gbuffers;
while (*size * *count > gbuffers * gbufsize)
(*count)--;
if (*size * *count > gbuffers * gbufsize)
*count = (gbuffers * gbufsize) / *size;
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/cx23885/cx23885-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count,
*size = fh->fmt->depth*fh->width*fh->height >> 3;
if (0 == *count)
*count = 32;
while (*size * *count > vid_limit * 1024 * 1024)
(*count)--;
if (*size * *count > vid_limit * 1024 * 1024)
*count = (vid_limit * 1024 * 1024) / *size;
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/cx88/cx88-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
*size = fh->fmt->depth*fh->width*fh->height >> 3;
if (0 == *count)
*count = 32;
while (*size * *count > vid_limit * 1024 * 1024)
(*count)--;
if (*size * *count > vid_limit * 1024 * 1024)
*count = (vid_limit * 1024 * 1024) / *size;
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/mx1_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ static int mx1_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
if (!*count)
*count = 32;

while (*size * *count > MAX_VIDEO_MEM * 1024 * 1024)
(*count)--;
if (*size * *count > MAX_VIDEO_MEM * 1024 * 1024)
*count = (MAX_VIDEO_MEM * 1024 * 1024) / *size;

dev_dbg(icd->dev.parent, "count=%d, size=%d\n", *count, *size);

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/omap24xxcam.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ static int omap24xxcam_vbq_setup(struct videobuf_queue *vbq, unsigned int *cnt,
*size = fh->pix.sizeimage;

/* accessing fh->cam->capture_mem is ok, it's constant */
while (*size * *cnt > fh->cam->capture_mem)
(*cnt)--;
if (*size * *cnt > fh->cam->capture_mem)
*cnt = fh->cam->capture_mem / *size;

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/pxa_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,

if (0 == *count)
*count = 32;
while (*size * *count > vid_limit * 1024 * 1024)
(*count)--;
if (*size * *count > vid_limit * 1024 * 1024)
*count = (vid_limit * 1024 * 1024) / *size;

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/s2255drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned int *count,
if (0 == *count)
*count = S2255_DEF_BUFS;

while (*size * (*count) > vid_limit * 1024 * 1024)
(*count)--;
if (*size * *count > vid_limit * 1024 * 1024)
*count = (vid_limit * 1024 * 1024) / *size;

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/sh_mobile_ceu_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ static int sh_mobile_ceu_videobuf_setup(struct videobuf_queue *vq,
*count = 2;

if (pcdev->video_limit) {
while (PAGE_ALIGN(*size) * *count > pcdev->video_limit)
(*count)--;
if (PAGE_ALIGN(*size) * *count > pcdev->video_limit)
*count = pcdev->video_limit / PAGE_ALIGN(*size);
}

dev_dbg(icd->dev.parent, "count=%d, size=%d\n", *count, *size);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/vivi.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,8 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
if (0 == *count)
*count = 32;

while (*size * *count > vid_limit * 1024 * 1024)
(*count)--;
if (*size * *count > vid_limit * 1024 * 1024)
*count = (vid_limit * 1024 * 1024) / *size;

dprintk(dev, 1, "%s, count=%d, size=%d\n", __func__,
*count, *size);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/zr364xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned int *count,
if (*count == 0)
*count = ZR364XX_DEF_BUFS;

while (*size * (*count) > ZR364XX_DEF_BUFS * 1024 * 1024)
(*count)--;
if (*size * *count > ZR364XX_DEF_BUFS * 1024 * 1024)
*count = (ZR364XX_DEF_BUFS * 1024 * 1024) / *size;

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/cx25821/cx25821-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count,
if (0 == *count)
*count = 32;

while (*size * *count > vid_limit * 1024 * 1024)
(*count)--;
if (*size * *count > vid_limit * 1024 * 1024)
*count = (vid_limit * 1024 * 1024) / *size;

return 0;
}
Expand Down

0 comments on commit dab7e31

Please sign in to comment.