V4L/DVB (3568c): zoran: Init cleanups
Cleanups to the zr36057 initialization: * Drop intermediate local variables. * Single error path. Also drop a needless cast on kfree. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
parent
6eb5d9ca9f
commit
daf72f408c
|
@ -995,10 +995,7 @@ test_interrupts (struct zoran *zr)
|
||||||
static int __devinit
|
static int __devinit
|
||||||
zr36057_init (struct zoran *zr)
|
zr36057_init (struct zoran *zr)
|
||||||
{
|
{
|
||||||
u32 *mem;
|
int j, err;
|
||||||
void *vdev;
|
|
||||||
unsigned mem_needed;
|
|
||||||
int j;
|
|
||||||
int two = 2;
|
int two = 2;
|
||||||
int zero = 0;
|
int zero = 0;
|
||||||
|
|
||||||
|
@ -1049,19 +1046,16 @@ zr36057_init (struct zoran *zr)
|
||||||
|
|
||||||
/* allocate memory *before* doing anything to the hardware
|
/* allocate memory *before* doing anything to the hardware
|
||||||
* in case allocation fails */
|
* in case allocation fails */
|
||||||
mem_needed = BUZ_NUM_STAT_COM * 4;
|
zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
|
||||||
mem = kzalloc(mem_needed, GFP_KERNEL);
|
zr->video_dev = kmalloc(sizeof(struct video_device), GFP_KERNEL);
|
||||||
vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);
|
if (!zr->stat_com || !zr->video_dev) {
|
||||||
if (!mem || !vdev) {
|
|
||||||
dprintk(1,
|
dprintk(1,
|
||||||
KERN_ERR
|
KERN_ERR
|
||||||
"%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
|
"%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
|
||||||
ZR_DEVNAME(zr));
|
ZR_DEVNAME(zr));
|
||||||
kfree(vdev);
|
err = -ENOMEM;
|
||||||
kfree(mem);
|
goto exit_free;
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
zr->stat_com = mem;
|
|
||||||
for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
|
for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
|
||||||
zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */
|
zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */
|
||||||
}
|
}
|
||||||
|
@ -1069,16 +1063,11 @@ zr36057_init (struct zoran *zr)
|
||||||
/*
|
/*
|
||||||
* Now add the template and register the device unit.
|
* Now add the template and register the device unit.
|
||||||
*/
|
*/
|
||||||
zr->video_dev = vdev;
|
|
||||||
memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template));
|
memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template));
|
||||||
strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
|
strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
|
||||||
if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER,
|
err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr);
|
||||||
video_nr) < 0) {
|
if (err < 0)
|
||||||
zoran_unregister_i2c(zr);
|
goto exit_unregister;
|
||||||
kfree((void *) zr->stat_com);
|
|
||||||
kfree(vdev);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
zoran_init_hardware(zr);
|
zoran_init_hardware(zr);
|
||||||
if (*zr_debug > 2)
|
if (*zr_debug > 2)
|
||||||
|
@ -1092,6 +1081,13 @@ zr36057_init (struct zoran *zr)
|
||||||
zr->zoran_proc = NULL;
|
zr->zoran_proc = NULL;
|
||||||
zr->initialized = 1;
|
zr->initialized = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
exit_unregister:
|
||||||
|
zoran_unregister_i2c(zr);
|
||||||
|
exit_free:
|
||||||
|
kfree(zr->stat_com);
|
||||||
|
kfree(zr->video_dev);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1121,7 +1117,7 @@ zoran_release (struct zoran *zr)
|
||||||
btwrite(0, ZR36057_SPGPPCR);
|
btwrite(0, ZR36057_SPGPPCR);
|
||||||
free_irq(zr->pci_dev->irq, zr);
|
free_irq(zr->pci_dev->irq, zr);
|
||||||
/* unmap and free memory */
|
/* unmap and free memory */
|
||||||
kfree((void *) zr->stat_com);
|
kfree(zr->stat_com);
|
||||||
zoran_proc_cleanup(zr);
|
zoran_proc_cleanup(zr);
|
||||||
iounmap(zr->zr36057_mem);
|
iounmap(zr->zr36057_mem);
|
||||||
pci_disable_device(zr->pci_dev);
|
pci_disable_device(zr->pci_dev);
|
||||||
|
|
Loading…
Reference in New Issue