public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ronald S. Bultje" <rbultje@ronald.bitfreak.net>
To: Jean Delvare <khali@linux-fr.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH 8/8] zoran: Init cleanups
Date: Mon, 27 Mar 2006 00:09:59 -0500	[thread overview]
Message-ID: <1143436200.2691.6.camel@localhost.localdomain> (raw)
In-Reply-To: <20060313213651.e983de01.khali@linux-fr.org>

Hi Andrew,

On Mon, 2006-03-13 at 21:36 +0100, Jean Delvare wrote:
> Cleanups to the zr36057 initialization:
> * Drop intermediate local variables.
> * Single error path.
> Also drop a needless cast on kfree.

Please take this patch into your tree, it looks good. Jean, thanks for
contributing (again!).

Cheers,
Ronald

> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> ---
>  drivers/media/video/zoran_card.c |   38 +++++++++++++++++---------------------
>  1 file changed, 17 insertions(+), 21 deletions(-)
> 
> --- linux-2.6.15-git.orig/drivers/media/video/zoran_card.c	2006-01-12 21:08:57.000000000 +0100
> +++ linux-2.6.15-git/drivers/media/video/zoran_card.c	2006-01-12 21:12:05.000000000 +0100
> @@ -995,10 +995,7 @@
>  static int __devinit
>  zr36057_init (struct zoran *zr)
>  {
> -	u32 *mem;
> -	void *vdev;
> -	unsigned mem_needed;
> -	int j;
> +	int j, err;
>  	int two = 2;
>  	int zero = 0;
>  
> @@ -1049,19 +1046,16 @@
>  
>  	/* allocate memory *before* doing anything to the hardware
>  	 * in case allocation fails */
> -	mem_needed = BUZ_NUM_STAT_COM * 4;
> -	mem = kzalloc(mem_needed, GFP_KERNEL);
> -	vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);
> -	if (!mem || !vdev) {
> +	zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
> +	zr->video_dev = kmalloc(sizeof(struct video_device), GFP_KERNEL);
> +	if (!zr->stat_com || !zr->video_dev) {
>  		dprintk(1,
>  			KERN_ERR
>  			"%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
>  			ZR_DEVNAME(zr));
> -		kfree(vdev);
> -		kfree(mem);
> -		return -ENOMEM;
> +		err = -ENOMEM;
> +		goto exit_free;
>  	}
> -	zr->stat_com = mem;
>  	for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
>  		zr->stat_com[j] = 1;	/* mark as unavailable to zr36057 */
>  	}
> @@ -1069,16 +1063,11 @@
>  	/*
>  	 *   Now add the template and register the device unit.
>  	 */
> -	zr->video_dev = vdev;
>  	memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template));
>  	strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
> -	if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER,
> -				  video_nr) < 0) {
> -		zoran_unregister_i2c(zr);
> -		kfree((void *) zr->stat_com);
> -		kfree(vdev);
> -		return -1;
> -	}
> +	err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr);
> +	if (err < 0)
> +		goto exit_unregister;
>  
>  	zoran_init_hardware(zr);
>  	if (*zr_debug > 2)
> @@ -1092,6 +1081,13 @@
>  	zr->zoran_proc = NULL;
>  	zr->initialized = 1;
>  	return 0;
> +
> +exit_unregister:
> +	zoran_unregister_i2c(zr);
> +exit_free:
> +	kfree(zr->stat_com);
> +	kfree(zr->video_dev);
> +	return err;
>  }
>  
>  static void
> @@ -1121,7 +1117,7 @@
>  	btwrite(0, ZR36057_SPGPPCR);
>  	free_irq(zr->pci_dev->irq, zr);
>  	/* unmap and free memory */
> -	kfree((void *) zr->stat_com);
> +	kfree(zr->stat_com);
>  	zoran_proc_cleanup(zr);
>  	iounmap(zr->zr36057_mem);
>  	pci_disable_device(zr->pci_dev);
> 


  reply	other threads:[~2006-03-27  5:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-13 20:09 [PATCH 0/8] Zoran drivers updates Jean Delvare
2006-03-13 20:29 ` [PATCH 1/8] saa7110: Fix array overrun Jean Delvare
2006-03-13 20:29 ` [PATCH 2/8] saa7111: Prevent " Jean Delvare
2006-03-13 20:30 ` [PATCH 3/8] saa7114: Fix i2c block write Jean Delvare
2006-03-13 20:31 ` [PATCH 4/8] adv7175: Drop unused encoder dump command Jean Delvare
2006-03-13 20:32 ` [PATCH 5/8] adv7175: Drop unused register cache Jean Delvare
2006-03-13 20:34 ` [PATCH 6/8] zoran: Use i2c_master_send when possible Jean Delvare
2006-03-13 20:35 ` [PATCH 7/8] bt856: Spare memory Jean Delvare
2006-03-13 20:36 ` [PATCH 8/8] zoran: Init cleanups Jean Delvare
2006-03-27  5:09   ` Ronald S. Bultje [this message]
2006-03-13 20:53 ` [PATCH 0/8] Zoran drivers updates Ronald S. Bultje

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1143436200.2691.6.camel@localhost.localdomain \
    --to=rbultje@ronald.bitfreak.net \
    --cc=akpm@osdl.org \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox