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

[PATCH] fbdev: kyrofb: Driver cleanups

- remove unneeded casts

- use framebuffer_alloc/framebuffer_release to allocate/free memory

- the pseudo_palette is always u32 regardless of bpp if using generic
drawing functions

Signed-off-by: Antonino Daplas <adaplas@pol.net>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Antonino A. Daplas and committed by
Linus Torvalds
a26968df 94f9e09c

+15 -18
+14 -18
drivers/video/kyro/fbdev.c
··· 73 73 .vmode = FB_VMODE_NONINTERLACED, 74 74 }; 75 75 76 - static struct kyrofb_info *currentpar; 77 - 78 76 typedef struct { 79 77 STG4000REG __iomem *pSTGReg; /* Virtual address of PCI register region */ 80 78 u32 ulNextFreeVidMem; /* Offset from start of vid mem to next free region */ ··· 307 309 /* Accessors */ 308 310 static int kyro_dev_video_mode_set(struct fb_info *info) 309 311 { 310 - struct kyrofb_info *par = (struct kyrofb_info *)info->par; 312 + struct kyrofb_info *par = info->par; 311 313 312 314 /* Turn off display */ 313 315 StopVTG(deviceInfo.pSTGReg); ··· 400 402 401 403 static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 402 404 { 403 - struct kyrofb_info *par = (struct kyrofb_info *)info->par; 405 + struct kyrofb_info *par = info->par; 404 406 405 407 if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) { 406 408 printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel); ··· 476 478 477 479 static int kyrofb_set_par(struct fb_info *info) 478 480 { 479 - struct kyrofb_info *par = (struct kyrofb_info *)info->par; 481 + struct kyrofb_info *par = info->par; 480 482 unsigned long lineclock; 481 483 unsigned long frameclock; 482 484 ··· 534 536 static int kyrofb_setcolreg(u_int regno, u_int red, u_int green, 535 537 u_int blue, u_int transp, struct fb_info *info) 536 538 { 539 + struct kyrofb_info *par = info->par; 540 + 537 541 if (regno > 255) 538 542 return 1; /* Invalid register */ 539 543 540 544 if (regno < 16) { 541 545 switch (info->var.bits_per_pixel) { 542 546 case 16: 543 - ((u16*)(info->pseudo_palette))[regno] = 547 + par->palette[regno] = 544 548 (red & 0xf800) | 545 549 ((green & 0xfc00) >> 5) | 546 550 ((blue & 0xf800) >> 11); 547 551 break; 548 552 case 32: 549 553 red >>= 8; green >>= 8; blue >>= 8; transp >>= 8; 550 - ((u32*)(info->pseudo_palette))[regno] = 554 + par->palette[regno] = 551 555 (transp << 24) | (red << 16) | (green << 8) | blue; 552 556 break; 553 557 } ··· 675 675 const struct pci_device_id *ent) 676 676 { 677 677 struct fb_info *info; 678 + struct kyrofb_info *currentpar; 678 679 unsigned long size; 679 680 int err; 680 681 ··· 684 683 return err; 685 684 } 686 685 687 - size = sizeof(struct fb_info) + sizeof(struct kyrofb_info) + 16 * sizeof(u32); 688 - info = kmalloc(size, GFP_KERNEL); 686 + info = framebuffer_alloc(sizeof(struct kyrofb_info), &pdev->dev); 689 687 if (!info) 690 688 return -ENOMEM; 691 689 692 - memset(info, 0, size); 693 - 694 - currentpar = (struct kyrofb_info *)(info + 1); 690 + currentpar = info->par; 695 691 696 692 kyro_fix.smem_start = pci_resource_start(pdev, 0); 697 693 kyro_fix.smem_len = pci_resource_len(pdev, 0); ··· 714 716 715 717 info->fbops = &kyrofb_ops; 716 718 info->fix = kyro_fix; 717 - info->par = currentpar; 718 - info->pseudo_palette = (void *)(currentpar + 1); 719 + info->pseudo_palette = currentpar->palette; 719 720 info->flags = FBINFO_DEFAULT; 720 721 721 722 SetCoreClockPLL(deviceInfo.pSTGReg, pdev); ··· 738 741 739 742 fb_memset(info->screen_base, 0, size); 740 743 741 - info->device = &pdev->dev; 742 744 if (register_framebuffer(info) < 0) 743 745 goto out_unmap; 744 746 ··· 753 757 out_unmap: 754 758 iounmap(currentpar->regbase); 755 759 iounmap(info->screen_base); 756 - kfree(info); 760 + framebuffer_release(info); 757 761 758 762 return -EINVAL; 759 763 } ··· 761 765 static void __devexit kyrofb_remove(struct pci_dev *pdev) 762 766 { 763 767 struct fb_info *info = pci_get_drvdata(pdev); 764 - struct kyrofb_info *par = (struct kyrofb_info *)info->par; 768 + struct kyrofb_info *par = info->par; 765 769 766 770 /* Reset the board */ 767 771 StopVTG(deviceInfo.pSTGReg); ··· 785 789 786 790 unregister_framebuffer(info); 787 791 pci_set_drvdata(pdev, NULL); 788 - kfree(info); 792 + framebuffer_release(info); 789 793 } 790 794 791 795 static int __init kyrofb_init(void)
+1
include/video/kyro.h
··· 15 15 struct kyrofb_info { 16 16 void __iomem *regbase; 17 17 18 + u32 palette[16]; 18 19 u32 HTot; /* Hor Total Time */ 19 20 u32 HFP; /* Hor Front Porch */ 20 21 u32 HST; /* Hor Sync Time */