V4L/DVB (9297): cx18: Fix memory leak on card initialization failure
[safe/jmp/linux-2.6] / drivers / media / video / w9968cf.c
index 77599f2..dcd45db 100644 (file)
@@ -42,6 +42,7 @@
 #include <asm/page.h>
 #include <asm/uaccess.h>
 #include <linux/page-flags.h>
+#include <media/v4l2-ioctl.h>
 
 #include "w9968cf.h"
 #include "w9968cf_decoder.h"
@@ -110,7 +111,7 @@ static int specific_debug = W9968CF_SPECIFIC_DEBUG;
 
 static unsigned int param_nv[24]; /* number of values per parameter */
 
-#ifdef CONFIG_KMOD
+#ifdef CONFIG_MODULES
 module_param(ovmod_load, bool, 0644);
 #endif
 module_param(simcams, ushort, 0644);
@@ -143,7 +144,7 @@ module_param(debug, ushort, 0644);
 module_param(specific_debug, bool, 0644);
 #endif
 
-#ifdef CONFIG_KMOD
+#ifdef CONFIG_MODULES
 MODULE_PARM_DESC(ovmod_load,
                 "\n<0|1> Automatic 'ovcamchip' module loading."
                 "\n0 disabled, 1 enabled."
@@ -444,8 +445,6 @@ static int w9968cf_i2c_smbus_xfer(struct i2c_adapter*, u16 addr,
 static u32 w9968cf_i2c_func(struct i2c_adapter*);
 static int w9968cf_i2c_attach_inform(struct i2c_client*);
 static int w9968cf_i2c_detach_inform(struct i2c_client*);
-static int w9968cf_i2c_control(struct i2c_adapter*, unsigned int cmd,
-                              unsigned long arg);
 
 /* Memory management */
 static void* rvmalloc(unsigned long size);
@@ -912,7 +911,6 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
 
        for (i = 0; i < W9968CF_URBS; i++) {
                urb = usb_alloc_urb(W9968CF_ISO_PACKETS, GFP_KERNEL);
-               cam->urb[i] = urb;
                if (!urb) {
                        for (j = 0; j < i; j++)
                                usb_free_urb(cam->urb[j]);
@@ -920,6 +918,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
                        return -ENOMEM;
                }
 
+               cam->urb[i] = urb;
                urb->dev = udev;
                urb->context = (void*)cam;
                urb->pipe = usb_rcvisocpipe(udev, 1);
@@ -1543,21 +1542,12 @@ static int w9968cf_i2c_detach_inform(struct i2c_client* client)
 }
 
 
-static int
-w9968cf_i2c_control(struct i2c_adapter* adapter, unsigned int cmd,
-                   unsigned long arg)
-{
-       return 0;
-}
-
-
 static int w9968cf_i2c_init(struct w9968cf_device* cam)
 {
        int err = 0;
 
        static struct i2c_algorithm algo = {
                .smbus_xfer =    w9968cf_i2c_smbus_xfer,
-               .algo_control =  w9968cf_i2c_control,
                .functionality = w9968cf_i2c_func,
        };
 
@@ -2679,7 +2669,7 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
 
        /* This the only safe way to prevent race conditions with disconnect */
        if (!down_read_trylock(&w9968cf_disconnect))
-               return -ERESTARTSYS;
+               return -EAGAIN;
 
        cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp));
 
@@ -3472,7 +3462,9 @@ static const struct file_operations w9968cf_fops = {
        .release = w9968cf_release,
        .read =    w9968cf_read,
        .ioctl =   w9968cf_ioctl,
+#ifdef CONFIG_COMPAT
        .compat_ioctl = v4l_compat_ioctl32,
+#endif
        .mmap =    w9968cf_mmap,
        .llseek =  no_llseek,
 };
@@ -3492,7 +3484,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
        enum w9968cf_model_id mod_id;
        struct list_head* ptr;
        u8 sc = 0; /* number of simultaneous cameras */
-       static unsigned short dev_nr = 0; /* we are handling device number n */
+       static unsigned short dev_nr; /* 0 - we are handling device number n */
 
        if (le16_to_cpu(udev->descriptor.idVendor)  == winbond_id_table[0].idVendor &&
            le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct)
@@ -3558,14 +3550,11 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
        }
 
        strcpy(cam->v4ldev->name, symbolic(camlist, mod_id));
-       cam->v4ldev->owner = THIS_MODULE;
-       cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
-       cam->v4ldev->hardware = VID_HARDWARE_W9968CF;
        cam->v4ldev->fops = &w9968cf_fops;
        cam->v4ldev->minor = video_nr[dev_nr];
        cam->v4ldev->release = video_device_release;
        video_set_drvdata(cam->v4ldev, cam);
-       cam->v4ldev->dev = &cam->dev;
+       cam->v4ldev->parent = &cam->dev;
 
        err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
                                    video_nr[dev_nr]);