diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-06-19 02:17:40 -0400 |
---|---|---|
committer | Inki Dae <inki.dae@samsung.com> | 2012-07-26 22:13:55 -0400 |
commit | a6e65072102a962e473cce5cf7aab0574bdf47e0 (patch) | |
tree | a402f32f3fb408aca09edd8ea02a65d60dd1ddb5 /drivers/gpu | |
parent | edc572662a97773053a8d46a59794a08467f5115 (diff) |
drm/exynos: Use devm_* functions in exynos_hdmi.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_hdmi.c | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 066bde3f19c4..409e2ec1207c 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c | |||
@@ -63,7 +63,6 @@ struct hdmi_context { | |||
63 | bool dvi_mode; | 63 | bool dvi_mode; |
64 | struct mutex hdmi_mutex; | 64 | struct mutex hdmi_mutex; |
65 | 65 | ||
66 | struct resource *regs_res; | ||
67 | void __iomem *regs; | 66 | void __iomem *regs; |
68 | unsigned int external_irq; | 67 | unsigned int external_irq; |
69 | unsigned int internal_irq; | 68 | unsigned int internal_irq; |
@@ -2280,16 +2279,17 @@ static int __devinit hdmi_probe(struct platform_device *pdev) | |||
2280 | return -EINVAL; | 2279 | return -EINVAL; |
2281 | } | 2280 | } |
2282 | 2281 | ||
2283 | drm_hdmi_ctx = kzalloc(sizeof(*drm_hdmi_ctx), GFP_KERNEL); | 2282 | drm_hdmi_ctx = devm_kzalloc(&pdev->dev, sizeof(*drm_hdmi_ctx), |
2283 | GFP_KERNEL); | ||
2284 | if (!drm_hdmi_ctx) { | 2284 | if (!drm_hdmi_ctx) { |
2285 | DRM_ERROR("failed to allocate common hdmi context.\n"); | 2285 | DRM_ERROR("failed to allocate common hdmi context.\n"); |
2286 | return -ENOMEM; | 2286 | return -ENOMEM; |
2287 | } | 2287 | } |
2288 | 2288 | ||
2289 | hdata = kzalloc(sizeof(struct hdmi_context), GFP_KERNEL); | 2289 | hdata = devm_kzalloc(&pdev->dev, sizeof(struct hdmi_context), |
2290 | GFP_KERNEL); | ||
2290 | if (!hdata) { | 2291 | if (!hdata) { |
2291 | DRM_ERROR("out of memory\n"); | 2292 | DRM_ERROR("out of memory\n"); |
2292 | kfree(drm_hdmi_ctx); | ||
2293 | return -ENOMEM; | 2293 | return -ENOMEM; |
2294 | } | 2294 | } |
2295 | 2295 | ||
@@ -2318,26 +2318,18 @@ static int __devinit hdmi_probe(struct platform_device *pdev) | |||
2318 | goto err_resource; | 2318 | goto err_resource; |
2319 | } | 2319 | } |
2320 | 2320 | ||
2321 | hdata->regs_res = request_mem_region(res->start, resource_size(res), | 2321 | hdata->regs = devm_request_and_ioremap(&pdev->dev, res); |
2322 | dev_name(dev)); | ||
2323 | if (!hdata->regs_res) { | ||
2324 | DRM_ERROR("failed to claim register region\n"); | ||
2325 | ret = -ENOENT; | ||
2326 | goto err_resource; | ||
2327 | } | ||
2328 | |||
2329 | hdata->regs = ioremap(res->start, resource_size(res)); | ||
2330 | if (!hdata->regs) { | 2322 | if (!hdata->regs) { |
2331 | DRM_ERROR("failed to map registers\n"); | 2323 | DRM_ERROR("failed to map registers\n"); |
2332 | ret = -ENXIO; | 2324 | ret = -ENXIO; |
2333 | goto err_req_region; | 2325 | goto err_resource; |
2334 | } | 2326 | } |
2335 | 2327 | ||
2336 | /* DDC i2c driver */ | 2328 | /* DDC i2c driver */ |
2337 | if (i2c_add_driver(&ddc_driver)) { | 2329 | if (i2c_add_driver(&ddc_driver)) { |
2338 | DRM_ERROR("failed to register ddc i2c driver\n"); | 2330 | DRM_ERROR("failed to register ddc i2c driver\n"); |
2339 | ret = -ENOENT; | 2331 | ret = -ENOENT; |
2340 | goto err_iomap; | 2332 | goto err_resource; |
2341 | } | 2333 | } |
2342 | 2334 | ||
2343 | hdata->ddc_port = hdmi_ddc; | 2335 | hdata->ddc_port = hdmi_ddc; |
@@ -2398,16 +2390,9 @@ err_hdmiphy: | |||
2398 | i2c_del_driver(&hdmiphy_driver); | 2390 | i2c_del_driver(&hdmiphy_driver); |
2399 | err_ddc: | 2391 | err_ddc: |
2400 | i2c_del_driver(&ddc_driver); | 2392 | i2c_del_driver(&ddc_driver); |
2401 | err_iomap: | ||
2402 | iounmap(hdata->regs); | ||
2403 | err_req_region: | ||
2404 | release_mem_region(hdata->regs_res->start, | ||
2405 | resource_size(hdata->regs_res)); | ||
2406 | err_resource: | 2393 | err_resource: |
2407 | hdmi_resources_cleanup(hdata); | 2394 | hdmi_resources_cleanup(hdata); |
2408 | err_data: | 2395 | err_data: |
2409 | kfree(hdata); | ||
2410 | kfree(drm_hdmi_ctx); | ||
2411 | return ret; | 2396 | return ret; |
2412 | } | 2397 | } |
2413 | 2398 | ||
@@ -2425,18 +2410,11 @@ static int __devexit hdmi_remove(struct platform_device *pdev) | |||
2425 | 2410 | ||
2426 | hdmi_resources_cleanup(hdata); | 2411 | hdmi_resources_cleanup(hdata); |
2427 | 2412 | ||
2428 | iounmap(hdata->regs); | ||
2429 | |||
2430 | release_mem_region(hdata->regs_res->start, | ||
2431 | resource_size(hdata->regs_res)); | ||
2432 | |||
2433 | /* hdmiphy i2c driver */ | 2413 | /* hdmiphy i2c driver */ |
2434 | i2c_del_driver(&hdmiphy_driver); | 2414 | i2c_del_driver(&hdmiphy_driver); |
2435 | /* DDC i2c driver */ | 2415 | /* DDC i2c driver */ |
2436 | i2c_del_driver(&ddc_driver); | 2416 | i2c_del_driver(&ddc_driver); |
2437 | 2417 | ||
2438 | kfree(hdata); | ||
2439 | |||
2440 | return 0; | 2418 | return 0; |
2441 | } | 2419 | } |
2442 | 2420 | ||