- patches.suse/slab-handle-memoryless-nodes-v2a.patch: Refresh.
[linux-flexiantxendom0-3.2.10.git] / drivers / media / video / cx23885 / cx23885-417.c
index 6c3b51c..88c0d24 100644 (file)
@@ -37,6 +37,7 @@
 #include <media/cx2341x.h>
 
 #include "cx23885.h"
+#include "cx23885-ioctl.h"
 
 #define CX23885_FIRM_IMAGE_SIZE 376836
 #define CX23885_FIRM_IMAGE_NAME "v4l-cx23885-enc.fw"
@@ -318,7 +319,7 @@ static int mc417_wait_ready(struct cx23885_dev *dev)
        }
 }
 
-static int mc417_register_write(struct cx23885_dev *dev, u16 address, u32 value)
+int mc417_register_write(struct cx23885_dev *dev, u16 address, u32 value)
 {
        u32 regval;
 
@@ -382,7 +383,7 @@ static int mc417_register_write(struct cx23885_dev *dev, u16 address, u32 value)
        return mc417_wait_ready(dev);
 }
 
-static int mc417_register_read(struct cx23885_dev *dev, u16 address, u32 *value)
+int mc417_register_read(struct cx23885_dev *dev, u16 address, u32 *value)
 {
        int retval;
        u32 regval;
@@ -1567,28 +1568,11 @@ static int vidioc_queryctrl(struct file *file, void *priv,
 
 static int mpeg_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx23885_dev *h, *dev = NULL;
-       struct list_head *list;
+       struct cx23885_dev *dev = video_drvdata(file);
        struct cx23885_fh *fh;
 
        dprintk(2, "%s()\n", __func__);
 
-       lock_kernel();
-       list_for_each(list, &cx23885_devlist) {
-               h = list_entry(list, struct cx23885_dev, devlist);
-               if (h->v4l_device &&
-                   h->v4l_device->minor == minor) {
-                       dev = h;
-                       break;
-               }
-       }
-
-       if (dev == NULL) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
        if (NULL == fh) {
@@ -1596,6 +1580,8 @@ static int mpeg_open(struct file *file)
                return -ENOMEM;
        }
 
+       lock_kernel();
+
        file->private_data = fh;
        fh->dev      = dev;
 
@@ -1724,13 +1710,17 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
        .vidioc_log_status       = vidioc_log_status,
        .vidioc_querymenu        = vidioc_querymenu,
        .vidioc_queryctrl        = vidioc_queryctrl,
+       .vidioc_g_chip_ident     = cx23885_g_chip_ident,
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+       .vidioc_g_register       = cx23885_g_register,
+       .vidioc_s_register       = cx23885_s_register,
+#endif
 };
 
 static struct video_device cx23885_mpeg_template = {
        .name          = "cx23885",
        .fops          = &mpeg_fops,
        .ioctl_ops     = &mpeg_ioctl_ops,
-       .minor         = -1,
        .tvnorms       = CX23885_NORMS,
        .current_norm  = V4L2_STD_NTSC_M,
 };
@@ -1740,7 +1730,7 @@ void cx23885_417_unregister(struct cx23885_dev *dev)
        dprintk(1, "%s()\n", __func__);
 
        if (dev->v4l_device) {
-               if (-1 != dev->v4l_device->minor)
+               if (video_is_registered(dev->v4l_device))
                        video_unregister_device(dev->v4l_device);
                else
                        video_device_release(dev->v4l_device);
@@ -1797,6 +1787,7 @@ int cx23885_417_register(struct cx23885_dev *dev)
        /* Allocate and initialize V4L video device */
        dev->v4l_device = cx23885_video_dev_alloc(tsport,
                dev->pci, &cx23885_mpeg_template, "mpeg");
+       video_set_drvdata(dev->v4l_device, dev);
        err = video_register_device(dev->v4l_device,
                VFL_TYPE_GRABBER, -1);
        if (err < 0) {
@@ -1804,8 +1795,8 @@ int cx23885_417_register(struct cx23885_dev *dev)
                return err;
        }
 
-       printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
-              dev->name, dev->v4l_device->num);
+       printk(KERN_INFO "%s: registered device %s [mpeg]\n",
+              dev->name, video_device_node_name(dev->v4l_device));
 
        return 0;
 }