Skip to content

Commit

Permalink
V4L/DVB (8506): empress: fix control handling oops
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Jul 27, 2008
1 parent 1052efe commit 531d83a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
20 changes: 18 additions & 2 deletions drivers/media/video/saa7134/saa7134-empress.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,22 @@ static int empress_g_ext_ctrls(struct file *file, void *priv,
return saa7134_i2c_call_saa6752(dev, VIDIOC_G_EXT_CTRLS, ctrls);
}

static int empress_g_ctrl(struct file *file, void *priv,
struct v4l2_control *c)
{
struct saa7134_dev *dev = file->private_data;

return saa7134_g_ctrl_internal(dev, NULL, c);
}

static int empress_s_ctrl(struct file *file, void *priv,
struct v4l2_control *c)
{
struct saa7134_dev *dev = file->private_data;

return saa7134_s_ctrl_internal(dev, NULL, c);
}

static int empress_queryctrl(struct file *file, void *priv,
struct v4l2_queryctrl *c)
{
Expand Down Expand Up @@ -415,8 +431,8 @@ static const struct v4l2_ioctl_ops ts_ioctl_ops = {

.vidioc_queryctrl = empress_queryctrl,
.vidioc_querymenu = empress_querymenu,
.vidioc_g_ctrl = saa7134_g_ctrl,
.vidioc_s_ctrl = saa7134_s_ctrl,
.vidioc_g_ctrl = empress_g_ctrl,
.vidioc_s_ctrl = empress_s_ctrl,
};

/* ----------------------------------------------------------- */
Expand Down
40 changes: 28 additions & 12 deletions drivers/media/video/saa7134/saa7134-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,10 +1112,8 @@ static struct videobuf_queue_ops video_qops = {

/* ------------------------------------------------------------------ */

int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c)
int saa7134_g_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c)
{
struct saa7134_fh *fh = priv;
struct saa7134_dev *dev = fh->dev;
const struct v4l2_queryctrl* ctrl;

ctrl = ctrl_by_id(c->id);
Expand Down Expand Up @@ -1160,20 +1158,31 @@ int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c)
}
return 0;
}
EXPORT_SYMBOL_GPL(saa7134_g_ctrl);
EXPORT_SYMBOL_GPL(saa7134_g_ctrl_internal);

static int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c)
{
struct saa7134_fh *fh = priv;

return saa7134_g_ctrl_internal(fh->dev, fh, c);
}

int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c)
int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c)
{
const struct v4l2_queryctrl* ctrl;
struct saa7134_fh *fh = f;
struct saa7134_dev *dev = fh->dev;
unsigned long flags;
int restart_overlay = 0;
int err = -EINVAL;
int err;

err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
/* When called from the empress code fh == NULL.
That needs to be fixed somehow, but for now this is
good enough. */
if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
err = -EINVAL;

mutex_lock(&dev->lock);

Expand Down Expand Up @@ -1274,7 +1283,14 @@ int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c)
mutex_unlock(&dev->lock);
return err;
}
EXPORT_SYMBOL_GPL(saa7134_s_ctrl);
EXPORT_SYMBOL_GPL(saa7134_s_ctrl_internal);

static int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c)
{
struct saa7134_fh *fh = f;

return saa7134_s_ctrl_internal(fh->dev, fh, c);
}

/* ------------------------------------------------------------------ */

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/saa7134/saa7134.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ extern unsigned int video_debug;
extern struct video_device saa7134_video_template;
extern struct video_device saa7134_radio_template;

int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c);
int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c);
int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c);
int saa7134_g_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c);
int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c);

int saa7134_videoport_init(struct saa7134_dev *dev);
Expand Down

0 comments on commit 531d83a

Please sign in to comment.