V4L/DVB (8703): gspca: Do controls work for spca561 revision 12a.
[safe/jmp/linux-2.6] / drivers / media / video / ov511.c
index 5d8cd28..9edaca4 100644 (file)
@@ -41,7 +41,6 @@
 #include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/pagemap.h>
-#include <asm/semaphore.h>
 #include <asm/processor.h>
 #include <linux/mm.h>
 #include <linux/device.h>
@@ -181,7 +180,7 @@ module_param(force_palette, int, 0);
 MODULE_PARM_DESC(force_palette, "Force the palette to a specific value");
 module_param(backlight, int, 0);
 MODULE_PARM_DESC(backlight, "For objects that are lit from behind");
-static int num_uv;
+static unsigned int num_uv;
 module_param_array(unit_video, int, &num_uv, 0);
 MODULE_PARM_DESC(unit_video,
   "Force use of specific minor number(s). 0 is not allowed.");
@@ -3503,7 +3502,7 @@ check_middle:
 }
 
 static void
-ov51x_isoc_irq(struct urb *urb, struct pt_regs *regs)
+ov51x_isoc_irq(struct urb *urb)
 {
        int i;
        struct usb_ov511 *ov;
@@ -4653,22 +4652,21 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma)
        return 0;
 }
 
-static struct file_operations ov511_fops = {
+static const struct file_operations ov511_fops = {
        .owner =        THIS_MODULE,
        .open =         ov51x_v4l1_open,
        .release =      ov51x_v4l1_close,
        .read =         ov51x_v4l1_read,
        .mmap =         ov51x_v4l1_mmap,
        .ioctl =        ov51x_v4l1_ioctl,
+#ifdef CONFIG_COMPAT
        .compat_ioctl = v4l_compat_ioctl32,
+#endif
        .llseek =       no_llseek,
 };
 
 static struct video_device vdev_template = {
-       .owner =        THIS_MODULE,
        .name =         "OV511 USB Camera",
-       .type =         VID_TYPE_CAPTURE,
-       .hardware =     VID_HARDWARE_OV511,
        .fops =         &ov511_fops,
        .release =      video_device_release,
        .minor =        -1,
@@ -5554,41 +5552,46 @@ error:
  *  sysfs
  ***************************************************************************/
 
-static inline struct usb_ov511 *cd_to_ov(struct class_device *cd)
+static inline struct usb_ov511 *cd_to_ov(struct device *cd)
 {
        struct video_device *vdev = to_video_device(cd);
        return video_get_drvdata(vdev);
 }
 
-static ssize_t show_custom_id(struct class_device *cd, char *buf)
+static ssize_t show_custom_id(struct device *cd,
+                             struct device_attribute *attr, char *buf)
 {
        struct usb_ov511 *ov = cd_to_ov(cd);
        return sprintf(buf, "%d\n", ov->customid);
 }
-static CLASS_DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL);
+static DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL);
 
-static ssize_t show_model(struct class_device *cd, char *buf)
+static ssize_t show_model(struct device *cd,
+                         struct device_attribute *attr, char *buf)
 {
        struct usb_ov511 *ov = cd_to_ov(cd);
        return sprintf(buf, "%s\n", ov->desc);
 }
-static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
+static DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
 
-static ssize_t show_bridge(struct class_device *cd, char *buf)
+static ssize_t show_bridge(struct device *cd,
+                          struct device_attribute *attr, char *buf)
 {
        struct usb_ov511 *ov = cd_to_ov(cd);
        return sprintf(buf, "%s\n", symbolic(brglist, ov->bridge));
 }
-static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL);
+static DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL);
 
-static ssize_t show_sensor(struct class_device *cd, char *buf)
+static ssize_t show_sensor(struct device *cd,
+                          struct device_attribute *attr, char *buf)
 {
        struct usb_ov511 *ov = cd_to_ov(cd);
        return sprintf(buf, "%s\n", symbolic(senlist, ov->sensor));
 }
-static CLASS_DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL);
+static DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL);
 
-static ssize_t show_brightness(struct class_device *cd, char *buf)
+static ssize_t show_brightness(struct device *cd,
+                              struct device_attribute *attr, char *buf)
 {
        struct usb_ov511 *ov = cd_to_ov(cd);
        unsigned short x;
@@ -5598,9 +5601,10 @@ static ssize_t show_brightness(struct class_device *cd, char *buf)
        sensor_get_brightness(ov, &x);
        return sprintf(buf, "%d\n", x >> 8);
 }
-static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
+static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
 
-static ssize_t show_saturation(struct class_device *cd, char *buf)
+static ssize_t show_saturation(struct device *cd,
+                              struct device_attribute *attr, char *buf)
 {
        struct usb_ov511 *ov = cd_to_ov(cd);
        unsigned short x;
@@ -5610,9 +5614,10 @@ static ssize_t show_saturation(struct class_device *cd, char *buf)
        sensor_get_saturation(ov, &x);
        return sprintf(buf, "%d\n", x >> 8);
 }
-static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
+static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
 
-static ssize_t show_contrast(struct class_device *cd, char *buf)
+static ssize_t show_contrast(struct device *cd,
+                            struct device_attribute *attr, char *buf)
 {
        struct usb_ov511 *ov = cd_to_ov(cd);
        unsigned short x;
@@ -5622,9 +5627,10 @@ static ssize_t show_contrast(struct class_device *cd, char *buf)
        sensor_get_contrast(ov, &x);
        return sprintf(buf, "%d\n", x >> 8);
 }
-static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
+static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
 
-static ssize_t show_hue(struct class_device *cd, char *buf)
+static ssize_t show_hue(struct device *cd,
+                       struct device_attribute *attr, char *buf)
 {
        struct usb_ov511 *ov = cd_to_ov(cd);
        unsigned short x;
@@ -5634,9 +5640,10 @@ static ssize_t show_hue(struct class_device *cd, char *buf)
        sensor_get_hue(ov, &x);
        return sprintf(buf, "%d\n", x >> 8);
 }
-static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
+static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
 
-static ssize_t show_exposure(struct class_device *cd, char *buf)
+static ssize_t show_exposure(struct device *cd,
+                            struct device_attribute *attr, char *buf)
 {
        struct usb_ov511 *ov = cd_to_ov(cd);
        unsigned char exp = 0;
@@ -5646,19 +5653,51 @@ static ssize_t show_exposure(struct class_device *cd, char *buf)
        sensor_get_exposure(ov, &exp);
        return sprintf(buf, "%d\n", exp >> 8);
 }
-static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
+static DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
 
-static void ov_create_sysfs(struct video_device *vdev)
+static int ov_create_sysfs(struct video_device *vdev)
 {
-       video_device_create_file(vdev, &class_device_attr_custom_id);
-       video_device_create_file(vdev, &class_device_attr_model);
-       video_device_create_file(vdev, &class_device_attr_bridge);
-       video_device_create_file(vdev, &class_device_attr_sensor);
-       video_device_create_file(vdev, &class_device_attr_brightness);
-       video_device_create_file(vdev, &class_device_attr_saturation);
-       video_device_create_file(vdev, &class_device_attr_contrast);
-       video_device_create_file(vdev, &class_device_attr_hue);
-       video_device_create_file(vdev, &class_device_attr_exposure);
+       int rc;
+
+       rc = device_create_file(&vdev->dev, &dev_attr_custom_id);
+       if (rc) goto err;
+       rc = device_create_file(&vdev->dev, &dev_attr_model);
+       if (rc) goto err_id;
+       rc = device_create_file(&vdev->dev, &dev_attr_bridge);
+       if (rc) goto err_model;
+       rc = device_create_file(&vdev->dev, &dev_attr_sensor);
+       if (rc) goto err_bridge;
+       rc = device_create_file(&vdev->dev, &dev_attr_brightness);
+       if (rc) goto err_sensor;
+       rc = device_create_file(&vdev->dev, &dev_attr_saturation);
+       if (rc) goto err_bright;
+       rc = device_create_file(&vdev->dev, &dev_attr_contrast);
+       if (rc) goto err_sat;
+       rc = device_create_file(&vdev->dev, &dev_attr_hue);
+       if (rc) goto err_contrast;
+       rc = device_create_file(&vdev->dev, &dev_attr_exposure);
+       if (rc) goto err_hue;
+
+       return 0;
+
+err_hue:
+       device_remove_file(&vdev->dev, &dev_attr_hue);
+err_contrast:
+       device_remove_file(&vdev->dev, &dev_attr_contrast);
+err_sat:
+       device_remove_file(&vdev->dev, &dev_attr_saturation);
+err_bright:
+       device_remove_file(&vdev->dev, &dev_attr_brightness);
+err_sensor:
+       device_remove_file(&vdev->dev, &dev_attr_sensor);
+err_bridge:
+       device_remove_file(&vdev->dev, &dev_attr_bridge);
+err_model:
+       device_remove_file(&vdev->dev, &dev_attr_model);
+err_id:
+       device_remove_file(&vdev->dev, &dev_attr_custom_id);
+err:
+       return rc;
 }
 
 /****************************************************************************
@@ -5792,7 +5831,7 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
                goto error;
 
        memcpy(ov->vdev, &vdev_template, sizeof(*ov->vdev));
-       ov->vdev->dev = &dev->dev;
+       ov->vdev->parent = &intf->dev;
        video_set_drvdata(ov->vdev, ov);
 
        for (i = 0; i < OV511_MAX_UNIT_VIDEO; i++) {
@@ -5817,7 +5856,11 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
             ov->vdev->minor);
 
        usb_set_intfdata(intf, ov);
-       ov_create_sysfs(ov->vdev);
+       if (ov_create_sysfs(ov->vdev)) {
+               err("ov_create_sysfs failed");
+               goto error;
+       }
+
        return 0;
 
 error: