diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-06-19 02:17:41 -0400 |
---|---|---|
committer | Inki Dae <inki.dae@samsung.com> | 2012-07-26 22:13:55 -0400 |
commit | 9416dfa76ab418a2ba71ec1027f3c0af674d6e23 (patch) | |
tree | a4f7382c1a141680692ae04905b1ce4cef178557 /drivers/gpu | |
parent | a6e65072102a962e473cce5cf7aab0574bdf47e0 (diff) |
drm/exynos: Use devm_* functions in exynos_mixer.c
devm_* functions are device managed functions and make error handling
and cleanup cleaner and simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Sachin Kamat <sachin.kamat@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/exynos/exynos_mixer.c | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index e2147a2ddcec..30fcc12f81dd 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c | |||
@@ -956,7 +956,8 @@ static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx, | |||
956 | 956 | ||
957 | clk_set_parent(mixer_res->sclk_mixer, mixer_res->sclk_hdmi); | 957 | clk_set_parent(mixer_res->sclk_mixer, mixer_res->sclk_hdmi); |
958 | 958 | ||
959 | mixer_res->mixer_regs = ioremap(res->start, resource_size(res)); | 959 | mixer_res->mixer_regs = devm_ioremap(&pdev->dev, res->start, |
960 | resource_size(res)); | ||
960 | if (mixer_res->mixer_regs == NULL) { | 961 | if (mixer_res->mixer_regs == NULL) { |
961 | dev_err(dev, "register mapping failed.\n"); | 962 | dev_err(dev, "register mapping failed.\n"); |
962 | ret = -ENXIO; | 963 | ret = -ENXIO; |
@@ -967,38 +968,34 @@ static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx, | |||
967 | if (res == NULL) { | 968 | if (res == NULL) { |
968 | dev_err(dev, "get memory resource failed.\n"); | 969 | dev_err(dev, "get memory resource failed.\n"); |
969 | ret = -ENXIO; | 970 | ret = -ENXIO; |
970 | goto fail_mixer_regs; | 971 | goto fail; |
971 | } | 972 | } |
972 | 973 | ||
973 | mixer_res->vp_regs = ioremap(res->start, resource_size(res)); | 974 | mixer_res->vp_regs = devm_ioremap(&pdev->dev, res->start, |
975 | resource_size(res)); | ||
974 | if (mixer_res->vp_regs == NULL) { | 976 | if (mixer_res->vp_regs == NULL) { |
975 | dev_err(dev, "register mapping failed.\n"); | 977 | dev_err(dev, "register mapping failed.\n"); |
976 | ret = -ENXIO; | 978 | ret = -ENXIO; |
977 | goto fail_mixer_regs; | 979 | goto fail; |
978 | } | 980 | } |
979 | 981 | ||
980 | res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq"); | 982 | res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq"); |
981 | if (res == NULL) { | 983 | if (res == NULL) { |
982 | dev_err(dev, "get interrupt resource failed.\n"); | 984 | dev_err(dev, "get interrupt resource failed.\n"); |
983 | ret = -ENXIO; | 985 | ret = -ENXIO; |
984 | goto fail_vp_regs; | 986 | goto fail; |
985 | } | 987 | } |
986 | 988 | ||
987 | ret = request_irq(res->start, mixer_irq_handler, 0, "drm_mixer", ctx); | 989 | ret = devm_request_irq(&pdev->dev, res->start, mixer_irq_handler, |
990 | 0, "drm_mixer", ctx); | ||
988 | if (ret) { | 991 | if (ret) { |
989 | dev_err(dev, "request interrupt failed.\n"); | 992 | dev_err(dev, "request interrupt failed.\n"); |
990 | goto fail_vp_regs; | 993 | goto fail; |
991 | } | 994 | } |
992 | mixer_res->irq = res->start; | 995 | mixer_res->irq = res->start; |
993 | 996 | ||
994 | return 0; | 997 | return 0; |
995 | 998 | ||
996 | fail_vp_regs: | ||
997 | iounmap(mixer_res->vp_regs); | ||
998 | |||
999 | fail_mixer_regs: | ||
1000 | iounmap(mixer_res->mixer_regs); | ||
1001 | |||
1002 | fail: | 999 | fail: |
1003 | if (!IS_ERR_OR_NULL(mixer_res->sclk_dac)) | 1000 | if (!IS_ERR_OR_NULL(mixer_res->sclk_dac)) |
1004 | clk_put(mixer_res->sclk_dac); | 1001 | clk_put(mixer_res->sclk_dac); |
@@ -1013,16 +1010,6 @@ fail: | |||
1013 | return ret; | 1010 | return ret; |
1014 | } | 1011 | } |
1015 | 1012 | ||
1016 | static void mixer_resources_cleanup(struct mixer_context *ctx) | ||
1017 | { | ||
1018 | struct mixer_resources *res = &ctx->mixer_res; | ||
1019 | |||
1020 | free_irq(res->irq, ctx); | ||
1021 | |||
1022 | iounmap(res->vp_regs); | ||
1023 | iounmap(res->mixer_regs); | ||
1024 | } | ||
1025 | |||
1026 | static int __devinit mixer_probe(struct platform_device *pdev) | 1013 | static int __devinit mixer_probe(struct platform_device *pdev) |
1027 | { | 1014 | { |
1028 | struct device *dev = &pdev->dev; | 1015 | struct device *dev = &pdev->dev; |
@@ -1032,16 +1019,16 @@ static int __devinit mixer_probe(struct platform_device *pdev) | |||
1032 | 1019 | ||
1033 | dev_info(dev, "probe start\n"); | 1020 | dev_info(dev, "probe start\n"); |
1034 | 1021 | ||
1035 | drm_hdmi_ctx = kzalloc(sizeof(*drm_hdmi_ctx), GFP_KERNEL); | 1022 | drm_hdmi_ctx = devm_kzalloc(&pdev->dev, sizeof(*drm_hdmi_ctx), |
1023 | GFP_KERNEL); | ||
1036 | if (!drm_hdmi_ctx) { | 1024 | if (!drm_hdmi_ctx) { |
1037 | DRM_ERROR("failed to allocate common hdmi context.\n"); | 1025 | DRM_ERROR("failed to allocate common hdmi context.\n"); |
1038 | return -ENOMEM; | 1026 | return -ENOMEM; |
1039 | } | 1027 | } |
1040 | 1028 | ||
1041 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); | 1029 | ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); |
1042 | if (!ctx) { | 1030 | if (!ctx) { |
1043 | DRM_ERROR("failed to alloc mixer context.\n"); | 1031 | DRM_ERROR("failed to alloc mixer context.\n"); |
1044 | kfree(drm_hdmi_ctx); | ||
1045 | return -ENOMEM; | 1032 | return -ENOMEM; |
1046 | } | 1033 | } |
1047 | 1034 | ||
@@ -1072,17 +1059,10 @@ fail: | |||
1072 | 1059 | ||
1073 | static int mixer_remove(struct platform_device *pdev) | 1060 | static int mixer_remove(struct platform_device *pdev) |
1074 | { | 1061 | { |
1075 | struct device *dev = &pdev->dev; | 1062 | dev_info(&pdev->dev, "remove successful\n"); |
1076 | struct exynos_drm_hdmi_context *drm_hdmi_ctx = | ||
1077 | platform_get_drvdata(pdev); | ||
1078 | struct mixer_context *ctx = drm_hdmi_ctx->ctx; | ||
1079 | |||
1080 | dev_info(dev, "remove successful\n"); | ||
1081 | 1063 | ||
1082 | pm_runtime_disable(&pdev->dev); | 1064 | pm_runtime_disable(&pdev->dev); |
1083 | 1065 | ||
1084 | mixer_resources_cleanup(ctx); | ||
1085 | |||
1086 | return 0; | 1066 | return 0; |
1087 | } | 1067 | } |
1088 | 1068 | ||