]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/stv680.c
V4L/DVB (4741): {ov511,stv680}: handle sysfs errors
[linux-2.6-omap-h63xx.git] / drivers / media / video / stv680.c
index 2ba2991a214ff3026858a13929468869d9da2cf4..6d1ef1e2e8efd9dbf8be48763ee7283b3cf42021 100644 (file)
@@ -516,16 +516,45 @@ stv680_file(frames_read, framecount, "%d\n");
 stv680_file(packets_dropped, dropped, "%d\n");
 stv680_file(decoding_errors, error, "%d\n");
 
-static void stv680_create_sysfs_files(struct video_device *vdev)
+static int stv680_create_sysfs_files(struct video_device *vdev)
 {
-       video_device_create_file(vdev, &class_device_attr_model);
-       video_device_create_file(vdev, &class_device_attr_in_use);
-       video_device_create_file(vdev, &class_device_attr_streaming);
-       video_device_create_file(vdev, &class_device_attr_palette);
-       video_device_create_file(vdev, &class_device_attr_frames_total);
-       video_device_create_file(vdev, &class_device_attr_frames_read);
-       video_device_create_file(vdev, &class_device_attr_packets_dropped);
-       video_device_create_file(vdev, &class_device_attr_decoding_errors);
+       int rc;
+
+       rc = video_device_create_file(vdev, &class_device_attr_model);
+       if (rc) goto err;
+       rc = video_device_create_file(vdev, &class_device_attr_in_use);
+       if (rc) goto err_model;
+       rc = video_device_create_file(vdev, &class_device_attr_streaming);
+       if (rc) goto err_inuse;
+       rc = video_device_create_file(vdev, &class_device_attr_palette);
+       if (rc) goto err_stream;
+       rc = video_device_create_file(vdev, &class_device_attr_frames_total);
+       if (rc) goto err_pal;
+       rc = video_device_create_file(vdev, &class_device_attr_frames_read);
+       if (rc) goto err_framtot;
+       rc = video_device_create_file(vdev, &class_device_attr_packets_dropped);
+       if (rc) goto err_framread;
+       rc = video_device_create_file(vdev, &class_device_attr_decoding_errors);
+       if (rc) goto err_dropped;
+
+       return 0;
+
+err_dropped:
+       video_device_remove_file(vdev, &class_device_attr_packets_dropped);
+err_framread:
+       video_device_remove_file(vdev, &class_device_attr_frames_read);
+err_framtot:
+       video_device_remove_file(vdev, &class_device_attr_frames_total);
+err_pal:
+       video_device_remove_file(vdev, &class_device_attr_palette);
+err_stream:
+       video_device_remove_file(vdev, &class_device_attr_streaming);
+err_inuse:
+       video_device_remove_file(vdev, &class_device_attr_in_use);
+err_model:
+       video_device_remove_file(vdev, &class_device_attr_model);
+err:
+       return rc;
 }
 
 static void stv680_remove_sysfs_files(struct video_device *vdev)
@@ -582,7 +611,7 @@ static int stv680_set_pict (struct usb_stv *stv680, struct video_picture *p)
        return 0;
 }
 
-static void stv680_video_irq (struct urb *urb, struct pt_regs *regs)
+static void stv680_video_irq (struct urb *urb)
 {
        struct usb_stv *stv680 = urb->context;
        int length = urb->actual_length;
@@ -1418,9 +1447,13 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
        PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev->minor);
 
        usb_set_intfdata (intf, stv680);
-       stv680_create_sysfs_files(stv680->vdev);
+       retval = stv680_create_sysfs_files(stv680->vdev);
+       if (retval)
+               goto error_unreg;
        return 0;
 
+error_unreg:
+       video_unregister_device(stv680->vdev);
 error_vdev:
        video_device_release(stv680->vdev);
 error: