 spin_lock_irqsave(&zr->spinlock, flags); 
zoran_jpg_queue_frame (struct file          *file,		       int                   num,		       enum zoran_codec_mode mode){	struct zoran_fh *fh = file->private_data;	struct zoran *zr = fh->zr;	unsigned long flags;	int res = 0;	/* Check if buffers are allocated */	if (!fh->jpg_buffers.allocated) {		dprintk(1,			KERN_ERR			"%s: jpg_queue_frame() - buffers not yet allocated\n",			ZR_DEVNAME(zr));		return -ENOMEM;	}	/* No grabbing outside the buffer range! */	if (num >= fh->jpg_buffers.num_buffers || num < 0) {		dprintk(1,			KERN_ERR			"%s: jpg_queue_frame() - buffer %d out of range\n",			ZR_DEVNAME(zr), num);		return -EINVAL;	}	/* what is the codec mode right now? */	if (zr->codec_mode == BUZ_MODE_IDLE) {		zr->jpg_settings = fh->jpg_settings;	} else if (zr->codec_mode != mode) {		/* wrong codec mode active - invalid */		dprintk(1,			KERN_ERR			"%s: jpg_queue_frame() - codec in wrong mode\n",			ZR_DEVNAME(zr));		return -EINVAL;	}	spin_lock_irqsave(&zr->spinlock, flags);	if (fh->jpg_buffers.active == ZORAN_FREE) {		if (zr->jpg_buffers.active == ZORAN_FREE) {			zr->jpg_buffers = fh->jpg_buffers;			fh->jpg_buffers.active = ZORAN_ACTIVE;		} else {			dprintk(1,				KERN_ERR				"%s: jpg_queue_frame() - another session is already capturing\n",				ZR_DEVNAME(zr));			res = -EBUSY;		}	}	if (!res && zr->codec_mode == BUZ_MODE_IDLE) {		/* Ok load up the jpeg codec */		zr36057_enable_jpg(zr, mode);	}	if (!res) {		switch (zr->jpg_buffers.buffer[num].state) {		case BUZ_STATE_DONE:			dprintk(2,				KERN_WARNING				"%s: jpg_queue_frame() - queing frame in BUZ_STATE_DONE state!?\n",				ZR_DEVNAME(zr));		case BUZ_STATE_USER:			/* since there is at least one unused buffer there's room for at			 *least one more pend[] entry */			zr->jpg_pend[zr->jpg_que_head++ & BUZ_MASK_FRAME] =			    num;			zr->jpg_buffers.buffer[num].state = BUZ_STATE_PEND;			fh->jpg_buffers.buffer[num] =			    zr->jpg_buffers.buffer[num];			zoran_feed_stat_com(zr);			break;		default:		case BUZ_STATE_DMA:		case BUZ_STATE_PEND:			if (zr->jpg_buffers.active == ZORAN_FREE) {				fh->jpg_buffers.active = ZORAN_FREE;				zr->jpg_buffers.allocated = 0;			}			res = -EBUSY;	/* what are you doing? */			break;		}	}	spin_unlock_irqrestore(&zr->spinlock, flags);	if (!res && zr->jpg_buffers.active == ZORAN_FREE) {		zr->jpg_buffers.active = fh->jpg_buffers.active;	}	return res;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/8bc3efcfbf6521ec7bf3e5d969b31745fbd986f8/zoran_driver.c/buggy/drivers/media/video/zoran_driver.c