diff options
author | Emil Goode <emilgoode@gmail.com> | 2012-05-28 12:54:51 -0400 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2012-05-29 09:16:45 -0400 |
commit | c895305e806b4346006d3cfba2b432d52268ecd3 (patch) | |
tree | 03079676703d79f2e2e57734ab2e8fe6a0109516 | |
parent | ddbcb289ca4b5c124673c076a6941cbca016c1d7 (diff) |
video: bfin_adv7393fb: Fix cleanup code
This patch fixes the cleanup code of the bfin_adv7393_fb_probe
function.
1) The resources were not freed in the order that we allocated them
so we call dma_free_coherent() before it was allocated.
2) The labels weren't in the right place which also meant that we
freed resources that weren't allocated.
3) We should free gpio_free(P_IDENT(P_PPI0_FS3)) before returning.
4) Lets change the label names into something more meaningful.
Signed-off-by: Emil Goode <emilgoode@gmail.com>
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
-rw-r--r-- | drivers/video/bfin_adv7393fb.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/drivers/video/bfin_adv7393fb.c b/drivers/video/bfin_adv7393fb.c index 1a268a294478..33ea874c87d2 100644 --- a/drivers/video/bfin_adv7393fb.c +++ b/drivers/video/bfin_adv7393fb.c | |||
@@ -414,14 +414,14 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client, | |||
414 | if (ret) { | 414 | if (ret) { |
415 | dev_err(&client->dev, "PPI0_FS3 GPIO request failed\n"); | 415 | dev_err(&client->dev, "PPI0_FS3 GPIO request failed\n"); |
416 | ret = -EBUSY; | 416 | ret = -EBUSY; |
417 | goto out_8; | 417 | goto free_fbdev; |
418 | } | 418 | } |
419 | } | 419 | } |
420 | 420 | ||
421 | if (peripheral_request_list(ppi_pins, DRIVER_NAME)) { | 421 | if (peripheral_request_list(ppi_pins, DRIVER_NAME)) { |
422 | dev_err(&client->dev, "requesting PPI peripheral failed\n"); | 422 | dev_err(&client->dev, "requesting PPI peripheral failed\n"); |
423 | ret = -EFAULT; | 423 | ret = -EFAULT; |
424 | goto out_8; | 424 | goto free_gpio; |
425 | } | 425 | } |
426 | 426 | ||
427 | fbdev->fb_mem = | 427 | fbdev->fb_mem = |
@@ -432,7 +432,7 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client, | |||
432 | dev_err(&client->dev, "couldn't allocate dma buffer (%d bytes)\n", | 432 | dev_err(&client->dev, "couldn't allocate dma buffer (%d bytes)\n", |
433 | (u32) fbdev->fb_len); | 433 | (u32) fbdev->fb_len); |
434 | ret = -ENOMEM; | 434 | ret = -ENOMEM; |
435 | goto out_7; | 435 | goto free_ppi_pins; |
436 | } | 436 | } |
437 | 437 | ||
438 | fbdev->info.screen_base = (void *)fbdev->fb_mem; | 438 | fbdev->info.screen_base = (void *)fbdev->fb_mem; |
@@ -464,27 +464,27 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client, | |||
464 | if (!fbdev->info.pseudo_palette) { | 464 | if (!fbdev->info.pseudo_palette) { |
465 | dev_err(&client->dev, "failed to allocate pseudo_palette\n"); | 465 | dev_err(&client->dev, "failed to allocate pseudo_palette\n"); |
466 | ret = -ENOMEM; | 466 | ret = -ENOMEM; |
467 | goto out_6; | 467 | goto free_fb_mem; |
468 | } | 468 | } |
469 | 469 | ||
470 | if (fb_alloc_cmap(&fbdev->info.cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0) < 0) { | 470 | if (fb_alloc_cmap(&fbdev->info.cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0) < 0) { |
471 | dev_err(&client->dev, "failed to allocate colormap (%d entries)\n", | 471 | dev_err(&client->dev, "failed to allocate colormap (%d entries)\n", |
472 | BFIN_LCD_NBR_PALETTE_ENTRIES); | 472 | BFIN_LCD_NBR_PALETTE_ENTRIES); |
473 | ret = -EFAULT; | 473 | ret = -EFAULT; |
474 | goto out_5; | 474 | goto free_palette; |
475 | } | 475 | } |
476 | 476 | ||
477 | if (request_dma(CH_PPI, "BF5xx_PPI_DMA") < 0) { | 477 | if (request_dma(CH_PPI, "BF5xx_PPI_DMA") < 0) { |
478 | dev_err(&client->dev, "unable to request PPI DMA\n"); | 478 | dev_err(&client->dev, "unable to request PPI DMA\n"); |
479 | ret = -EFAULT; | 479 | ret = -EFAULT; |
480 | goto out_4; | 480 | goto free_cmap; |
481 | } | 481 | } |
482 | 482 | ||
483 | if (request_irq(IRQ_PPI_ERROR, ppi_irq_error, 0, | 483 | if (request_irq(IRQ_PPI_ERROR, ppi_irq_error, 0, |
484 | "PPI ERROR", fbdev) < 0) { | 484 | "PPI ERROR", fbdev) < 0) { |
485 | dev_err(&client->dev, "unable to request PPI ERROR IRQ\n"); | 485 | dev_err(&client->dev, "unable to request PPI ERROR IRQ\n"); |
486 | ret = -EFAULT; | 486 | ret = -EFAULT; |
487 | goto out_3; | 487 | goto free_ch_ppi; |
488 | } | 488 | } |
489 | 489 | ||
490 | fbdev->open = 0; | 490 | fbdev->open = 0; |
@@ -494,14 +494,14 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client, | |||
494 | 494 | ||
495 | if (ret) { | 495 | if (ret) { |
496 | dev_err(&client->dev, "i2c attach: init error\n"); | 496 | dev_err(&client->dev, "i2c attach: init error\n"); |
497 | goto out_1; | 497 | goto free_irq_ppi; |
498 | } | 498 | } |
499 | 499 | ||
500 | 500 | ||
501 | if (register_framebuffer(&fbdev->info) < 0) { | 501 | if (register_framebuffer(&fbdev->info) < 0) { |
502 | dev_err(&client->dev, "unable to register framebuffer\n"); | 502 | dev_err(&client->dev, "unable to register framebuffer\n"); |
503 | ret = -EFAULT; | 503 | ret = -EFAULT; |
504 | goto out_1; | 504 | goto free_irq_ppi; |
505 | } | 505 | } |
506 | 506 | ||
507 | dev_info(&client->dev, "fb%d: %s frame buffer device\n", | 507 | dev_info(&client->dev, "fb%d: %s frame buffer device\n", |
@@ -512,7 +512,7 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client, | |||
512 | if (!entry) { | 512 | if (!entry) { |
513 | dev_err(&client->dev, "unable to create /proc entry\n"); | 513 | dev_err(&client->dev, "unable to create /proc entry\n"); |
514 | ret = -EFAULT; | 514 | ret = -EFAULT; |
515 | goto out_0; | 515 | goto free_fb; |
516 | } | 516 | } |
517 | 517 | ||
518 | entry->read_proc = adv7393_read_proc; | 518 | entry->read_proc = adv7393_read_proc; |
@@ -521,22 +521,25 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client, | |||
521 | 521 | ||
522 | return 0; | 522 | return 0; |
523 | 523 | ||
524 | out_0: | 524 | free_fb: |
525 | unregister_framebuffer(&fbdev->info); | 525 | unregister_framebuffer(&fbdev->info); |
526 | out_1: | 526 | free_irq_ppi: |
527 | free_irq(IRQ_PPI_ERROR, fbdev); | 527 | free_irq(IRQ_PPI_ERROR, fbdev); |
528 | out_3: | 528 | free_ch_ppi: |
529 | free_dma(CH_PPI); | 529 | free_dma(CH_PPI); |
530 | out_4: | 530 | free_cmap: |
531 | dma_free_coherent(NULL, fbdev->fb_len, fbdev->fb_mem, | ||
532 | fbdev->dma_handle); | ||
533 | out_5: | ||
534 | fb_dealloc_cmap(&fbdev->info.cmap); | 531 | fb_dealloc_cmap(&fbdev->info.cmap); |
535 | out_6: | 532 | free_palette: |
536 | kfree(fbdev->info.pseudo_palette); | 533 | kfree(fbdev->info.pseudo_palette); |
537 | out_7: | 534 | free_fb_mem: |
535 | dma_free_coherent(NULL, fbdev->fb_len, fbdev->fb_mem, | ||
536 | fbdev->dma_handle); | ||
537 | free_ppi_pins: | ||
538 | peripheral_free_list(ppi_pins); | 538 | peripheral_free_list(ppi_pins); |
539 | out_8: | 539 | free_gpio: |
540 | if (ANOMALY_05000400) | ||
541 | gpio_free(P_IDENT(P_PPI0_FS3)); | ||
542 | free_fbdev: | ||
540 | kfree(fbdev); | 543 | kfree(fbdev); |
541 | 544 | ||
542 | return ret; | 545 | return ret; |