V4L/DVB (6115): ivtv/ivtv-fb: improve locking to avoid initialization problems
authorHans Verkuil <hverkuil@xs4all.nl>
Sat, 25 Aug 2007 08:41:52 +0000 (05:41 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 10 Oct 2007 01:07:13 +0000 (22:07 -0300)
ivtv/ivtv-fb: improve locking to prevent ivtv/ivtv-fb initialization problems

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/ivtv/ivtv-driver.c
drivers/media/video/ivtv/ivtv-fb.c

index 855697c1c9681bcca51c73fc080c502e1ecda539..2a5e0facca7df8d912b1542c597b072a05f27c50 100644 (file)
@@ -1003,6 +1003,8 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
 
        IVTV_DEBUG_INFO("base addr: 0x%08x\n", itv->base_addr);
 
+       mutex_lock(&itv->serialize_lock);
+
        /* PCI Device Setup */
        if ((retval = ivtv_setup_pci(itv, dev, pci_id)) != 0) {
                if (retval == -EIO)
@@ -1174,6 +1176,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
                IVTV_ERR("Failed to register irq %d\n", retval);
                goto free_streams;
        }
+       mutex_unlock(&itv->serialize_lock);
        IVTV_INFO("Initialized card #%d: %s\n", itv->num, itv->card_name);
        return 0;
 
@@ -1192,6 +1195,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
                release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE);
       free_workqueue:
        destroy_workqueue(itv->irq_work_queues);
+       mutex_unlock(&itv->serialize_lock);
       err:
        if (retval == 0)
                retval = -ENODEV;
index e80564aed6326ee564bd2f9df52f5f1679fa2ece..ffe6478682aef29696c0f9db0b49c1c6e6445cfb 100644 (file)
@@ -1011,10 +1011,13 @@ static int ivtvfb_init_io(struct ivtv *itv)
 {
        struct osd_info *oi = itv->osd_info;
 
+       mutex_lock(&itv->serialize_lock);
        if (ivtv_init_on_first_open(itv)) {
+               mutex_unlock(&itv->serialize_lock);
                IVTV_FB_ERR("Failed to initialize ivtv\n");
                return -ENXIO;
        }
+       mutex_unlock(&itv->serialize_lock);
 
        ivtv_fb_get_framebuffer(itv, &oi->video_rbase, &oi->video_buffer_size);