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 <[email protected]>
---
I think this doesn't need a Fixes line, but if you want, it would be:
Fixes: 3b495f2bb749 ("Au1100 FB driver uplift for 2.6.")
Fixes: f77f50ca1a23 ("[PATCH] au1100fb: add power management support")
---
drivers/video/fbdev/au1100fb.c | 63 ++++++++++++++++------------------
drivers/video/fbdev/au1100fb.h | 5 +++
2 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c
index feaa1061c436..75344ee080f3 100644
--- a/drivers/video/fbdev/au1100fb.c
+++ b/drivers/video/fbdev/au1100fb.c
@@ -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);
@@ -547,7 +542,7 @@ void au1100fb_drv_remove(struct platform_device *dev)
#ifdef CONFIG_PM
static struct au1100fb_regs fbregs;