V4L/DVB (8703): gspca: Do controls work for spca561 revision 12a.
[safe/jmp/linux-2.6] / drivers / media / video / v4l2-dev.c
index 2dd82b1..0320fb8 100644 (file)
 static ssize_t show_index(struct device *cd,
                         struct device_attribute *attr, char *buf)
 {
-       struct video_device *vfd = container_of(cd, struct video_device,
-                                               class_dev);
+       struct video_device *vfd = container_of(cd, struct video_device, dev);
        return sprintf(buf, "%i\n", vfd->index);
 }
 
 static ssize_t show_name(struct device *cd,
                         struct device_attribute *attr, char *buf)
 {
-       struct video_device *vfd = container_of(cd, struct video_device,
-                                               class_dev);
+       struct video_device *vfd = container_of(cd, struct video_device, dev);
        return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
 }
 
@@ -77,8 +75,7 @@ EXPORT_SYMBOL(video_device_release);
 
 static void video_release(struct device *cd)
 {
-       struct video_device *vfd = container_of(cd, struct video_device,
-                                                               class_dev);
+       struct video_device *vfd = container_of(cd, struct video_device, dev);
 
 #if 1
        /* needed until all drivers are fixed */
@@ -201,7 +198,7 @@ static int get_index(struct video_device *vdev, int num)
        for (i = 0; i < VIDEO_NUM_DEVICES; i++) {
                if (video_device[i] != NULL &&
                    video_device[i] != vdev &&
-                   video_device[i]->dev == vdev->dev) {
+                   video_device[i]->parent == vdev->parent) {
                        used |= 1 << video_device[i]->index;
                }
        }
@@ -225,11 +222,13 @@ int video_register_device(struct video_device *vfd, int type, int nr)
 EXPORT_SYMBOL(video_register_device);
 
 /**
- *     video_register_device - register video4linux devices
+ *     video_register_device_index - register video4linux devices
  *     @vfd:  video device structure we want to register
  *     @type: type of device to register
  *     @nr:   which device number (0 == /dev/video0, 1 == /dev/video1, ...
  *             -1 == first free)
+ *     @index: stream number based on parent device;
+ *             -1 if auto assign, requested number otherwise
  *
  *     The registration code assigns minor numbers based on the type
  *     requested. -ENFILE is returned in all the device slots for this
@@ -282,7 +281,7 @@ int video_register_device_index(struct video_device *vfd, int type, int nr,
        default:
                printk(KERN_ERR "%s called with unknown type: %d\n",
                       __func__, type);
-               return -1;
+               return -EINVAL;
        }
 
        /* pick a minor number */
@@ -305,6 +304,7 @@ int video_register_device_index(struct video_device *vfd, int type, int nr,
                }
        }
        video_device[i] = vfd;
+       vfd->vfl_type = type;
        vfd->minor = i;
 
        ret = get_index(vfd, index);
@@ -320,13 +320,13 @@ int video_register_device_index(struct video_device *vfd, int type, int nr,
        mutex_init(&vfd->lock);
 
        /* sysfs class */
-       memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
-       vfd->class_dev.class = &video_class;
-       vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
-       if (vfd->dev)
-               vfd->class_dev.parent = vfd->dev;
-       sprintf(vfd->class_dev.bus_id, "%s%d", name_base, i - base);
-       ret = device_register(&vfd->class_dev);
+       memset(&vfd->dev, 0x00, sizeof(vfd->dev));
+       vfd->dev.class = &video_class;
+       vfd->dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
+       if (vfd->parent)
+               vfd->dev.parent = vfd->parent;
+       sprintf(vfd->dev.bus_id, "%s%d", name_base, i - base);
+       ret = device_register(&vfd->dev);
        if (ret < 0) {
                printk(KERN_ERR "%s: device_register failed\n", __func__);
                goto fail_minor;
@@ -365,7 +365,7 @@ void video_unregister_device(struct video_device *vfd)
                panic("videodev: bad unregister");
 
        video_device[vfd->minor] = NULL;
-       device_unregister(&vfd->class_dev);
+       device_unregister(&vfd->dev);
        mutex_unlock(&videodev_lock);
 }
 EXPORT_SYMBOL(video_unregister_device);