]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/usbvideo/usbvideo.c
V4L/DVB (5766): ET61x251 driver updates
[linux-2.6-omap-h63xx.git] / drivers / media / video / usbvideo / usbvideo.c
index b560c9d7c5168f492809ddab1308d64fab75e297..37ce36b9e5878bc9123691e3b859b442995b93bd 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/mm.h>
-#include <linux/smp_lock.h>
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
@@ -628,24 +627,21 @@ EXPORT_SYMBOL(usbvideo_HexDump);
 /* ******************************************************************** */
 
 /* XXX: this piece of crap really wants some error handling.. */
-static void usbvideo_ClientIncModCount(struct uvd *uvd)
+static int usbvideo_ClientIncModCount(struct uvd *uvd)
 {
        if (uvd == NULL) {
                err("%s: uvd == NULL", __FUNCTION__);
-               return;
+               return -EINVAL;
        }
        if (uvd->handle == NULL) {
                err("%s: uvd->handle == NULL", __FUNCTION__);
-               return;
-       }
-       if (uvd->handle->md_module == NULL) {
-               err("%s: uvd->handle->md_module == NULL", __FUNCTION__);
-               return;
+               return -EINVAL;
        }
        if (!try_module_get(uvd->handle->md_module)) {
                err("%s: try_module_get() == 0", __FUNCTION__);
-               return;
+               return -ENODEV;
        }
+       return 0;
 }
 
 static void usbvideo_ClientDecModCount(struct uvd *uvd)
@@ -712,8 +708,6 @@ int usbvideo_register(
        cams->num_cameras = num_cams;
        cams->cam = (struct uvd *) &cams[1];
        cams->md_module = md;
-       if (cams->md_module == NULL)
-               warn("%s: module == NULL!", __FUNCTION__);
        mutex_init(&cams->lock);        /* to 1 == available */
 
        for (i = 0; i < num_cams; i++) {
@@ -945,7 +939,7 @@ static int usbvideo_find_struct(struct usbvideo *cams)
        return rv;
 }
 
-static struct file_operations usbvideo_fops = {
+static const struct file_operations usbvideo_fops = {
        .owner =  THIS_MODULE,
        .open =   usbvideo_v4l_open,
        .release =usbvideo_v4l_close,
@@ -1119,7 +1113,8 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file)
        if (uvd->debug > 1)
                info("%s($%p)", __FUNCTION__, dev);
 
-       usbvideo_ClientIncModCount(uvd);
+       if (0 < usbvideo_ClientIncModCount(uvd))
+               return -ENODEV;
        mutex_lock(&uvd->lock);
 
        if (uvd->user) {