if (vdev) kfree(vdev); if (mem) kfree((void *)mem); 
kfree(vdev); kfree((void *)mem); 
zr36057_init (struct zoran *zr){	unsigned long mem;	void *vdev;	unsigned mem_needed;	int j;	int two = 2;	int zero = 0;	dprintk(1,		KERN_INFO		"%s: zr36057_init() - initializing card[%d], zr=%p\n",		ZR_DEVNAME(zr), zr->id, zr);	/* default setup of all parameters which will persist between opens */	zr->user = 0;	init_waitqueue_head(&zr->v4l_capq);	init_waitqueue_head(&zr->jpg_capq);	init_waitqueue_head(&zr->test_q);	zr->jpg_buffers.allocated = 0;	zr->v4l_buffers.allocated = 0;	zr->buffer.base = (void *) vidmem;	zr->buffer.width = 0;	zr->buffer.height = 0;	zr->buffer.depth = 0;	zr->buffer.bytesperline = 0;	/* Avoid nonsense settings from user for default input/norm */	if (default_norm < VIDEO_MODE_PAL &&	    default_norm > VIDEO_MODE_SECAM)		default_norm = VIDEO_MODE_PAL;	zr->norm = default_norm;	if (!(zr->timing = zr->card.tvn[zr->norm])) {		dprintk(1,			KERN_WARNING			"%s: zr36057_init() - default TV standard not supported by hardware. PAL will be used.\n",			ZR_DEVNAME(zr));		zr->norm = VIDEO_MODE_PAL;		zr->timing = zr->card.tvn[zr->norm];	}	zr->input = default_input = (default_input ? 1 : 0);	/* Should the following be reset at every open ? */	zr->hue = 32768;	zr->contrast = 32768;	zr->saturation = 32768;	zr->brightness = 32768;	/* default setup (will be repeated at every open) */	zoran_open_init_params(zr);	/* allocate memory *before* doing anything to the hardware	 * in case allocation fails */	mem_needed = BUZ_NUM_STAT_COM * 4;	mem = (unsigned long) kmalloc(mem_needed, GFP_KERNEL);	vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);	if (!mem || !vdev) {		dprintk(1,			KERN_ERR			"%s: zr36057_init() - kmalloc (STAT_COM) failed\n",			ZR_DEVNAME(zr));		if (vdev)			kfree(vdev);		if (mem)			kfree((void *)mem);		return -ENOMEM;	}	memset((void *) mem, 0, mem_needed);	zr->stat_com = (u32 *) mem;	for (j = 0; j < BUZ_NUM_STAT_COM; j++) {		zr->stat_com[j] = 1;	/* mark as unavailable to zr36057 */	}	/*	 *   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;	}	zoran_init_hardware(zr);	if (*zr_debug > 2)		detect_guest_activity(zr);	test_interrupts(zr);	if (!pass_through) {		decoder_command(zr, DECODER_ENABLE_OUTPUT, &zero);		encoder_command(zr, ENCODER_SET_INPUT, &two);	}	zr->zoran_proc = NULL;	zr->initialized = 1;	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/2ea7533060e361810c21b2f5ee02151c4dfb85d8/zoran_card.c/clean/drivers/media/video/zoran_card.c