Pull bugzilla-7897 into release branch
[sfrench/cifs-2.6.git] / drivers / media / video / vivi.c
index 9986de5cb3d6d46860ee9ad6e12fdf6e498683fe..cfb6b1f0402c0e24885f37b9ad9adcd5a22e0bd3 100644 (file)
@@ -270,10 +270,15 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
        char *p,*s,*basep;
        struct page *pg;
        u8   chr,r,g,b,color;
+       unsigned long flags;
+       spinlock_t spinlock;
+
+       spin_lock_init(&spinlock);
 
        /* Get first addr pointed to pixel position */
        oldpg=get_addr_pos(pos,pages,to_addr);
        pg=pfn_to_page(sg_dma_address(to_addr[oldpg].sg) >> PAGE_SHIFT);
+       spin_lock_irqsave(&spinlock,flags);
        basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
 
        /* We will just duplicate the second pixel at the packet */
@@ -376,6 +381,8 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
 
 end:
        kunmap_atomic(basep, KM_BOUNCE_READ);
+       spin_unlock_irqrestore(&spinlock,flags);
+
 }
 static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
 {
@@ -535,9 +542,9 @@ static int vivi_start_thread(struct vivi_dmaqueue  *dma_q)
 
        dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi");
 
-       if (dma_q->kthread == NULL) {
+       if (IS_ERR(dma_q->kthread)) {
                printk(KERN_ERR "vivi: kernel_thread() failed\n");
-               return -EINVAL;
+               return PTR_ERR(dma_q->kthread);
        }
        dprintk(1,"returning from %s\n",__FUNCTION__);
        return 0;
@@ -1044,16 +1051,8 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
        return (0);
 }
 
-static struct v4l2_tvnorm tvnorms[] = {
-       {
-               .name      = "NTSC-M",
-               .id        = V4L2_STD_NTSC_M,
-       }
-};
-
-static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id a)
+static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *i)
 {
-
        return 0;
 }
 
@@ -1293,7 +1292,7 @@ vivi_mmap(struct file *file, struct vm_area_struct * vma)
        return ret;
 }
 
-static struct file_operations vivi_fops = {
+static const struct file_operations vivi_fops = {
        .owner          = THIS_MODULE,
        .open           = vivi_open,
        .release        = vivi_release,
@@ -1333,8 +1332,8 @@ static struct video_device vivi = {
 #ifdef CONFIG_VIDEO_V4L1_COMPAT
        .vidiocgmbuf          = vidiocgmbuf,
 #endif
-       .tvnorms              = tvnorms,
-       .tvnormsize           = ARRAY_SIZE(tvnorms),
+       .tvnorms              = V4L2_STD_NTSC_M,
+       .current_norm         = V4L2_STD_NTSC_M,
 };
 /* -----------------------------------------------------------------
        Initialization and module stuff
@@ -1361,8 +1360,6 @@ static int __init vivi_init(void)
        dev->vidq.timeout.data     = (unsigned long)dev;
        init_timer(&dev->vidq.timeout);
 
-       vivi.current_norm         = tvnorms[0].id;
-
        ret = video_register_device(&vivi, VFL_TYPE_GRABBER, video_nr);
        printk(KERN_INFO "Video Technology Magazine Virtual Video Capture Board (Load status: %d)\n", ret);
        return ret;
@@ -1373,7 +1370,9 @@ static void __exit vivi_exit(void)
        struct vivi_dev *h;
        struct list_head *list;
 
-       list_for_each(list,&vivi_devlist) {
+       while (!list_empty(&vivi_devlist)) {
+               list = vivi_devlist.next;
+               list_del(list);
                h = list_entry(list, struct vivi_dev, vivi_devlist);
                kfree (h);
        }