aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video
diff options
context:
space:
mode:
authorMarcin Slusarz <marcin.slusarz@gmail.com>2008-04-22 14:45:57 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 14:07:50 -0300
commit76e41e4851e0c8b642e348d8489d7645b8dae21e (patch)
tree63479aebf183b45c9e80f892b3c6e32999ed4341 /drivers/media/video
parentb524f7b02d70204444441e4805fb3a71981e9018 (diff)
V4L/DVB (7365): reduce stack usage of v4l1_compat_sync
poll_one allocated on stack struct poll_wqueues which is pretty big structure (>500 bytes on x86_64). v4l1_compat_sync invokes poll_one in a loop, so allocate struct poll_wqueues in v4l1_compat_sync (with kmalloc) and pass it to poll_one. Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/v4l1-compat.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index e42cea98796..a0f6c60279e 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -199,14 +199,13 @@ pixelformat_to_palette(unsigned int pixelformat)
/* ----------------------------------------------------------------- */
-static int poll_one(struct file *file)
+static int poll_one(struct file *file, struct poll_wqueues *pwq)
{
int retval = 1;
poll_table *table;
- struct poll_wqueues pwq; /*TODO: allocate dynamically*/
- poll_initwait(&pwq);
- table = &pwq.pt;
+ poll_initwait(pwq);
+ table = &pwq->pt;
for (;;) {
int mask;
set_current_state(TASK_INTERRUPTIBLE);
@@ -221,7 +220,7 @@ static int poll_one(struct file *file)
schedule();
}
set_current_state(TASK_RUNNING);
- poll_freewait(&pwq);
+ poll_freewait(pwq);
return retval;
}
@@ -1068,6 +1067,7 @@ static noinline int v4l1_compat_sync(
int err;
enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
struct v4l2_buffer buf;
+ struct poll_wqueues *pwq;
memset(&buf, 0, sizeof(buf));
buf.index = *i;
@@ -1091,10 +1091,11 @@ static noinline int v4l1_compat_sync(
goto done;
}
+ pwq = kmalloc(sizeof(*pwq), GFP_KERNEL);
/* Loop as long as the buffer is queued, but not done */
while ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE))
== V4L2_BUF_FLAG_QUEUED) {
- err = poll_one(file);
+ err = poll_one(file, pwq);
if (err < 0 || /* error or sleep was interrupted */
err == 0) /* timeout? Shouldn't occur. */
break;
@@ -1102,6 +1103,7 @@ static noinline int v4l1_compat_sync(
if (err < 0)
dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err);
}
+ kfree(pwq);
if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */
goto done;
do {