aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2013-03-13 01:37:11 -0400
committerShawn Guo <shawn.guo@linaro.org>2013-04-04 09:22:41 -0400
commit9e5485791b805e3235ba5fb53d140881dbbe79be (patch)
treef37025214f2a87947389ae5ceac0d54113062c4e /drivers/video
parentd260a7af0fbd2257b3d88b3e72b8b11a0398f796 (diff)
video: mxsfb: use devm_* managed functions
Use devm_* managed functions to make code a little cleaner. Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/mxsfb.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 45169cbaba6e..69fb3f1d1e12 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -802,23 +802,19 @@ static int mxsfb_probe(struct platform_device *pdev)
802 return -ENODEV; 802 return -ENODEV;
803 } 803 }
804 804
805 if (!request_mem_region(res->start, resource_size(res), pdev->name))
806 return -EBUSY;
807
808 fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev); 805 fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);
809 if (!fb_info) { 806 if (!fb_info) {
810 dev_err(&pdev->dev, "Failed to allocate fbdev\n"); 807 dev_err(&pdev->dev, "Failed to allocate fbdev\n");
811 ret = -ENOMEM; 808 return -ENOMEM;
812 goto error_alloc_info;
813 } 809 }
814 810
815 host = to_imxfb_host(fb_info); 811 host = to_imxfb_host(fb_info);
816 812
817 host->base = ioremap(res->start, resource_size(res)); 813 host->base = devm_ioremap_resource(&pdev->dev, res);
818 if (!host->base) { 814 if (IS_ERR(host->base)) {
819 dev_err(&pdev->dev, "ioremap failed\n"); 815 dev_err(&pdev->dev, "ioremap failed\n");
820 ret = -ENOMEM; 816 ret = PTR_ERR(host->base);
821 goto error_ioremap; 817 goto fb_release;
822 } 818 }
823 819
824 host->pdev = pdev; 820 host->pdev = pdev;
@@ -829,13 +825,13 @@ static int mxsfb_probe(struct platform_device *pdev)
829 pinctrl = devm_pinctrl_get_select_default(&pdev->dev); 825 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
830 if (IS_ERR(pinctrl)) { 826 if (IS_ERR(pinctrl)) {
831 ret = PTR_ERR(pinctrl); 827 ret = PTR_ERR(pinctrl);
832 goto error_getpin; 828 goto fb_release;
833 } 829 }
834 830
835 host->clk = clk_get(&host->pdev->dev, NULL); 831 host->clk = devm_clk_get(&host->pdev->dev, NULL);
836 if (IS_ERR(host->clk)) { 832 if (IS_ERR(host->clk)) {
837 ret = PTR_ERR(host->clk); 833 ret = PTR_ERR(host->clk);
838 goto error_getclock; 834 goto fb_release;
839 } 835 }
840 836
841 panel_enable = of_get_named_gpio_flags(pdev->dev.of_node, 837 panel_enable = of_get_named_gpio_flags(pdev->dev.of_node,
@@ -850,14 +846,15 @@ static int mxsfb_probe(struct platform_device *pdev)
850 dev_err(&pdev->dev, 846 dev_err(&pdev->dev,
851 "failed to request gpio %d: %d\n", 847 "failed to request gpio %d: %d\n",
852 panel_enable, ret); 848 panel_enable, ret);
853 goto error_panel_enable; 849 goto fb_release;
854 } 850 }
855 } 851 }
856 852
857 fb_info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); 853 fb_info->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16,
854 GFP_KERNEL);
858 if (!fb_info->pseudo_palette) { 855 if (!fb_info->pseudo_palette) {
859 ret = -ENOMEM; 856 ret = -ENOMEM;
860 goto error_pseudo_pallette; 857 goto fb_release;
861 } 858 }
862 859
863 INIT_LIST_HEAD(&fb_info->modelist); 860 INIT_LIST_HEAD(&fb_info->modelist);
@@ -866,7 +863,7 @@ static int mxsfb_probe(struct platform_device *pdev)
866 863
867 ret = mxsfb_init_fbinfo(host); 864 ret = mxsfb_init_fbinfo(host);
868 if (ret != 0) 865 if (ret != 0)
869 goto error_init_fb; 866 goto fb_release;
870 867
871 for (i = 0; i < pdata->mode_count; i++) 868 for (i = 0; i < pdata->mode_count; i++)
872 fb_add_videomode(&pdata->mode_list[i], &fb_info->modelist); 869 fb_add_videomode(&pdata->mode_list[i], &fb_info->modelist);
@@ -883,7 +880,7 @@ static int mxsfb_probe(struct platform_device *pdev)
883 ret = register_framebuffer(fb_info); 880 ret = register_framebuffer(fb_info);
884 if (ret != 0) { 881 if (ret != 0) {
885 dev_err(&pdev->dev,"Failed to register framebuffer\n"); 882 dev_err(&pdev->dev,"Failed to register framebuffer\n");
886 goto error_register; 883 goto fb_destroy;
887 } 884 }
888 885
889 if (!host->enabled) { 886 if (!host->enabled) {
@@ -896,22 +893,12 @@ static int mxsfb_probe(struct platform_device *pdev)
896 893
897 return 0; 894 return 0;
898 895
899error_register: 896fb_destroy:
900 if (host->enabled) 897 if (host->enabled)
901 clk_disable_unprepare(host->clk); 898 clk_disable_unprepare(host->clk);
902 fb_destroy_modelist(&fb_info->modelist); 899 fb_destroy_modelist(&fb_info->modelist);
903error_init_fb: 900fb_release:
904 kfree(fb_info->pseudo_palette);
905error_pseudo_pallette:
906error_panel_enable:
907 clk_put(host->clk);
908error_getclock:
909error_getpin:
910 iounmap(host->base);
911error_ioremap:
912 framebuffer_release(fb_info); 901 framebuffer_release(fb_info);
913error_alloc_info:
914 release_mem_region(res->start, resource_size(res));
915 902
916 return ret; 903 return ret;
917} 904}
@@ -920,19 +907,14 @@ static int mxsfb_remove(struct platform_device *pdev)
920{ 907{
921 struct fb_info *fb_info = platform_get_drvdata(pdev); 908 struct fb_info *fb_info = platform_get_drvdata(pdev);
922 struct mxsfb_info *host = to_imxfb_host(fb_info); 909 struct mxsfb_info *host = to_imxfb_host(fb_info);
923 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
924 910
925 if (host->enabled) 911 if (host->enabled)
926 mxsfb_disable_controller(fb_info); 912 mxsfb_disable_controller(fb_info);
927 913
928 unregister_framebuffer(fb_info); 914 unregister_framebuffer(fb_info);
929 kfree(fb_info->pseudo_palette);
930 mxsfb_free_videomem(host); 915 mxsfb_free_videomem(host);
931 iounmap(host->base);
932 clk_put(host->clk);
933 916
934 framebuffer_release(fb_info); 917 framebuffer_release(fb_info);
935 release_mem_region(res->start, resource_size(res));
936 918
937 platform_set_drvdata(pdev, NULL); 919 platform_set_drvdata(pdev, NULL);
938 920