]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
fbdev: au1100fb: Don't store device specific data in global variables
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Sun, 15 Feb 2026 23:33:17 +0000 (00:33 +0100)
committerHelge Deller <deller@gmx.de>
Thu, 19 Feb 2026 16:38:16 +0000 (17:38 +0100)
Using global data to store device specific data is a bad pattern that
breaks if there is more than one device. So expand driver data and drop
the global variables.

While there is probably no machine that has two or more au1100fb
devices, this makes the driver a better template for new drivers and
saves some memory if there is no such bound device.

bloat-o-meter reports (for ARCH=arm allmodconfig + CONFIG_FB_AU1100=y
and ignoring the rename of the init function):

add/remove: 1/4 grow/shrink: 2/2 up/down: 1360/-4800 (-3440)
Function                                     old     new   delta
au1100fb_drv_probe                          2648    3328    +680
$a                                         12808   13484    +676
au1100fb_drv_resume                          404     400      -4
au1100fb_fix                                  68       -     -68
au1100fb_var                                 160       -    -160
fbregs                                      2048       -   -2048
$d                                          9525    7009   -2516
Total: Before=38664, After=35224, chg -8.90%

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/au1100fb.c
drivers/video/fbdev/au1100fb.h

index feaa1061c4364d28e60e0a973abbc1346596238e..7bc224a8455caa96a4caf01fcf26d832f0566480 100644 (file)
@@ -84,21 +84,6 @@ struct fb_bitfield rgb_bitfields[][4] =
        { { 8, 4, 0 },  { 4, 4, 0 }, { 0, 4, 0 }, { 0, 0, 0 } },
 };
 
-static struct fb_fix_screeninfo au1100fb_fix = {
-       .id             = "AU1100 FB",
-       .xpanstep       = 1,
-       .ypanstep       = 1,
-       .type           = FB_TYPE_PACKED_PIXELS,
-       .accel          = FB_ACCEL_NONE,
-};
-
-static struct fb_var_screeninfo au1100fb_var = {
-       .activate       = FB_ACTIVATE_NOW,
-       .height         = -1,
-       .width          = -1,
-       .vmode          = FB_VMODE_NONINTERLACED,
-};
-
 /* fb_blank
  * Blank the screen. Depending on the mode, the screen will be
  * activated with the backlight color, or desactivated
@@ -432,19 +417,26 @@ static int au1100fb_drv_probe(struct platform_device *dev)
                return -EFAULT;
        }
 
-       au1100fb_fix.mmio_start = regs_res->start;
-       au1100fb_fix.mmio_len = resource_size(regs_res);
+       fbdev->info.fix = (struct fb_fix_screeninfo) {
+               .mmio_start = regs_res->start,
+               .mmio_len = resource_size(regs_res),
+               .id = "AU1100 FB",
+               .xpanstep = 1,
+               .ypanstep = 1,
+               .type = FB_TYPE_PACKED_PIXELS,
+               .accel = FB_ACCEL_NONE,
+       };
 
        if (!devm_request_mem_region(&dev->dev,
-                                    au1100fb_fix.mmio_start,
-                                    au1100fb_fix.mmio_len,
+                                    fbdev->info.fix.mmio_start,
+                                    fbdev->info.fix.mmio_len,
                                     DRIVER_NAME)) {
                print_err("fail to lock memory region at 0x%08lx",
-                               au1100fb_fix.mmio_start);
+                         fbdev->info.fix.mmio_start);
                return -EBUSY;
        }
 
-       fbdev->regs = (struct au1100fb_regs*)KSEG1ADDR(au1100fb_fix.mmio_start);
+       fbdev->regs = (struct au1100fb_regs*)KSEG1ADDR(fbdev->info.fix.mmio_start);
 
        print_dbg("Register memory map at %p", fbdev->regs);
        print_dbg("phys=0x%08x, size=%d", fbdev->regs_phys, fbdev->regs_len);
@@ -469,22 +461,27 @@ static int au1100fb_drv_probe(struct platform_device *dev)
                return -ENOMEM;
        }
 
-       au1100fb_fix.smem_start = fbdev->fb_phys;
-       au1100fb_fix.smem_len = fbdev->fb_len;
+       fbdev->info.fix.smem_start = fbdev->fb_phys;
+       fbdev->info.fix.smem_len = fbdev->fb_len;
 
        print_dbg("Framebuffer memory map at %p", fbdev->fb_mem);
        print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024);
 
        /* load the panel info into the var struct */
-       au1100fb_var.bits_per_pixel = fbdev->panel->bpp;
-       au1100fb_var.xres = fbdev->panel->xres;
-       au1100fb_var.xres_virtual = au1100fb_var.xres;
-       au1100fb_var.yres = fbdev->panel->yres;
-       au1100fb_var.yres_virtual = au1100fb_var.yres;
+       fbdev->info.var = (struct fb_var_screeninfo) {
+               .activate = FB_ACTIVATE_NOW,
+               .height = -1,
+               .width = -1,
+               .vmode = FB_VMODE_NONINTERLACED,
+               .bits_per_pixel = fbdev->panel->bpp,
+               .xres = fbdev->panel->xres,
+               .xres_virtual = fbdev->panel->xres,
+               .yres = fbdev->panel->yres,
+               .yres_virtual = fbdev->panel->yres,
+       };
 
        fbdev->info.screen_base = fbdev->fb_mem;
        fbdev->info.fbops = &au1100fb_ops;
-       fbdev->info.fix = au1100fb_fix;
 
        fbdev->info.pseudo_palette =
                devm_kcalloc(&dev->dev, 16, sizeof(u32), GFP_KERNEL);
@@ -497,8 +494,6 @@ static int au1100fb_drv_probe(struct platform_device *dev)
                return -EFAULT;
        }
 
-       fbdev->info.var = au1100fb_var;
-
        /* Set h/w registers */
        au1100fb_setmode(fbdev);
 
@@ -545,9 +540,7 @@ void au1100fb_drv_remove(struct platform_device *dev)
 }
 
 #ifdef CONFIG_PM
-static struct au1100fb_regs fbregs;
-
-int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state)
+static int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state)
 {
        struct au1100fb_device *fbdev = platform_get_drvdata(dev);
 
@@ -559,7 +552,7 @@ int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state)
 
        clk_disable(fbdev->lcdclk);
 
-       memcpy(&fbregs, fbdev->regs, sizeof(struct au1100fb_regs));
+       memcpy(&fbdev->pm_regs, fbdev->regs, sizeof(struct au1100fb_regs));
 
        return 0;
 }
@@ -572,7 +565,7 @@ int au1100fb_drv_resume(struct platform_device *dev)
        if (!fbdev)
                return 0;
 
-       memcpy(fbdev->regs, &fbregs, sizeof(struct au1100fb_regs));
+       memcpy(fbdev->regs, &fbdev->pm_regs, sizeof(struct au1100fb_regs));
 
        ret = clk_enable(fbdev->lcdclk);
        if (ret)
index 79f4048726f1af0f2deb114e7d13a4cbd9ad21dd..b7bf6e0055726a0a7316df8056c0becb54a73fcd 100644 (file)
@@ -105,6 +105,11 @@ struct au1100fb_device {
        size_t                  regs_len;
        unsigned int            regs_phys;
 
+#ifdef CONFIG_PM
+       /* stores the register values during suspend */
+       struct au1100fb_regs    pm_regs;
+#endif
+
        unsigned char*          fb_mem;         /* FrameBuffer memory map */
        size_t                  fb_len;
        dma_addr_t              fb_phys;