]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/video/fbdev/au1200fb.c
Merge tag 'wireless-drivers-for-davem-2017-11-22' of git://git.kernel.org/pub/scm...
[mirror_ubuntu-bionic-kernel.git] / drivers / video / fbdev / au1200fb.c
index 5f04b4096c428883be0b4032fb9b055916cda5f5..87d5a62bf6ca446fb8141b602c38839363dc120e 100644 (file)
@@ -1518,7 +1518,7 @@ static irqreturn_t au1200fb_handle_irq(int irq, void* dev_id)
 static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev)
 {
        struct fb_info *fbi = fbdev->fb_info;
-       int bpp;
+       int bpp, ret;
 
        fbi->fbops = &au1200fb_fb_ops;
 
@@ -1546,15 +1546,14 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev)
        }
 
        fbi->pseudo_palette = kcalloc(16, sizeof(u32), GFP_KERNEL);
-       if (!fbi->pseudo_palette) {
+       if (!fbi->pseudo_palette)
                return -ENOMEM;
-       }
 
-       if (fb_alloc_cmap(&fbi->cmap, AU1200_LCD_NBR_PALETTE_ENTRIES, 0) < 0) {
+       ret = fb_alloc_cmap(&fbi->cmap, AU1200_LCD_NBR_PALETTE_ENTRIES, 0);
+       if (ret < 0) {
                print_err("Fail to allocate colormap (%d entries)",
-                          AU1200_LCD_NBR_PALETTE_ENTRIES);
-               kfree(fbi->pseudo_palette);
-               return -EFAULT;
+                         AU1200_LCD_NBR_PALETTE_ENTRIES);
+               return ret;
        }
 
        strncpy(fbi->fix.id, "AU1200", sizeof(fbi->fix.id));
@@ -1668,10 +1667,6 @@ static int au1200fb_drv_probe(struct platform_device *dev)
        printk(DRIVER_NAME ": Panel %d %s\n", panel_index, panel->name);
        printk(DRIVER_NAME ": Win %d %s\n", window_index, win->name);
 
-       /* shut gcc up */
-       ret = 0;
-       fbdev = NULL;
-
        for (plane = 0; plane < device_count; ++plane) {
                bpp = winbpp(win->w[plane].mode_winctrl1);
                if (win->w[plane].xres == 0)
@@ -1681,8 +1676,10 @@ static int au1200fb_drv_probe(struct platform_device *dev)
 
                fbi = framebuffer_alloc(sizeof(struct au1200fb_device),
                                        &dev->dev);
-               if (!fbi)
+               if (!fbi) {
+                       ret = -ENOMEM;
                        goto failed;
+               }
 
                _au1200fb_infos[plane] = fbi;
                fbdev = fbi->par;
@@ -1701,7 +1698,8 @@ static int au1200fb_drv_probe(struct platform_device *dev)
                if (!fbdev->fb_mem) {
                        print_err("fail to allocate frambuffer (size: %dK))",
                                  fbdev->fb_len / 1024);
-                       return -ENOMEM;
+                       ret = -ENOMEM;
+                       goto failed;
                }
 
                /*
@@ -1718,7 +1716,8 @@ static int au1200fb_drv_probe(struct platform_device *dev)
                print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024);
 
                /* Init FB data */
-               if ((ret = au1200fb_init_fbinfo(fbdev)) < 0)
+               ret = au1200fb_init_fbinfo(fbdev);
+               if (ret < 0)
                        goto failed;
 
                /* Register new framebuffer */
@@ -1758,21 +1757,26 @@ static int au1200fb_drv_probe(struct platform_device *dev)
        return 0;
 
 failed:
-       /* NOTE: This only does the current plane/window that failed; others are still active */
-       if (fbi) {
+       for (plane = 0; plane < device_count; ++plane) {
+               fbi = _au1200fb_infos[plane];
+               if (!fbi)
+                       break;
+
+               /* Clean up all probe data */
+               unregister_framebuffer(fbi);
                if (fbi->cmap.len != 0)
                        fb_dealloc_cmap(&fbi->cmap);
                kfree(fbi->pseudo_palette);
+
+               framebuffer_release(fbi);
+               _au1200fb_infos[plane] = NULL;
        }
-       if (plane == 0)
-               free_irq(AU1200_LCD_INT, (void*)dev);
        return ret;
 }
 
 static int au1200fb_drv_remove(struct platform_device *dev)
 {
        struct au1200fb_platdata *pd = platform_get_drvdata(dev);
-       struct au1200fb_device *fbdev;
        struct fb_info *fbi;
        int plane;
 
@@ -1781,7 +1785,6 @@ static int au1200fb_drv_remove(struct platform_device *dev)
 
        for (plane = 0; plane < device_count; ++plane)  {
                fbi = _au1200fb_infos[plane];
-               fbdev = fbi->par;
 
                /* Clean up all probe data */
                unregister_framebuffer(fbi);