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

fbdev: mxsfb: use framebuffer_alloc in the correct way

framebuffer_alloc allocated the fb_info struct plus the extra
par and set fb_info->par pointer equal to this extra par. We
can refer the mxcfb_info from fb_info->par

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Tested-by: Stefan Agner <stefan@agner.ch>
Cc: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

authored by

Michael Trimarchi and committed by
Bartlomiej Zolnierkiewicz
91ae3396 7ea46206

+21 -24
+21 -24
drivers/video/fbdev/mxsfb.c
··· 169 169 }; 170 170 171 171 struct mxsfb_info { 172 - struct fb_info fb_info; 173 172 struct platform_device *pdev; 174 173 struct clk *clk; 175 174 struct clk *clk_axi; ··· 206 207 .ipversion = 4, 207 208 }, 208 209 }; 209 - 210 - #define to_imxfb_host(x) (container_of(x, struct mxsfb_info, fb_info)) 211 210 212 211 /* mask and shift depends on architecture */ 213 212 static inline u32 set_hsync_pulse_width(struct mxsfb_info *host, unsigned val) ··· 266 269 static int mxsfb_check_var(struct fb_var_screeninfo *var, 267 270 struct fb_info *fb_info) 268 271 { 269 - struct mxsfb_info *host = to_imxfb_host(fb_info); 272 + struct mxsfb_info *host = fb_info->par; 270 273 const struct fb_bitfield *rgb = NULL; 271 274 272 275 if (var->xres < MIN_XRES) ··· 327 330 328 331 static void mxsfb_enable_controller(struct fb_info *fb_info) 329 332 { 330 - struct mxsfb_info *host = to_imxfb_host(fb_info); 333 + struct mxsfb_info *host = fb_info->par; 331 334 u32 reg; 332 335 int ret; 333 336 ··· 364 367 365 368 static void mxsfb_disable_controller(struct fb_info *fb_info) 366 369 { 367 - struct mxsfb_info *host = to_imxfb_host(fb_info); 370 + struct mxsfb_info *host = fb_info->par; 368 371 unsigned loop; 369 372 u32 reg; 370 373 int ret; ··· 406 409 407 410 static int mxsfb_set_par(struct fb_info *fb_info) 408 411 { 409 - struct mxsfb_info *host = to_imxfb_host(fb_info); 412 + struct mxsfb_info *host = fb_info->par; 410 413 u32 ctrl, vdctrl0, vdctrl4; 411 414 int line_size, fb_size; 412 415 int reenable = 0; ··· 566 569 567 570 static int mxsfb_blank(int blank, struct fb_info *fb_info) 568 571 { 569 - struct mxsfb_info *host = to_imxfb_host(fb_info); 572 + struct mxsfb_info *host = fb_info->par; 570 573 571 574 switch (blank) { 572 575 case FB_BLANK_POWERDOWN: ··· 588 591 static int mxsfb_pan_display(struct fb_var_screeninfo *var, 589 592 struct fb_info *fb_info) 590 593 { 591 - struct mxsfb_info *host = to_imxfb_host(fb_info); 594 + struct mxsfb_info *host = fb_info->par; 592 595 unsigned offset; 593 596 594 597 if (var->xoffset != 0) ··· 619 622 .fb_imageblit = cfb_imageblit, 620 623 }; 621 624 622 - static int mxsfb_restore_mode(struct mxsfb_info *host, 625 + static int mxsfb_restore_mode(struct fb_info *fb_info, 623 626 struct fb_videomode *vmode) 624 627 { 625 - struct fb_info *fb_info = &host->fb_info; 628 + struct mxsfb_info *host = fb_info->par; 626 629 unsigned line_count; 627 630 unsigned period; 628 631 unsigned long pa, fbsize; ··· 723 726 return ret; 724 727 } 725 728 726 - static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host, 729 + static int mxsfb_init_fbinfo_dt(struct fb_info *fb_info, 727 730 struct fb_videomode *vmode) 728 731 { 729 - struct fb_info *fb_info = &host->fb_info; 732 + struct mxsfb_info *host = fb_info->par; 730 733 struct fb_var_screeninfo *var = &fb_info->var; 731 734 struct device *dev = &host->pdev->dev; 732 735 struct device_node *np = host->pdev->dev.of_node; ··· 802 805 return ret; 803 806 } 804 807 805 - static int mxsfb_init_fbinfo(struct mxsfb_info *host, 808 + static int mxsfb_init_fbinfo(struct fb_info *fb_info, 806 809 struct fb_videomode *vmode) 807 810 { 808 811 int ret; 812 + struct mxsfb_info *host = fb_info->par; 809 813 struct device *dev = &host->pdev->dev; 810 - struct fb_info *fb_info = &host->fb_info; 811 814 struct fb_var_screeninfo *var = &fb_info->var; 812 815 dma_addr_t fb_phys; 813 816 void *fb_virt; ··· 821 824 fb_info->fix.visual = FB_VISUAL_TRUECOLOR, 822 825 fb_info->fix.accel = FB_ACCEL_NONE; 823 826 824 - ret = mxsfb_init_fbinfo_dt(host, vmode); 827 + ret = mxsfb_init_fbinfo_dt(fb_info, vmode); 825 828 if (ret) 826 829 return ret; 827 830 ··· 840 843 fb_info->screen_base = fb_virt; 841 844 fb_info->screen_size = fb_info->fix.smem_len = fb_size; 842 845 843 - if (mxsfb_restore_mode(host, vmode)) 846 + if (mxsfb_restore_mode(fb_info, vmode)) 844 847 memset(fb_virt, 0, fb_size); 845 848 846 849 return 0; 847 850 } 848 851 849 - static void mxsfb_free_videomem(struct mxsfb_info *host) 852 + static void mxsfb_free_videomem(struct fb_info *fb_info) 850 853 { 854 + struct mxsfb_info *host = fb_info->par; 851 855 struct device *dev = &host->pdev->dev; 852 - struct fb_info *fb_info = &host->fb_info; 853 856 854 857 dma_free_wc(dev, fb_info->screen_size, fb_info->screen_base, 855 858 fb_info->fix.smem_start); ··· 899 902 if (mode == NULL) 900 903 return -ENOMEM; 901 904 902 - host = to_imxfb_host(fb_info); 905 + host = fb_info->par; 903 906 904 907 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 905 908 host->base = devm_ioremap_resource(&pdev->dev, res); ··· 938 941 goto fb_release; 939 942 } 940 943 941 - ret = mxsfb_init_fbinfo(host, mode); 944 + ret = mxsfb_init_fbinfo(fb_info, mode); 942 945 if (ret != 0) 943 946 goto fb_release; 944 947 ··· 979 982 static int mxsfb_remove(struct platform_device *pdev) 980 983 { 981 984 struct fb_info *fb_info = platform_get_drvdata(pdev); 982 - struct mxsfb_info *host = to_imxfb_host(fb_info); 985 + struct mxsfb_info *host = fb_info->par; 983 986 984 987 if (host->enabled) 985 988 mxsfb_disable_controller(fb_info); 986 989 987 990 unregister_framebuffer(fb_info); 988 - mxsfb_free_videomem(host); 991 + mxsfb_free_videomem(fb_info); 989 992 990 993 framebuffer_release(fb_info); 991 994 ··· 995 998 static void mxsfb_shutdown(struct platform_device *pdev) 996 999 { 997 1000 struct fb_info *fb_info = platform_get_drvdata(pdev); 998 - struct mxsfb_info *host = to_imxfb_host(fb_info); 1001 + struct mxsfb_info *host = fb_info->par; 999 1002 1000 1003 mxsfb_enable_axi_clk(host); 1001 1004