]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/radio/radio-typhoon.c
V4L/DVB (8482): videodev: move all ioctl callbacks to a new v4l2_ioctl_ops struct
[linux-2.6-omap-h63xx.git] / drivers / media / radio / radio-typhoon.c
index 1366326474e5b664951ffe06944cfddccf140e9c..48b5d2bc627603518a78fa26eaa2a48353c4db37 100644 (file)
 #include <linux/init.h>                /* Initdata                       */
 #include <linux/ioport.h>      /* request_region                 */
 #include <linux/proc_fs.h>     /* radio card status report       */
+#include <linux/seq_file.h>
 #include <asm/io.h>            /* outb, outb_p                   */
 #include <asm/uaccess.h>       /* copy to/from user              */
 #include <linux/videodev2.h>   /* kernel radio structs           */
 #include <media/v4l2-common.h>
+#include <media/v4l2-ioctl.h>
 
 #include <linux/version.h>      /* for KERNEL_VERSION MACRO     */
 #define RADIO_VERSION KERNEL_VERSION(0,1,1)
@@ -93,9 +95,6 @@ static int typhoon_setfreq(struct typhoon_device *dev, unsigned long frequency);
 static void typhoon_mute(struct typhoon_device *dev);
 static void typhoon_unmute(struct typhoon_device *dev);
 static int typhoon_setvol(struct typhoon_device *dev, int vol);
-#ifdef CONFIG_RADIO_TYPHOON_PROC_FS
-static int typhoon_get_info(char *buf, char **start, off_t offset, int len);
-#endif
 
 static void typhoon_setvol_generic(struct typhoon_device *dev, int vol)
 {
@@ -340,16 +339,13 @@ static const struct file_operations typhoon_fops = {
        .open           = video_exclusive_open,
        .release        = video_exclusive_release,
        .ioctl          = video_ioctl2,
+#ifdef CONFIG_COMPAT
        .compat_ioctl   = v4l_compat_ioctl32,
+#endif
        .llseek         = no_llseek,
 };
 
-static struct video_device typhoon_radio =
-{
-       .owner          = THIS_MODULE,
-       .name           = "Typhoon Radio",
-       .type           = VID_TYPE_TUNER,
-       .fops           = &typhoon_fops,
+static const struct v4l2_ioctl_ops typhoon_ioctl_ops = {
        .vidioc_querycap    = vidioc_querycap,
        .vidioc_g_tuner     = vidioc_g_tuner,
        .vidioc_s_tuner     = vidioc_s_tuner,
@@ -364,32 +360,49 @@ static struct video_device typhoon_radio =
        .vidioc_s_ctrl      = vidioc_s_ctrl,
 };
 
+static struct video_device typhoon_radio = {
+       .owner          = THIS_MODULE,
+       .name           = "Typhoon Radio",
+       .type           = VID_TYPE_TUNER,
+       .fops           = &typhoon_fops,
+       .ioctl_ops      = &typhoon_ioctl_ops,
+};
+
 #ifdef CONFIG_RADIO_TYPHOON_PROC_FS
 
-static int typhoon_get_info(char *buf, char **start, off_t offset, int len)
+static int typhoon_proc_show(struct seq_file *m, void *v)
 {
-       char *out = buf;
-
        #ifdef MODULE
            #define MODULEPROCSTRING "Driver loaded as a module"
        #else
            #define MODULEPROCSTRING "Driver compiled into kernel"
        #endif
 
-       /* output must be kept under PAGE_SIZE */
-       out += sprintf(out, BANNER);
-       out += sprintf(out, "Load type: " MODULEPROCSTRING "\n\n");
-       out += sprintf(out, "frequency = %lu kHz\n",
+       seq_puts(m, BANNER);
+       seq_puts(m, "Load type: " MODULEPROCSTRING "\n\n");
+       seq_printf(m, "frequency = %lu kHz\n",
                typhoon_unit.curfreq >> 4);
-       out += sprintf(out, "volume = %d\n", typhoon_unit.curvol);
-       out += sprintf(out, "mute = %s\n", typhoon_unit.muted ?
+       seq_printf(m, "volume = %d\n", typhoon_unit.curvol);
+       seq_printf(m, "mute = %s\n", typhoon_unit.muted ?
                "on" : "off");
-       out += sprintf(out, "iobase = 0x%x\n", typhoon_unit.iobase);
-       out += sprintf(out, "mute frequency = %lu kHz\n",
+       seq_printf(m, "iobase = 0x%x\n", typhoon_unit.iobase);
+       seq_printf(m, "mute frequency = %lu kHz\n",
                typhoon_unit.mutefreq >> 4);
-       return out - buf;
+       return 0;
 }
 
+static int typhoon_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, typhoon_proc_show, NULL);
+}
+
+static const struct file_operations typhoon_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = typhoon_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
 #endif /* CONFIG_RADIO_TYPHOON_PROC_FS */
 
 MODULE_AUTHOR("Dr. Henrik Seidel");
@@ -404,7 +417,7 @@ MODULE_PARM_DESC(io, "I/O address of the Typhoon card (0x316 or 0x336)");
 module_param(radio_nr, int, 0);
 
 #ifdef MODULE
-static unsigned long mutefreq = 0;
+static unsigned long mutefreq;
 module_param(mutefreq, ulong, 0);
 MODULE_PARM_DESC(mutefreq, "Frequency used when muting the card (in kHz)");
 #endif
@@ -450,8 +463,7 @@ static int __init typhoon_init(void)
        typhoon_mute(&typhoon_unit);
 
 #ifdef CONFIG_RADIO_TYPHOON_PROC_FS
-       if (!create_proc_info_entry("driver/radio-typhoon", 0, NULL,
-                                   typhoon_get_info))
+       if (!proc_create("driver/radio-typhoon", 0, NULL, &typhoon_proc_fops))
                printk(KERN_ERR "radio-typhoon: registering /proc/driver/radio-typhoon failed\n");
 #endif