Commit 4d10ecf8 authored by Jingoo Han's avatar Jingoo Han Committed by Florian Tobias Schandinat

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: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
parent cc440114
...@@ -858,7 +858,8 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) ...@@ -858,7 +858,8 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
dp = kzalloc(sizeof(struct exynos_dp_device), GFP_KERNEL); dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
GFP_KERNEL);
if (!dp) { if (!dp) {
dev_err(&pdev->dev, "no memory for device data\n"); dev_err(&pdev->dev, "no memory for device data\n");
return -ENOMEM; return -ENOMEM;
...@@ -869,8 +870,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) ...@@ -869,8 +870,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
dp->clock = clk_get(&pdev->dev, "dp"); dp->clock = clk_get(&pdev->dev, "dp");
if (IS_ERR(dp->clock)) { if (IS_ERR(dp->clock)) {
dev_err(&pdev->dev, "failed to get clock\n"); dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(dp->clock); return PTR_ERR(dp->clock);
goto err_dp;
} }
clk_enable(dp->clock); clk_enable(dp->clock);
...@@ -882,35 +882,25 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) ...@@ -882,35 +882,25 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
goto err_clock; goto err_clock;
} }
res = request_mem_region(res->start, resource_size(res), dp->reg_base = devm_request_and_ioremap(&pdev->dev, res);
dev_name(&pdev->dev));
if (!res) {
dev_err(&pdev->dev, "failed to request registers region\n");
ret = -EINVAL;
goto err_clock;
}
dp->res = res;
dp->reg_base = ioremap(res->start, resource_size(res));
if (!dp->reg_base) { if (!dp->reg_base) {
dev_err(&pdev->dev, "failed to ioremap\n"); dev_err(&pdev->dev, "failed to ioremap\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_req_region; goto err_clock;
} }
dp->irq = platform_get_irq(pdev, 0); dp->irq = platform_get_irq(pdev, 0);
if (!dp->irq) { if (!dp->irq) {
dev_err(&pdev->dev, "failed to get irq\n"); dev_err(&pdev->dev, "failed to get irq\n");
ret = -ENODEV; ret = -ENODEV;
goto err_ioremap; goto err_clock;
} }
ret = request_irq(dp->irq, exynos_dp_irq_handler, 0, ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler, 0,
"exynos-dp", dp); "exynos-dp", dp);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to request irq\n"); dev_err(&pdev->dev, "failed to request irq\n");
goto err_ioremap; goto err_clock;
} }
dp->video_info = pdata->video_info; dp->video_info = pdata->video_info;
...@@ -922,7 +912,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) ...@@ -922,7 +912,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
ret = exynos_dp_detect_hpd(dp); ret = exynos_dp_detect_hpd(dp);
if (ret) { if (ret) {
dev_err(&pdev->dev, "unable to detect hpd\n"); dev_err(&pdev->dev, "unable to detect hpd\n");
goto err_irq; goto err_clock;
} }
exynos_dp_handle_edid(dp); exynos_dp_handle_edid(dp);
...@@ -931,7 +921,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) ...@@ -931,7 +921,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
dp->video_info->link_rate); dp->video_info->link_rate);
if (ret) { if (ret) {
dev_err(&pdev->dev, "unable to do link train\n"); dev_err(&pdev->dev, "unable to do link train\n");
goto err_irq; goto err_clock;
} }
exynos_dp_enable_scramble(dp, 1); exynos_dp_enable_scramble(dp, 1);
...@@ -945,23 +935,15 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) ...@@ -945,23 +935,15 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
ret = exynos_dp_config_video(dp, dp->video_info); ret = exynos_dp_config_video(dp, dp->video_info);
if (ret) { if (ret) {
dev_err(&pdev->dev, "unable to config video\n"); dev_err(&pdev->dev, "unable to config video\n");
goto err_irq; goto err_clock;
} }
platform_set_drvdata(pdev, dp); platform_set_drvdata(pdev, dp);
return 0; return 0;
err_irq:
free_irq(dp->irq, dp);
err_ioremap:
iounmap(dp->reg_base);
err_req_region:
release_mem_region(res->start, resource_size(res));
err_clock: err_clock:
clk_put(dp->clock); clk_put(dp->clock);
err_dp:
kfree(dp);
return ret; return ret;
} }
...@@ -974,16 +956,9 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev) ...@@ -974,16 +956,9 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev)
if (pdata && pdata->phy_exit) if (pdata && pdata->phy_exit)
pdata->phy_exit(); pdata->phy_exit();
free_irq(dp->irq, dp);
iounmap(dp->reg_base);
clk_disable(dp->clock); clk_disable(dp->clock);
clk_put(dp->clock); clk_put(dp->clock);
release_mem_region(dp->res->start, resource_size(dp->res));
kfree(dp);
return 0; return 0;
} }
......
...@@ -26,7 +26,6 @@ struct link_train { ...@@ -26,7 +26,6 @@ struct link_train {
struct exynos_dp_device { struct exynos_dp_device {
struct device *dev; struct device *dev;
struct resource *res;
struct clk *clock; struct clk *clock;
unsigned int irq; unsigned int irq;
void __iomem *reg_base; void __iomem *reg_base;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment