linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] video: bfin_adv7393fb: Fix cleanup code
@ 2012-05-28 14:40 Emil Goode
  2012-05-28 15:26 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Emil Goode @ 2012-05-28 14:40 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: linux-fbdev, linux-kernel, kernel-janitors, Emil Goode

This patch fixes the cleanup code of the bfin_adv7393_fb_probe
function by changing the order in which cleanup is performed
and by adding one label.

Signed-off-by: Emil Goode <emilgoode@gmail.com>
---
 drivers/video/bfin_adv7393fb.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/video/bfin_adv7393fb.c b/drivers/video/bfin_adv7393fb.c
index 1a268a2..ddbd031 100644
--- a/drivers/video/bfin_adv7393fb.c
+++ b/drivers/video/bfin_adv7393fb.c
@@ -414,7 +414,7 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client,
 		if (ret) {
 			dev_err(&client->dev, "PPI0_FS3 GPIO request failed\n");
 			ret = -EBUSY;
-			goto out_8;
+			goto out_9;
 		}
 	}
 
@@ -528,15 +528,18 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client,
  out_3:
 	free_dma(CH_PPI);
  out_4:
-	dma_free_coherent(NULL, fbdev->fb_len, fbdev->fb_mem,
-			  fbdev->dma_handle);
- out_5:
 	fb_dealloc_cmap(&fbdev->info.cmap);
- out_6:
+ out_5:
 	kfree(fbdev->info.pseudo_palette);
+ out_6:
+	dma_free_coherent(NULL, fbdev->fb_len, fbdev->fb_mem,
+			  fbdev->dma_handle);
  out_7:
 	peripheral_free_list(ppi_pins);
  out_8:
+	if (ANOMALY_05000400)
+		gpio_free(P_IDENT(P_PPI0_FS3));
+ out_9:
 	kfree(fbdev);
 
 	return ret;
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] video: bfin_adv7393fb: Fix cleanup code
  2012-05-28 14:40 [PATCH] video: bfin_adv7393fb: Fix cleanup code Emil Goode
@ 2012-05-28 15:26 ` Dan Carpenter
  2012-05-28 15:34   ` Emil Goode
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2012-05-28 15:26 UTC (permalink / raw)
  To: Emil Goode; +Cc: FlorianSchandinat, linux-fbdev, linux-kernel, kernel-janitors

On Mon, May 28, 2012 at 04:40:19PM +0200, Emil Goode wrote:
> This patch fixes the cleanup code of the bfin_adv7393_fb_probe
> function by changing the order in which cleanup is performed
> and by adding one label.
> 

Could you list the actual bugs which were fixed:

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.

The new gpio_free() is more important than the added label.

Since you're changing all these, you may as well fix the label names
as well.  The out_9 style labels suck.  The right way is to give
them meaningful labels instead of GW-BASIC style labels.

Labels should be named after what happens when you arrive.  Some
people name them after the start of the journey but that's a
mistake.  It's just like the town of Chicago is still called Chicago
even though you might goto Chicago starting from Boston.  Like this:

err_ppi:
	free_dma(CH_PPI);
	fb_dealloc_cmap(&fbdev->info.cmap);
err_palette:
	kfree(fbdev->info.pseudo_palette);

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] video: bfin_adv7393fb: Fix cleanup code
  2012-05-28 15:26 ` Dan Carpenter
@ 2012-05-28 15:34   ` Emil Goode
  0 siblings, 0 replies; 3+ messages in thread
From: Emil Goode @ 2012-05-28 15:34 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: FlorianSchandinat, linux-fbdev, linux-kernel, kernel-janitors

Thanks Dan, I'll resend with these modifications.

Best regards, 
Emil Goode
On Mon, 2012-05-28 at 18:26 +0300, Dan Carpenter wrote:
> On Mon, May 28, 2012 at 04:40:19PM +0200, Emil Goode wrote:
> > This patch fixes the cleanup code of the bfin_adv7393_fb_probe
> > function by changing the order in which cleanup is performed
> > and by adding one label.
> > 
> 
> Could you list the actual bugs which were fixed:
> 
> 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.
> 
> The new gpio_free() is more important than the added label.
> 
> Since you're changing all these, you may as well fix the label names
> as well.  The out_9 style labels suck.  The right way is to give
> them meaningful labels instead of GW-BASIC style labels.
> 
> Labels should be named after what happens when you arrive.  Some
> people name them after the start of the journey but that's a
> mistake.  It's just like the town of Chicago is still called Chicago
> even though you might goto Chicago starting from Boston.  Like this:
> 
> err_ppi:
> 	free_dma(CH_PPI);
> 	fb_dealloc_cmap(&fbdev->info.cmap);
> err_palette:
> 	kfree(fbdev->info.pseudo_palette);
> 
> regards,
> dan carpenter



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-28 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-28 14:40 [PATCH] video: bfin_adv7393fb: Fix cleanup code Emil Goode
2012-05-28 15:26 ` Dan Carpenter
2012-05-28 15:34   ` Emil Goode

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).