aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-02-21 19:42:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 20:22:18 -0500
commitf18acdeacbcf038df3c9b03a96193cb01ca45cbb (patch)
tree7a4e2703088116918e3bf999f6b42593e4a5b3b9 /drivers/video
parent0c980826211611178b6d76b246d00a4c840f21e5 (diff)
drivers/video/exynos/exynos_mipi_dsi.c: use devm_* APIs
devm_* APIs are device managed and make exit and cleanup code simpler. While at it also remove some unused labels and fix an error path. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Donghwa Lee <dh09.lee@samsung.com> Cc: Inki Dae <inki.dae@samsung.com> Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/exynos/exynos_mipi_dsi.c68
1 files changed, 17 insertions, 51 deletions
diff --git a/drivers/video/exynos/exynos_mipi_dsi.c b/drivers/video/exynos/exynos_mipi_dsi.c
index f623dfcca927..fac7df6d1aba 100644
--- a/drivers/video/exynos/exynos_mipi_dsi.c
+++ b/drivers/video/exynos/exynos_mipi_dsi.c
@@ -338,7 +338,8 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
338 struct mipi_dsim_ddi *dsim_ddi; 338 struct mipi_dsim_ddi *dsim_ddi;
339 int ret = -EINVAL; 339 int ret = -EINVAL;
340 340
341 dsim = kzalloc(sizeof(struct mipi_dsim_device), GFP_KERNEL); 341 dsim = devm_kzalloc(&pdev->dev, sizeof(struct mipi_dsim_device),
342 GFP_KERNEL);
342 if (!dsim) { 343 if (!dsim) {
343 dev_err(&pdev->dev, "failed to allocate dsim object.\n"); 344 dev_err(&pdev->dev, "failed to allocate dsim object.\n");
344 return -ENOMEM; 345 return -ENOMEM;
@@ -352,13 +353,13 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
352 dsim_pd = (struct mipi_dsim_platform_data *)dsim->pd; 353 dsim_pd = (struct mipi_dsim_platform_data *)dsim->pd;
353 if (dsim_pd == NULL) { 354 if (dsim_pd == NULL) {
354 dev_err(&pdev->dev, "failed to get platform data for dsim.\n"); 355 dev_err(&pdev->dev, "failed to get platform data for dsim.\n");
355 goto err_clock_get; 356 return -EINVAL;
356 } 357 }
357 /* get mipi_dsim_config. */ 358 /* get mipi_dsim_config. */
358 dsim_config = dsim_pd->dsim_config; 359 dsim_config = dsim_pd->dsim_config;
359 if (dsim_config == NULL) { 360 if (dsim_config == NULL) {
360 dev_err(&pdev->dev, "failed to get dsim config data.\n"); 361 dev_err(&pdev->dev, "failed to get dsim config data.\n");
361 goto err_clock_get; 362 return -EINVAL;
362 } 363 }
363 364
364 dsim->dsim_config = dsim_config; 365 dsim->dsim_config = dsim_config;
@@ -366,41 +367,28 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
366 367
367 mutex_init(&dsim->lock); 368 mutex_init(&dsim->lock);
368 369
369 ret = regulator_bulk_get(&pdev->dev, ARRAY_SIZE(supplies), supplies); 370 ret = devm_regulator_bulk_get(&pdev->dev, ARRAY_SIZE(supplies),
371 supplies);
370 if (ret) { 372 if (ret) {
371 dev_err(&pdev->dev, "Failed to get regulators: %d\n", ret); 373 dev_err(&pdev->dev, "Failed to get regulators: %d\n", ret);
372 goto err_clock_get; 374 return ret;
373 } 375 }
374 376
375 dsim->clock = clk_get(&pdev->dev, "dsim0"); 377 dsim->clock = devm_clk_get(&pdev->dev, "dsim0");
376 if (IS_ERR(dsim->clock)) { 378 if (IS_ERR(dsim->clock)) {
377 dev_err(&pdev->dev, "failed to get dsim clock source\n"); 379 dev_err(&pdev->dev, "failed to get dsim clock source\n");
378 ret = -ENODEV; 380 return -ENODEV;
379 goto err_clock_get;
380 } 381 }
381 382
382 clk_enable(dsim->clock); 383 clk_enable(dsim->clock);
383 384
384 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 385 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
385 if (!res) {
386 dev_err(&pdev->dev, "failed to get io memory region\n");
387 ret = -ENODEV;
388 goto err_platform_get;
389 }
390
391 dsim->res = request_mem_region(res->start, resource_size(res),
392 dev_name(&pdev->dev));
393 if (!dsim->res) {
394 dev_err(&pdev->dev, "failed to request io memory region\n");
395 ret = -ENOMEM;
396 goto err_mem_region;
397 }
398 386
399 dsim->reg_base = ioremap(res->start, resource_size(res)); 387 dsim->reg_base = devm_request_and_ioremap(&pdev->dev, res);
400 if (!dsim->reg_base) { 388 if (!dsim->reg_base) {
401 dev_err(&pdev->dev, "failed to remap io region\n"); 389 dev_err(&pdev->dev, "failed to remap io region\n");
402 ret = -ENOMEM; 390 ret = -ENOMEM;
403 goto err_ioremap; 391 goto error;
404 } 392 }
405 393
406 mutex_init(&dsim->lock); 394 mutex_init(&dsim->lock);
@@ -410,26 +398,27 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
410 if (!dsim_ddi) { 398 if (!dsim_ddi) {
411 dev_err(&pdev->dev, "mipi_dsim_ddi object not found.\n"); 399 dev_err(&pdev->dev, "mipi_dsim_ddi object not found.\n");
412 ret = -EINVAL; 400 ret = -EINVAL;
413 goto err_bind; 401 goto error;
414 } 402 }
415 403
416 dsim->irq = platform_get_irq(pdev, 0); 404 dsim->irq = platform_get_irq(pdev, 0);
417 if (IS_ERR_VALUE(dsim->irq)) { 405 if (IS_ERR_VALUE(dsim->irq)) {
418 dev_err(&pdev->dev, "failed to request dsim irq resource\n"); 406 dev_err(&pdev->dev, "failed to request dsim irq resource\n");
419 ret = -EINVAL; 407 ret = -EINVAL;
420 goto err_platform_get_irq; 408 goto error;
421 } 409 }
422 410
423 init_completion(&dsim_wr_comp); 411 init_completion(&dsim_wr_comp);
424 init_completion(&dsim_rd_comp); 412 init_completion(&dsim_rd_comp);
425 platform_set_drvdata(pdev, dsim); 413 platform_set_drvdata(pdev, dsim);
426 414
427 ret = request_irq(dsim->irq, exynos_mipi_dsi_interrupt_handler, 415 ret = devm_request_irq(&pdev->dev, dsim->irq,
416 exynos_mipi_dsi_interrupt_handler,
428 IRQF_SHARED, dev_name(&pdev->dev), dsim); 417 IRQF_SHARED, dev_name(&pdev->dev), dsim);
429 if (ret != 0) { 418 if (ret != 0) {
430 dev_err(&pdev->dev, "failed to request dsim irq\n"); 419 dev_err(&pdev->dev, "failed to request dsim irq\n");
431 ret = -EINVAL; 420 ret = -EINVAL;
432 goto err_bind; 421 goto error;
433 } 422 }
434 423
435 /* enable interrupts */ 424 /* enable interrupts */
@@ -471,22 +460,8 @@ done:
471 460
472 return 0; 461 return 0;
473 462
474err_bind: 463error:
475 iounmap(dsim->reg_base);
476
477err_ioremap:
478 release_mem_region(dsim->res->start, resource_size(dsim->res));
479
480err_mem_region:
481 release_resource(dsim->res);
482
483err_platform_get:
484 clk_disable(dsim->clock); 464 clk_disable(dsim->clock);
485 clk_put(dsim->clock);
486err_clock_get:
487 kfree(dsim);
488
489err_platform_get_irq:
490 return ret; 465 return ret;
491} 466}
492 467
@@ -496,13 +471,7 @@ static int exynos_mipi_dsi_remove(struct platform_device *pdev)
496 struct mipi_dsim_ddi *dsim_ddi, *next; 471 struct mipi_dsim_ddi *dsim_ddi, *next;
497 struct mipi_dsim_lcd_driver *dsim_lcd_drv; 472 struct mipi_dsim_lcd_driver *dsim_lcd_drv;
498 473
499 iounmap(dsim->reg_base);
500
501 clk_disable(dsim->clock); 474 clk_disable(dsim->clock);
502 clk_put(dsim->clock);
503
504 release_resource(dsim->res);
505 release_mem_region(dsim->res->start, resource_size(dsim->res));
506 475
507 list_for_each_entry_safe(dsim_ddi, next, &dsim_ddi_list, list) { 476 list_for_each_entry_safe(dsim_ddi, next, &dsim_ddi_list, list) {
508 if (dsim_ddi) { 477 if (dsim_ddi) {
@@ -518,9 +487,6 @@ static int exynos_mipi_dsi_remove(struct platform_device *pdev)
518 } 487 }
519 } 488 }
520 489
521 regulator_bulk_free(ARRAY_SIZE(supplies), supplies);
522 kfree(dsim);
523
524 return 0; 490 return 0;
525} 491}
526 492