]> err.no Git - linux-2.6/commitdiff
V4L/DVB (8506): empress: fix control handling oops
authorHans Verkuil <hverkuil@xs4all.nl>
Sat, 26 Jul 2008 12:04:06 +0000 (09:04 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 27 Jul 2008 14:06:25 +0000 (11:06 -0300)
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/saa7134/saa7134-empress.c
drivers/media/video/saa7134/saa7134-video.c
drivers/media/video/saa7134/saa7134.h

index 2ecfbd1b41fc0beb4104ac8130b5a3efb8dbaebb..cd52d5be404da0347fb103a223c532a96038f59d 100644 (file)
@@ -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)
 {
@@ -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,
 };
 
 /* ----------------------------------------------------------- */
index 5e9cfc891be8f8968168e9ecaae02d98c36ac878..eb824897416b64a1ff884c27298b5464894a71ad 100644 (file)
@@ -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);
@@ -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);
 
@@ -1274,7 +1283,14 @@ error:
        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);
+}
 
 /* ------------------------------------------------------------------ */
 
index ed20dd56379c6eb52df281f691b43f675390dc38..a0884f639f6504b6826c9e791107f3bbe3f9f06c 100644 (file)
@@ -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);