]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/video/arkfb.c
drivers/video: release mutex in error handling code
[linux-2.6-omap-h63xx.git] / drivers / video / arkfb.c
index 0f6e0043069ddde658db1de9d7b500d1cea47507..38a1e8308c837d28d666e86a29b3097658020524 100644 (file)
@@ -943,7 +943,7 @@ static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_
        }
 
        /* Allocate and fill driver data structure */
-       info = framebuffer_alloc(sizeof(struct arkfb_info), NULL);
+       info = framebuffer_alloc(sizeof(struct arkfb_info), &(dev->dev));
        if (! info) {
                dev_err(&(dev->dev), "cannot allocate memory\n");
                return -ENOMEM;
@@ -958,20 +958,20 @@ static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_
        /* Prepare PCI device */
        rc = pci_enable_device(dev);
        if (rc < 0) {
-               dev_err(&(dev->dev), "cannot enable PCI device\n");
+               dev_err(info->dev, "cannot enable PCI device\n");
                goto err_enable_device;
        }
 
        rc = pci_request_regions(dev, "arkfb");
        if (rc < 0) {
-               dev_err(&(dev->dev), "cannot reserve framebuffer region\n");
+               dev_err(info->dev, "cannot reserve framebuffer region\n");
                goto err_request_regions;
        }
 
        par->dac = ics5342_init(ark_dac_read_regs, ark_dac_write_regs, info);
        if (! par->dac) {
                rc = -ENOMEM;
-               dev_err(&(dev->dev), "RAMDAC initialization failed\n");
+               dev_err(info->dev, "RAMDAC initialization failed\n");
                goto err_dac;
        }
 
@@ -982,7 +982,7 @@ static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_
        info->screen_base = pci_iomap(dev, 0, 0);
        if (! info->screen_base) {
                rc = -ENOMEM;
-               dev_err(&(dev->dev), "iomap for framebuffer failed\n");
+               dev_err(info->dev, "iomap for framebuffer failed\n");
                goto err_iomap;
        }
 
@@ -1004,19 +1004,19 @@ static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_
        rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8);
        if (! ((rc == 1) || (rc == 2))) {
                rc = -EINVAL;
-               dev_err(&(dev->dev), "mode %s not found\n", mode_option);
+               dev_err(info->dev, "mode %s not found\n", mode_option);
                goto err_find_mode;
        }
 
        rc = fb_alloc_cmap(&info->cmap, 256, 0);
        if (rc < 0) {
-               dev_err(&(dev->dev), "cannot allocate colormap\n");
+               dev_err(info->dev, "cannot allocate colormap\n");
                goto err_alloc_cmap;
        }
 
        rc = register_framebuffer(info);
        if (rc < 0) {
-               dev_err(&(dev->dev), "cannot register framebugger\n");
+               dev_err(info->dev, "cannot register framebugger\n");
                goto err_reg_fb;
        }
 
@@ -1090,7 +1090,7 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
        struct fb_info *info = pci_get_drvdata(dev);
        struct arkfb_info *par = info->par;
 
-       dev_info(&(dev->dev), "suspend\n");
+       dev_info(info->dev, "suspend\n");
 
        acquire_console_sem();
        mutex_lock(&(par->open_lock));
@@ -1121,16 +1121,13 @@ static int ark_pci_resume (struct pci_dev* dev)
        struct fb_info *info = pci_get_drvdata(dev);
        struct arkfb_info *par = info->par;
 
-       dev_info(&(dev->dev), "resume\n");
+       dev_info(info->dev, "resume\n");
 
        acquire_console_sem();
        mutex_lock(&(par->open_lock));
 
-       if (par->ref_count == 0) {
-               mutex_unlock(&(par->open_lock));
-               release_console_sem();
-               return 0;
-       }
+       if (par->ref_count == 0)
+               goto fail;
 
        pci_set_power_state(dev, PCI_D0);
        pci_restore_state(dev);
@@ -1143,8 +1140,8 @@ static int ark_pci_resume (struct pci_dev* dev)
        arkfb_set_par(info);
        fb_set_suspend(info, 0);
 
-       mutex_unlock(&(par->open_lock));
 fail:
+       mutex_unlock(&(par->open_lock));
        release_console_sem();
        return 0;
 }