Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fbdev: au1100fb: Don't store device specific data in global variables

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>

authored by

Uwe Kleine-König and committed by
Helge Deller
7939cecd 26a4cfaf

+34 -36
+29 -36
drivers/video/fbdev/au1100fb.c
··· 84 84 { { 8, 4, 0 }, { 4, 4, 0 }, { 0, 4, 0 }, { 0, 0, 0 } }, 85 85 }; 86 86 87 - static struct fb_fix_screeninfo au1100fb_fix = { 88 - .id = "AU1100 FB", 89 - .xpanstep = 1, 90 - .ypanstep = 1, 91 - .type = FB_TYPE_PACKED_PIXELS, 92 - .accel = FB_ACCEL_NONE, 93 - }; 94 - 95 - static struct fb_var_screeninfo au1100fb_var = { 96 - .activate = FB_ACTIVATE_NOW, 97 - .height = -1, 98 - .width = -1, 99 - .vmode = FB_VMODE_NONINTERLACED, 100 - }; 101 - 102 87 /* fb_blank 103 88 * Blank the screen. Depending on the mode, the screen will be 104 89 * activated with the backlight color, or desactivated ··· 417 432 return -EFAULT; 418 433 } 419 434 420 - au1100fb_fix.mmio_start = regs_res->start; 421 - au1100fb_fix.mmio_len = resource_size(regs_res); 435 + fbdev->info.fix = (struct fb_fix_screeninfo) { 436 + .mmio_start = regs_res->start, 437 + .mmio_len = resource_size(regs_res), 438 + .id = "AU1100 FB", 439 + .xpanstep = 1, 440 + .ypanstep = 1, 441 + .type = FB_TYPE_PACKED_PIXELS, 442 + .accel = FB_ACCEL_NONE, 443 + }; 422 444 423 445 if (!devm_request_mem_region(&dev->dev, 424 - au1100fb_fix.mmio_start, 425 - au1100fb_fix.mmio_len, 446 + fbdev->info.fix.mmio_start, 447 + fbdev->info.fix.mmio_len, 426 448 DRIVER_NAME)) { 427 449 print_err("fail to lock memory region at 0x%08lx", 428 - au1100fb_fix.mmio_start); 450 + fbdev->info.fix.mmio_start); 429 451 return -EBUSY; 430 452 } 431 453 432 - fbdev->regs = (struct au1100fb_regs*)KSEG1ADDR(au1100fb_fix.mmio_start); 454 + fbdev->regs = (struct au1100fb_regs*)KSEG1ADDR(fbdev->info.fix.mmio_start); 433 455 434 456 print_dbg("Register memory map at %p", fbdev->regs); 435 457 print_dbg("phys=0x%08x, size=%d", fbdev->regs_phys, fbdev->regs_len); ··· 461 469 return -ENOMEM; 462 470 } 463 471 464 - au1100fb_fix.smem_start = fbdev->fb_phys; 465 - au1100fb_fix.smem_len = fbdev->fb_len; 472 + fbdev->info.fix.smem_start = fbdev->fb_phys; 473 + fbdev->info.fix.smem_len = fbdev->fb_len; 466 474 467 475 print_dbg("Framebuffer memory map at %p", fbdev->fb_mem); 468 476 print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024); 469 477 470 478 /* load the panel info into the var struct */ 471 - au1100fb_var.bits_per_pixel = fbdev->panel->bpp; 472 - au1100fb_var.xres = fbdev->panel->xres; 473 - au1100fb_var.xres_virtual = au1100fb_var.xres; 474 - au1100fb_var.yres = fbdev->panel->yres; 475 - au1100fb_var.yres_virtual = au1100fb_var.yres; 479 + fbdev->info.var = (struct fb_var_screeninfo) { 480 + .activate = FB_ACTIVATE_NOW, 481 + .height = -1, 482 + .width = -1, 483 + .vmode = FB_VMODE_NONINTERLACED, 484 + .bits_per_pixel = fbdev->panel->bpp, 485 + .xres = fbdev->panel->xres, 486 + .xres_virtual = fbdev->panel->xres, 487 + .yres = fbdev->panel->yres, 488 + .yres_virtual = fbdev->panel->yres, 489 + }; 476 490 477 491 fbdev->info.screen_base = fbdev->fb_mem; 478 492 fbdev->info.fbops = &au1100fb_ops; 479 - fbdev->info.fix = au1100fb_fix; 480 493 481 494 fbdev->info.pseudo_palette = 482 495 devm_kcalloc(&dev->dev, 16, sizeof(u32), GFP_KERNEL); ··· 493 496 AU1100_LCD_NBR_PALETTE_ENTRIES); 494 497 return -EFAULT; 495 498 } 496 - 497 - fbdev->info.var = au1100fb_var; 498 499 499 500 /* Set h/w registers */ 500 501 au1100fb_setmode(fbdev); ··· 540 545 } 541 546 542 547 #ifdef CONFIG_PM 543 - static struct au1100fb_regs fbregs; 544 - 545 - int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state) 548 + static int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state) 546 549 { 547 550 struct au1100fb_device *fbdev = platform_get_drvdata(dev); 548 551 ··· 552 559 553 560 clk_disable(fbdev->lcdclk); 554 561 555 - memcpy(&fbregs, fbdev->regs, sizeof(struct au1100fb_regs)); 562 + memcpy(&fbdev->pm_regs, fbdev->regs, sizeof(struct au1100fb_regs)); 556 563 557 564 return 0; 558 565 } ··· 565 572 if (!fbdev) 566 573 return 0; 567 574 568 - memcpy(fbdev->regs, &fbregs, sizeof(struct au1100fb_regs)); 575 + memcpy(fbdev->regs, &fbdev->pm_regs, sizeof(struct au1100fb_regs)); 569 576 570 577 ret = clk_enable(fbdev->lcdclk); 571 578 if (ret)
+5
drivers/video/fbdev/au1100fb.h
··· 105 105 size_t regs_len; 106 106 unsigned int regs_phys; 107 107 108 + #ifdef CONFIG_PM 109 + /* stores the register values during suspend */ 110 + struct au1100fb_regs pm_regs; 111 + #endif 112 + 108 113 unsigned char* fb_mem; /* FrameBuffer memory map */ 109 114 size_t fb_len; 110 115 dma_addr_t fb_phys;