]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/radio/radio-aimslab.c
V4L/DVB (8776): radio: replace video_exclusive_open/release
[linux-2.6-omap-h63xx.git] / drivers / media / radio / radio-aimslab.c
index f0a67e93d7fd0765a38baece496b3eadc18b2b3a..b657c7bb47cc885c18359995ccd2b4b3f8d80a44 100644 (file)
@@ -36,7 +36,7 @@
 #include <asm/uaccess.h>       /* copy to/from user            */
 #include <linux/videodev2.h>   /* kernel radio structs         */
 #include <media/v4l2-common.h>
-#include <asm/semaphore.h>     /* Lock for the I/O             */
+#include <media/v4l2-ioctl.h>
 
 #include <linux/version.h>     /* for KERNEL_VERSION MACRO     */
 #define RADIO_VERSION KERNEL_VERSION(0,0,2)
@@ -51,6 +51,7 @@ static struct mutex lock;
 
 struct rt_device
 {
+       unsigned long in_use;
        int port;
        int curvol;
        unsigned long curfreq;
@@ -378,21 +379,29 @@ static int vidioc_s_audio(struct file *file, void *priv,
 
 static struct rt_device rtrack_unit;
 
+static int rtrack_exclusive_open(struct inode *inode, struct file *file)
+{
+       return test_and_set_bit(0, &rtrack_unit.in_use) ? -EBUSY : 0;
+}
+
+static int rtrack_exclusive_release(struct inode *inode, struct file *file)
+{
+       clear_bit(0, &rtrack_unit.in_use);
+       return 0;
+}
+
 static const struct file_operations rtrack_fops = {
        .owner          = THIS_MODULE,
-       .open           = video_exclusive_open,
-       .release        = video_exclusive_release,
+       .open           = rtrack_exclusive_open,
+       .release        = rtrack_exclusive_release,
        .ioctl          = video_ioctl2,
+#ifdef CONFIG_COMPAT
        .compat_ioctl   = v4l_compat_ioctl32,
+#endif
        .llseek         = no_llseek,
 };
 
-static struct video_device rtrack_radio=
-{
-       .owner          = THIS_MODULE,
-       .name           = "RadioTrack radio",
-       .type           = VID_TYPE_TUNER,
-       .fops           = &rtrack_fops,
+static const struct v4l2_ioctl_ops rtrack_ioctl_ops = {
        .vidioc_querycap    = vidioc_querycap,
        .vidioc_g_tuner     = vidioc_g_tuner,
        .vidioc_s_tuner     = vidioc_s_tuner,
@@ -407,6 +416,12 @@ static struct video_device rtrack_radio=
        .vidioc_s_ctrl      = vidioc_s_ctrl,
 };
 
+static struct video_device rtrack_radio = {
+       .name           = "RadioTrack radio",
+       .fops           = &rtrack_fops,
+       .ioctl_ops      = &rtrack_ioctl_ops,
+};
+
 static int __init rtrack_init(void)
 {
        if(io==-1)
@@ -423,8 +438,7 @@ static int __init rtrack_init(void)
 
        rtrack_radio.priv=&rtrack_unit;
 
-       if(video_register_device(&rtrack_radio, VFL_TYPE_RADIO, radio_nr)==-1)
-       {
+       if (video_register_device(&rtrack_radio, VFL_TYPE_RADIO, radio_nr) < 0) {
                release_region(io, 2);
                return -EINVAL;
        }