linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / media / video / zoran_card.c
index 227ba2f..246e67c 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/spinlock.h>
 #include <linux/sem.h>
 #include <linux/kmod.h>
+#include <linux/wait.h>
 
 #include <linux/pci.h>
 #include <linux/interrupt.h>
@@ -736,7 +737,7 @@ static struct i2c_algo_bit_data zoran_i2c_bit_data_template = {
 };
 
 static struct i2c_adapter zoran_i2c_adapter_template = {
-       I2C_DEVNAME("zr36057"),
+       .name = "zr36057",
        .id = I2C_HW_B_ZR36067,
        .algo = NULL,
        .client_register = zoran_i2c_client_register,
@@ -968,6 +969,7 @@ zoran_open_init_params (struct zoran *zr)
 static void __devinit
 test_interrupts (struct zoran *zr)
 {
+       DEFINE_WAIT(wait);
        int timeout, icr;
 
        clear_interrupt_counters(zr);
@@ -975,7 +977,9 @@ test_interrupts (struct zoran *zr)
        zr->testing = 1;
        icr = btread(ZR36057_ICR);
        btwrite(0x78000000 | ZR36057_ICR_IntPinEn, ZR36057_ICR);
-       timeout = interruptible_sleep_on_timeout(&zr->test_q, 1 * HZ);
+       prepare_to_wait(&zr->test_q, &wait, TASK_INTERRUPTIBLE);
+       timeout = schedule_timeout(HZ);
+       finish_wait(&zr->test_q, &wait);
        btwrite(0, ZR36057_ICR);
        btwrite(0x78000000, ZR36057_ISR);
        zr->testing = 0;
@@ -991,7 +995,7 @@ test_interrupts (struct zoran *zr)
 static int __devinit
 zr36057_init (struct zoran *zr)
 {
-       unsigned long mem;
+       u32 *mem;
        void *vdev;
        unsigned mem_needed;
        int j;
@@ -1046,21 +1050,18 @@ zr36057_init (struct zoran *zr)
        /* allocate memory *before* doing anything to the hardware
         * in case allocation fails */
        mem_needed = BUZ_NUM_STAT_COM * 4;
-       mem = (unsigned long) kmalloc(mem_needed, GFP_KERNEL);
+       mem = kzalloc(mem_needed, GFP_KERNEL);
        vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);
        if (!mem || !vdev) {
                dprintk(1,
                        KERN_ERR
                        "%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
                        ZR_DEVNAME(zr));
-               if (vdev)
-                       kfree(vdev);
-               if (mem)
-                       kfree((void *)mem);
+               kfree(vdev);
+               kfree(mem);
                return -ENOMEM;
        }
-       memset((void *) mem, 0, mem_needed);
-       zr->stat_com = (u32 *) mem;
+       zr->stat_com = mem;
        for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
                zr->stat_com[j] = 1;    /* mark as unavailable to zr36057 */
        }
@@ -1101,15 +1102,15 @@ zoran_release (struct zoran *zr)
        /* unregister videocodec bus */
        if (zr->codec) {
                struct videocodec_master *master = zr->codec->master_data;
+
                videocodec_detach(zr->codec);
-               if (master)
-                       kfree(master);
+               kfree(master);
        }
        if (zr->vfe) {
                struct videocodec_master *master = zr->vfe->master_data;
+
                videocodec_detach(zr->vfe);
-               if (master)
-                       kfree(master);
+               kfree(master);
        }
 
        /* unregister i2c bus */