case SOUND_PCM_READ_CHANNELS: 
case SOUND_PCM_READ_CHANNELS: 
static int dsp_ioctl(struct inode *inode, struct file *file,		     unsigned int cmd, unsigned long arg){	struct saa7134_dev *dev = file->private_data;	void __user *argp = (void __user *) arg;	int __user *p = argp;	int val = 0;	if (oss_debug > 1)		saa7134_print_ioctl(dev->name,cmd);        switch (cmd) {        case OSS_GETVERSION:                return put_user(SOUND_VERSION, p);        case SNDCTL_DSP_GETCAPS:		return 0;        case SNDCTL_DSP_SPEED:		if (get_user(val, p))			return -EFAULT;		/* fall through */        case SOUND_PCM_READ_RATE:		return put_user(dev->oss.rate, p);        case SNDCTL_DSP_STEREO:		if (get_user(val, p))			return -EFAULT;		down(&dev->oss.lock);		dev->oss.channels = val ? 2 : 1;		if (dev->oss.recording_on) {			dsp_rec_stop(dev);			dsp_rec_start(dev);		}		up(&dev->oss.lock);		return put_user(dev->oss.channels-1, p);        case SNDCTL_DSP_CHANNELS:		if (get_user(val, p))			return -EFAULT;		if (val != 1 && val != 2)			return -EINVAL;		down(&dev->oss.lock);		dev->oss.channels = val;		if (dev->oss.recording_on) {			dsp_rec_stop(dev);			dsp_rec_start(dev);		}		up(&dev->oss.lock);		/* fall through */        case SOUND_PCM_READ_CHANNELS:		return put_user(dev->oss.channels, p);        case SNDCTL_DSP_GETFMTS: /* Returns a mask */		return put_user(AFMT_U8     | AFMT_S8     |				AFMT_U16_LE | AFMT_U16_BE |				AFMT_S16_LE | AFMT_S16_BE, p);        case SNDCTL_DSP_SETFMT: /* Selects ONE fmt */		if (get_user(val, p))			return -EFAULT;		switch (val) {		case AFMT_QUERY:			/* nothing to do */			break;		case AFMT_U8:		case AFMT_S8:		case AFMT_U16_LE:		case AFMT_U16_BE:		case AFMT_S16_LE:		case AFMT_S16_BE:			down(&dev->oss.lock);			dev->oss.afmt = val;			if (dev->oss.recording_on) {				dsp_rec_stop(dev);				dsp_rec_start(dev);			}			up(&dev->oss.lock);			return put_user(dev->oss.afmt, p);		default:			return -EINVAL;		}        case SOUND_PCM_READ_BITS:		switch (dev->oss.afmt) {		case AFMT_U8:		case AFMT_S8:			return put_user(8, p);		case AFMT_U16_LE:		case AFMT_U16_BE:		case AFMT_S16_LE:		case AFMT_S16_BE:			return put_user(16, p);		default:			return -EINVAL;		}        case SNDCTL_DSP_NONBLOCK:                file->f_flags |= O_NONBLOCK;                return 0;        case SNDCTL_DSP_RESET:		down(&dev->oss.lock);		if (dev->oss.recording_on)			dsp_rec_stop(dev);		up(&dev->oss.lock);		return 0;        case SNDCTL_DSP_GETBLKSIZE:		return put_user(dev->oss.blksize, p);        case SNDCTL_DSP_SETFRAGMENT:		if (get_user(val, p))			return -EFAULT;		if (dev->oss.recording_on)			return -EBUSY;		dsp_buffer_free(dev);		/* used to be arg >> 16 instead of val >> 16; fixed */		dsp_buffer_conf(dev,1 << (val & 0xffff), (val >> 16) & 0xffff);		dsp_buffer_init(dev);		return 0;        case SNDCTL_DSP_SYNC:		/* NOP */		return 0;	case SNDCTL_DSP_GETISPACE:	{		audio_buf_info info;		info.fragsize   = dev->oss.blksize;		info.fragstotal = dev->oss.blocks;		info.bytes      = dev->oss.read_count;		info.fragments  = info.bytes / info.fragsize;		if (copy_to_user(argp, &info, sizeof(info)))			return -EFAULT;		return 0;	}	default:		return -EINVAL;	}}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/4ac97914c6c35f6bf132071c718e034d0846b9f5/saa7134-oss.c/buggy/drivers/media/video/saa7134/saa7134-oss.c