Commit 9e548579 authored by Shawn Guo's avatar Shawn Guo

video: mxsfb: use devm_* managed functions

Use devm_* managed functions to make code a little cleaner.
Signed-off-by: default avatarShawn Guo <shawn.guo@linaro.org>
parent d260a7af
...@@ -802,23 +802,19 @@ static int mxsfb_probe(struct platform_device *pdev) ...@@ -802,23 +802,19 @@ static int mxsfb_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
if (!request_mem_region(res->start, resource_size(res), pdev->name))
return -EBUSY;
fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev); fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);
if (!fb_info) { if (!fb_info) {
dev_err(&pdev->dev, "Failed to allocate fbdev\n"); dev_err(&pdev->dev, "Failed to allocate fbdev\n");
ret = -ENOMEM; return -ENOMEM;
goto error_alloc_info;
} }
host = to_imxfb_host(fb_info); host = to_imxfb_host(fb_info);
host->base = ioremap(res->start, resource_size(res)); host->base = devm_ioremap_resource(&pdev->dev, res);
if (!host->base) { if (IS_ERR(host->base)) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = PTR_ERR(host->base);
goto error_ioremap; goto fb_release;
} }
host->pdev = pdev; host->pdev = pdev;
...@@ -829,13 +825,13 @@ static int mxsfb_probe(struct platform_device *pdev) ...@@ -829,13 +825,13 @@ static int mxsfb_probe(struct platform_device *pdev)
pinctrl = devm_pinctrl_get_select_default(&pdev->dev); pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
if (IS_ERR(pinctrl)) { if (IS_ERR(pinctrl)) {
ret = PTR_ERR(pinctrl); ret = PTR_ERR(pinctrl);
goto error_getpin; goto fb_release;
} }
host->clk = clk_get(&host->pdev->dev, NULL); host->clk = devm_clk_get(&host->pdev->dev, NULL);
if (IS_ERR(host->clk)) { if (IS_ERR(host->clk)) {
ret = PTR_ERR(host->clk); ret = PTR_ERR(host->clk);
goto error_getclock; goto fb_release;
} }
panel_enable = of_get_named_gpio_flags(pdev->dev.of_node, panel_enable = of_get_named_gpio_flags(pdev->dev.of_node,
...@@ -850,14 +846,15 @@ static int mxsfb_probe(struct platform_device *pdev) ...@@ -850,14 +846,15 @@ static int mxsfb_probe(struct platform_device *pdev)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed to request gpio %d: %d\n", "failed to request gpio %d: %d\n",
panel_enable, ret); panel_enable, ret);
goto error_panel_enable; goto fb_release;
} }
} }
fb_info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); fb_info->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16,
GFP_KERNEL);
if (!fb_info->pseudo_palette) { if (!fb_info->pseudo_palette) {
ret = -ENOMEM; ret = -ENOMEM;
goto error_pseudo_pallette; goto fb_release;
} }
INIT_LIST_HEAD(&fb_info->modelist); INIT_LIST_HEAD(&fb_info->modelist);
...@@ -866,7 +863,7 @@ static int mxsfb_probe(struct platform_device *pdev) ...@@ -866,7 +863,7 @@ static int mxsfb_probe(struct platform_device *pdev)
ret = mxsfb_init_fbinfo(host); ret = mxsfb_init_fbinfo(host);
if (ret != 0) if (ret != 0)
goto error_init_fb; goto fb_release;
for (i = 0; i < pdata->mode_count; i++) for (i = 0; i < pdata->mode_count; i++)
fb_add_videomode(&pdata->mode_list[i], &fb_info->modelist); fb_add_videomode(&pdata->mode_list[i], &fb_info->modelist);
...@@ -883,7 +880,7 @@ static int mxsfb_probe(struct platform_device *pdev) ...@@ -883,7 +880,7 @@ static int mxsfb_probe(struct platform_device *pdev)
ret = register_framebuffer(fb_info); ret = register_framebuffer(fb_info);
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev,"Failed to register framebuffer\n"); dev_err(&pdev->dev,"Failed to register framebuffer\n");
goto error_register; goto fb_destroy;
} }
if (!host->enabled) { if (!host->enabled) {
...@@ -896,22 +893,12 @@ static int mxsfb_probe(struct platform_device *pdev) ...@@ -896,22 +893,12 @@ static int mxsfb_probe(struct platform_device *pdev)
return 0; return 0;
error_register: fb_destroy:
if (host->enabled) if (host->enabled)
clk_disable_unprepare(host->clk); clk_disable_unprepare(host->clk);
fb_destroy_modelist(&fb_info->modelist); fb_destroy_modelist(&fb_info->modelist);
error_init_fb: fb_release:
kfree(fb_info->pseudo_palette);
error_pseudo_pallette:
error_panel_enable:
clk_put(host->clk);
error_getclock:
error_getpin:
iounmap(host->base);
error_ioremap:
framebuffer_release(fb_info); framebuffer_release(fb_info);
error_alloc_info:
release_mem_region(res->start, resource_size(res));
return ret; return ret;
} }
...@@ -920,19 +907,14 @@ static int mxsfb_remove(struct platform_device *pdev) ...@@ -920,19 +907,14 @@ static int mxsfb_remove(struct platform_device *pdev)
{ {
struct fb_info *fb_info = platform_get_drvdata(pdev); struct fb_info *fb_info = platform_get_drvdata(pdev);
struct mxsfb_info *host = to_imxfb_host(fb_info); struct mxsfb_info *host = to_imxfb_host(fb_info);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (host->enabled) if (host->enabled)
mxsfb_disable_controller(fb_info); mxsfb_disable_controller(fb_info);
unregister_framebuffer(fb_info); unregister_framebuffer(fb_info);
kfree(fb_info->pseudo_palette);
mxsfb_free_videomem(host); mxsfb_free_videomem(host);
iounmap(host->base);
clk_put(host->clk);
framebuffer_release(fb_info); framebuffer_release(fb_info);
release_mem_region(res->start, resource_size(res));
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
......
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