aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/exynos
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2012-05-25 03:20:45 -0400
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2012-05-29 09:16:15 -0400
commit4d10ecf86b31b732092dc9668a6088323c24ab09 (patch)
tree744a64339a6f79e9be4e48fadcb82a4c5c9c382e /drivers/video/exynos
parentcc4401142c1cbc63b01d6024cbc7a9f804cb3143 (diff)
video: exynos_dp: use devm_ functions
The devm_ functions allocate memory that is released when a driver detaches. This makes the code smaller and a bit simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/exynos')
-rw-r--r--drivers/video/exynos/exynos_dp_core.c49
-rw-r--r--drivers/video/exynos/exynos_dp_core.h1
2 files changed, 12 insertions, 38 deletions
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index ef4d1ab4cf4d..aabd214990d3 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -858,7 +858,8 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
858 return -EINVAL; 858 return -EINVAL;
859 } 859 }
860 860
861 dp = kzalloc(sizeof(struct exynos_dp_device), GFP_KERNEL); 861 dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
862 GFP_KERNEL);
862 if (!dp) { 863 if (!dp) {
863 dev_err(&pdev->dev, "no memory for device data\n"); 864 dev_err(&pdev->dev, "no memory for device data\n");
864 return -ENOMEM; 865 return -ENOMEM;
@@ -869,8 +870,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
869 dp->clock = clk_get(&pdev->dev, "dp"); 870 dp->clock = clk_get(&pdev->dev, "dp");
870 if (IS_ERR(dp->clock)) { 871 if (IS_ERR(dp->clock)) {
871 dev_err(&pdev->dev, "failed to get clock\n"); 872 dev_err(&pdev->dev, "failed to get clock\n");
872 ret = PTR_ERR(dp->clock); 873 return PTR_ERR(dp->clock);
873 goto err_dp;
874 } 874 }
875 875
876 clk_enable(dp->clock); 876 clk_enable(dp->clock);
@@ -882,35 +882,25 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
882 goto err_clock; 882 goto err_clock;
883 } 883 }
884 884
885 res = request_mem_region(res->start, resource_size(res), 885 dp->reg_base = devm_request_and_ioremap(&pdev->dev, res);
886 dev_name(&pdev->dev));
887 if (!res) {
888 dev_err(&pdev->dev, "failed to request registers region\n");
889 ret = -EINVAL;
890 goto err_clock;
891 }
892
893 dp->res = res;
894
895 dp->reg_base = ioremap(res->start, resource_size(res));
896 if (!dp->reg_base) { 886 if (!dp->reg_base) {
897 dev_err(&pdev->dev, "failed to ioremap\n"); 887 dev_err(&pdev->dev, "failed to ioremap\n");
898 ret = -ENOMEM; 888 ret = -ENOMEM;
899 goto err_req_region; 889 goto err_clock;
900 } 890 }
901 891
902 dp->irq = platform_get_irq(pdev, 0); 892 dp->irq = platform_get_irq(pdev, 0);
903 if (!dp->irq) { 893 if (!dp->irq) {
904 dev_err(&pdev->dev, "failed to get irq\n"); 894 dev_err(&pdev->dev, "failed to get irq\n");
905 ret = -ENODEV; 895 ret = -ENODEV;
906 goto err_ioremap; 896 goto err_clock;
907 } 897 }
908 898
909 ret = request_irq(dp->irq, exynos_dp_irq_handler, 0, 899 ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler, 0,
910 "exynos-dp", dp); 900 "exynos-dp", dp);
911 if (ret) { 901 if (ret) {
912 dev_err(&pdev->dev, "failed to request irq\n"); 902 dev_err(&pdev->dev, "failed to request irq\n");
913 goto err_ioremap; 903 goto err_clock;
914 } 904 }
915 905
916 dp->video_info = pdata->video_info; 906 dp->video_info = pdata->video_info;
@@ -922,7 +912,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
922 ret = exynos_dp_detect_hpd(dp); 912 ret = exynos_dp_detect_hpd(dp);
923 if (ret) { 913 if (ret) {
924 dev_err(&pdev->dev, "unable to detect hpd\n"); 914 dev_err(&pdev->dev, "unable to detect hpd\n");
925 goto err_irq; 915 goto err_clock;
926 } 916 }
927 917
928 exynos_dp_handle_edid(dp); 918 exynos_dp_handle_edid(dp);
@@ -931,7 +921,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
931 dp->video_info->link_rate); 921 dp->video_info->link_rate);
932 if (ret) { 922 if (ret) {
933 dev_err(&pdev->dev, "unable to do link train\n"); 923 dev_err(&pdev->dev, "unable to do link train\n");
934 goto err_irq; 924 goto err_clock;
935 } 925 }
936 926
937 exynos_dp_enable_scramble(dp, 1); 927 exynos_dp_enable_scramble(dp, 1);
@@ -945,23 +935,15 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
945 ret = exynos_dp_config_video(dp, dp->video_info); 935 ret = exynos_dp_config_video(dp, dp->video_info);
946 if (ret) { 936 if (ret) {
947 dev_err(&pdev->dev, "unable to config video\n"); 937 dev_err(&pdev->dev, "unable to config video\n");
948 goto err_irq; 938 goto err_clock;
949 } 939 }
950 940
951 platform_set_drvdata(pdev, dp); 941 platform_set_drvdata(pdev, dp);
952 942
953 return 0; 943 return 0;
954 944
955err_irq:
956 free_irq(dp->irq, dp);
957err_ioremap:
958 iounmap(dp->reg_base);
959err_req_region:
960 release_mem_region(res->start, resource_size(res));
961err_clock: 945err_clock:
962 clk_put(dp->clock); 946 clk_put(dp->clock);
963err_dp:
964 kfree(dp);
965 947
966 return ret; 948 return ret;
967} 949}
@@ -974,16 +956,9 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev)
974 if (pdata && pdata->phy_exit) 956 if (pdata && pdata->phy_exit)
975 pdata->phy_exit(); 957 pdata->phy_exit();
976 958
977 free_irq(dp->irq, dp);
978 iounmap(dp->reg_base);
979
980 clk_disable(dp->clock); 959 clk_disable(dp->clock);
981 clk_put(dp->clock); 960 clk_put(dp->clock);
982 961
983 release_mem_region(dp->res->start, resource_size(dp->res));
984
985 kfree(dp);
986
987 return 0; 962 return 0;
988} 963}
989 964
diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h
index 519c3a6a5c58..8f596b9e7b2b 100644
--- a/drivers/video/exynos/exynos_dp_core.h
+++ b/drivers/video/exynos/exynos_dp_core.h
@@ -26,7 +26,6 @@ struct link_train {
26 26
27struct exynos_dp_device { 27struct exynos_dp_device {
28 struct device *dev; 28 struct device *dev;
29 struct resource *res;
30 struct clk *clock; 29 struct clk *clock;
31 unsigned int irq; 30 unsigned int irq;
32 void __iomem *reg_base; 31 void __iomem *reg_base;