V4L/DVB: v4l2: hook up the new control framework into the core framework
[pandora-kernel.git] / drivers / media / video / v4l2-device.c
index 5a7dc4a..0b08f96 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 #include <linux/videodev2.h>
 #include <media/v4l2-device.h>
+#include <media/v4l2-ctrls.h>
 
 int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
 {
@@ -115,6 +116,8 @@ EXPORT_SYMBOL_GPL(v4l2_device_unregister);
 int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
                                                struct v4l2_subdev *sd)
 {
+       int err;
+
        /* Check for valid input */
        if (v4l2_dev == NULL || sd == NULL || !sd->name[0])
                return -EINVAL;
@@ -122,6 +125,10 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
        WARN_ON(sd->v4l2_dev != NULL);
        if (!try_module_get(sd->owner))
                return -ENODEV;
+       /* This just returns 0 if either of the two args is NULL */
+       err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler);
+       if (err)
+               return err;
        sd->v4l2_dev = v4l2_dev;
        spin_lock(&v4l2_dev->lock);
        list_add_tail(&sd->list, &v4l2_dev->subdevs);