This commit was generated by cvs2svn to compensate for changes in r1129,
[linux-2.6.git] / drivers / media / video / zr36120.c
index 9780261..d4c633b 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/mm.h>
 #include <linux/pci.h>
 #include <linux/signal.h>
+#include <linux/wait.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
 #include <asm/page.h>
@@ -338,7 +339,7 @@ void zoran_irq(int irq, void *dev_id, struct pt_regs * regs)
 {
        u32 stat,estat;
        int count = 0;
-       struct zoran *ztv = (struct zoran *)dev_id;
+       struct zoran *ztv = dev_id;
 
        UNUSED(irq); UNUSED(regs);
        for (;;) {
@@ -775,7 +776,7 @@ static int zoran_open(struct video_device *dev, int flags)
        memset(ztv->fbuffer,0,ZORAN_MAX_FBUFSIZE);
 
        if (!ztv->overinfo.overlay)
-               ztv->overinfo.overlay = (void*)kmalloc(1024*1024/8, GFP_KERNEL);
+               ztv->overinfo.overlay = kmalloc(1024*1024/8, GFP_KERNEL);
        if (!ztv->overinfo.overlay) {
                /* could not get an overlay buffer, bail out */
                bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE);
@@ -819,11 +820,9 @@ void zoran_close(struct video_device* dev)
         msleep(100);                   /* Wait 1/10th of a second */
 
        /* free the allocated framebuffer */
-       if (ztv->fbuffer)
-               bfree( ztv->fbuffer, ZORAN_MAX_FBUFSIZE );
+       bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE);
        ztv->fbuffer = 0;
-       if (ztv->overinfo.overlay)
-               kfree( ztv->overinfo.overlay );
+       kfree(ztv->overinfo.overlay);
        ztv->overinfo.overlay = 0;
 
 }
@@ -899,12 +898,11 @@ long zoran_read(struct video_device* dev, char* buf, unsigned long count, int no
                zoran_cap(ztv, 1);
 
                /* wait till this buffer gets grabbed */
-               while (unused->status == FBUFFER_BUSY) {
-                       interruptible_sleep_on(&ztv->grabq);
-                       /* see if a signal did it */
-                       if (signal_pending(current))
-                               return -EINTR;
-               }
+               wait_event_interruptible(ztv->grabq,
+                               (unused->status != FBUFFER_BUSY));
+               /* see if a signal did it */
+               if (signal_pending(current))
+                       return -EINTR;
                done = unused;
        }
        else
@@ -1326,12 +1324,11 @@ int zoran_ioctl(struct video_device* dev, unsigned int cmd, void *arg)
                        return -EINVAL;
                 case FBUFFER_BUSY:
                        /* wait till this buffer gets grabbed */
-                       while (ztv->grabinfo[i].status == FBUFFER_BUSY) {
-                               interruptible_sleep_on(&ztv->grabq);
-                               /* see if a signal did it */
-                               if (signal_pending(current))
-                                       return -EINTR;
-                       }
+                       wait_event_interruptible(ztv->grabq,
+                                       (ztv->grabinfo[i].status != FBUFFER_BUSY));
+                       /* see if a signal did it */
+                       if (signal_pending(current))
+                               return -EINTR;
                        /* don't fall through; a DONE buffer is not UNUSED */
                        break;
                 case FBUFFER_DONE:
@@ -1493,6 +1490,7 @@ static struct video_device zr36120_template=
        .write          = zoran_write,
        .poll           = zoran_poll,
        .ioctl          = zoran_ioctl,
+       .compat_ioctl   = v4l_compat_ioctl32,
        .mmap           = zoran_mmap,
        .minor          = -1,
 };
@@ -1500,7 +1498,7 @@ static struct video_device zr36120_template=
 static
 int vbi_open(struct video_device *dev, int flags)
 {
-       struct zoran *ztv = (struct zoran*)dev->priv;
+       struct zoran *ztv = dev->priv;
        struct vidinfo* item;
 
        DEBUG(printk(CARD_DEBUG "vbi_open(dev,%d)\n",CARD,flags));
@@ -1549,7 +1547,7 @@ int vbi_open(struct video_device *dev, int flags)
 static
 void vbi_close(struct video_device *dev)
 {
-       struct zoran *ztv = (struct zoran*)dev->priv;
+       struct zoran *ztv = dev->priv;
        struct vidinfo* item;
 
        DEBUG(printk(CARD_DEBUG "vbi_close(dev)\n",CARD));
@@ -1585,7 +1583,7 @@ void vbi_close(struct video_device *dev)
 static
 long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonblock)
 {
-       struct zoran *ztv = (struct zoran*)dev->priv;
+       struct zoran *ztv = dev->priv;
        unsigned long max;
        struct vidinfo* unused = 0;
        struct vidinfo* done = 0;
@@ -1640,12 +1638,11 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
                zoran_cap(ztv, 1);
 
                /* wait till this buffer gets grabbed */
-               while (unused->status == FBUFFER_BUSY) {
-                       interruptible_sleep_on(&ztv->vbiq);
-                       /* see if a signal did it */
-                       if (signal_pending(current))
-                               return -EINTR;
-               }
+               wait_event_interruptible(ztv->vbiq,
+                               (unused->status != FBUFFER_BUSY));
+               /* see if a signal did it */
+               if (signal_pending(current))
+                       return -EINTR;
                done = unused;
        }
        else
@@ -1740,7 +1737,7 @@ out:
 static
 unsigned int vbi_poll(struct video_device *dev, struct file *file, poll_table *wait)
 {
-       struct zoran *ztv = (struct zoran*)dev->priv;
+       struct zoran *ztv = dev->priv;
        struct vidinfo* item;
        unsigned int mask = 0;
 
@@ -1761,7 +1758,7 @@ unsigned int vbi_poll(struct video_device *dev, struct file *file, poll_table *w
 static
 int vbi_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
 {
-       struct zoran* ztv = (struct zoran*)dev->priv;
+       struct zoran* ztv = dev->priv;
 
        switch (cmd) {
         case VIDIOCGVBIFMT:
@@ -1861,7 +1858,7 @@ int __init find_zoran(void)
                DEBUG(printk(KERN_DEBUG "zoran: mapped-memory at 0x%p\n",ztv->zoran_mem));
 
                result = request_irq(dev->irq, zoran_irq,
-                       SA_SHIRQ|SA_INTERRUPT,"zoran",(void *)ztv);
+                       SA_SHIRQ|SA_INTERRUPT,"zoran", ztv);
                if (result==-EINVAL)
                {
                        iounmap(ztv->zoran_mem);
@@ -1950,7 +1947,7 @@ int __init init_zoran(int card)
        ztv->tuner_type = 0;
        ztv->running = 0;
        ztv->users = 0;
-       ztv->lock = RW_LOCK_UNLOCKED;
+       rwlock_init(&ztv->lock);
        ztv->workqueue = 0;
        ztv->fieldnr = 0;
        ztv->lastfieldnr = 0;