]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/radio/radio-sf16fmi.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[linux-2.6-omap-h63xx.git] / drivers / media / radio / radio-sf16fmi.c
index 0d478f54a90770810198a3e14551ac287b807353..329c90bddadd953836b25cd10dd9668bf2e99329 100644 (file)
@@ -45,6 +45,7 @@ static struct v4l2_queryctrl radio_qctrl[] = {
 
 struct fmi_device
 {
+       unsigned long in_use;
        int port;
        int curvol; /* 1 or 0 */
        unsigned long curfreq; /* freq in kHz */
@@ -146,8 +147,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
                                        struct v4l2_tuner *v)
 {
        int mult;
-       struct video_device *dev = video_devdata(file);
-       struct fmi_device *fmi = dev->priv;
+       struct fmi_device *fmi = video_drvdata(file);
 
        if (v->index > 0)
                return -EINVAL;
@@ -175,8 +175,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
 static int vidioc_s_frequency(struct file *file, void *priv,
                                        struct v4l2_frequency *f)
 {
-       struct video_device *dev = video_devdata(file);
-       struct fmi_device *fmi = dev->priv;
+       struct fmi_device *fmi = video_drvdata(file);
 
        if (!(fmi->flags & V4L2_TUNER_CAP_LOW))
                f->frequency *= 1000;
@@ -193,8 +192,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 static int vidioc_g_frequency(struct file *file, void *priv,
                                        struct v4l2_frequency *f)
 {
-       struct video_device *dev = video_devdata(file);
-       struct fmi_device *fmi = dev->priv;
+       struct fmi_device *fmi = video_drvdata(file);
 
        f->type = V4L2_TUNER_RADIO;
        f->frequency = fmi->curfreq;
@@ -221,8 +219,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
 static int vidioc_g_ctrl(struct file *file, void *priv,
                                        struct v4l2_control *ctrl)
 {
-       struct video_device *dev = video_devdata(file);
-       struct fmi_device *fmi = dev->priv;
+       struct fmi_device *fmi = video_drvdata(file);
 
        switch (ctrl->id) {
        case V4L2_CID_AUDIO_MUTE:
@@ -235,8 +232,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
 static int vidioc_s_ctrl(struct file *file, void *priv,
                                        struct v4l2_control *ctrl)
 {
-       struct video_device *dev = video_devdata(file);
-       struct fmi_device *fmi = dev->priv;
+       struct fmi_device *fmi = video_drvdata(file);
 
        switch (ctrl->id) {
        case V4L2_CID_AUDIO_MUTE:
@@ -284,10 +280,21 @@ static int vidioc_s_audio(struct file *file, void *priv,
 
 static struct fmi_device fmi_unit;
 
+static int fmi_exclusive_open(struct inode *inode, struct file *file)
+{
+       return test_and_set_bit(0, &fmi_unit.in_use) ? -EBUSY : 0;
+}
+
+static int fmi_exclusive_release(struct inode *inode, struct file *file)
+{
+       clear_bit(0, &fmi_unit.in_use);
+       return 0;
+}
+
 static const struct file_operations fmi_fops = {
        .owner          = THIS_MODULE,
-       .open           = video_exclusive_open,
-       .release        = video_exclusive_release,
+       .open           = fmi_exclusive_open,
+       .release        = fmi_exclusive_release,
        .ioctl          = video_ioctl2,
 #ifdef CONFIG_COMPAT
        .compat_ioctl   = v4l_compat_ioctl32,
@@ -314,6 +321,7 @@ static struct video_device fmi_radio = {
        .name           = "SF16FMx radio",
        .fops           = &fmi_fops,
        .ioctl_ops      = &fmi_ioctl_ops,
+       .release        = video_device_release_empty,
 };
 
 /* ladis: this is my card. does any other types exist? */
@@ -373,7 +381,7 @@ static int __init fmi_init(void)
        fmi_unit.curvol = 0;
        fmi_unit.curfreq = 0;
        fmi_unit.flags = V4L2_TUNER_CAP_LOW;
-       fmi_radio.priv = &fmi_unit;
+       video_set_drvdata(&fmi_radio, &fmi_unit);
 
        mutex_init(&lock);