data_end = data_ptr + LE_INT(file_h.len); 
data_end = data_ptr + le32_to_cpu(file_h.len); 
static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user * mcode){	snd_sb_csp_mc_header_t info;	unsigned char __user *data_ptr;	unsigned char __user *data_end;	unsigned short func_nr = 0;	riff_header_t file_h, item_h, code_h;	__u32 item_type;	desc_header_t funcdesc_h;	unsigned long flags;	int err;	if (copy_from_user(&info, mcode, sizeof(info)))		return -EFAULT;	data_ptr = mcode->data;	if (copy_from_user(&file_h, data_ptr, sizeof(file_h)))		return -EFAULT;	if ((file_h.name != RIFF_HEADER) ||	    (LE_INT(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) {		snd_printd("%s: Invalid RIFF header\n", __FUNCTION__);		return -EINVAL;	}	data_ptr += sizeof(file_h);	data_end = data_ptr + LE_INT(file_h.len);	if (copy_from_user(&item_type, data_ptr, sizeof(item_type)))		return -EFAULT;	if (item_type != CSP__HEADER) {		snd_printd("%s: Invalid RIFF file type\n", __FUNCTION__);		return -EINVAL;	}	data_ptr += sizeof (item_type);	for (; data_ptr < data_end; data_ptr += LE_INT(item_h.len)) {		if (copy_from_user(&item_h, data_ptr, sizeof(item_h)))			return -EFAULT;		data_ptr += sizeof(item_h);		if (item_h.name != LIST_HEADER)			continue;		if (copy_from_user(&item_type, data_ptr, sizeof(item_type)))			 return -EFAULT;		switch (item_type) {		case FUNC_HEADER:			if (copy_from_user(&funcdesc_h, data_ptr + sizeof(item_type), sizeof(funcdesc_h)))				return -EFAULT;			func_nr = LE_SHORT(funcdesc_h.func_nr);			break;		case CODE_HEADER:			if (func_nr != info.func_req)				break;	/* not required function, try next */			data_ptr += sizeof(item_type);			/* destroy QSound mixer element */			if (p->mode == SNDRV_SB_CSP_MODE_QSOUND) {				snd_sb_qsound_destroy(p);			}			/* Clear all flags */			p->running = 0;			p->mode = 0;			/* load microcode blocks */			for (;;) {				if (data_ptr >= data_end)					return -EINVAL;				if (copy_from_user(&code_h, data_ptr, sizeof(code_h)))					return -EFAULT;				/* init microcode blocks */				if (code_h.name != INIT_HEADER)					break;				data_ptr += sizeof(code_h);				err = snd_sb_csp_load_user(p, data_ptr, LE_INT(code_h.len),						      SNDRV_SB_CSP_LOAD_INITBLOCK);				if (err)					return err;				data_ptr += LE_INT(code_h.len);			}			/* main microcode block */			if (copy_from_user(&code_h, data_ptr, sizeof(code_h)))				return -EFAULT;			if (code_h.name != MAIN_HEADER) {				snd_printd("%s: Missing 'main' microcode\n", __FUNCTION__);				return -EINVAL;			}			data_ptr += sizeof(code_h);			err = snd_sb_csp_load_user(p, data_ptr,						   LE_INT(code_h.len), 0);			if (err)				return err;			/* fill in codec header */			strlcpy(p->codec_name, info.codec_name, sizeof(p->codec_name));			p->func_nr = func_nr;			p->mode = LE_SHORT(funcdesc_h.flags_play_rec);			switch (LE_SHORT(funcdesc_h.VOC_type)) {			case 0x0001:	/* QSound decoder */				if (LE_SHORT(funcdesc_h.flags_play_rec) == SNDRV_SB_CSP_MODE_DSP_WRITE) {					if (snd_sb_qsound_build(p) == 0)						/* set QSound flag and clear all other mode flags */						p->mode = SNDRV_SB_CSP_MODE_QSOUND;				}				p->acc_format = 0;				break;			case 0x0006:	/* A Law codec */				p->acc_format = SNDRV_PCM_FMTBIT_A_LAW;				break;			case 0x0007:	/* Mu Law codec */				p->acc_format = SNDRV_PCM_FMTBIT_MU_LAW;				break;			case 0x0011:	/* what Creative thinks is IMA ADPCM codec */			case 0x0200:	/* Creative ADPCM codec */				p->acc_format = SNDRV_PCM_FMTBIT_IMA_ADPCM;				break;			case    201:	/* Text 2 Speech decoder */				/* TODO: Text2Speech handling routines */				p->acc_format = 0;				break;			case 0x0202:	/* Fast Speech 8 codec */			case 0x0203:	/* Fast Speech 10 codec */				p->acc_format = SNDRV_PCM_FMTBIT_SPECIAL;				break;			default:	/* other codecs are unsupported */				p->acc_format = p->acc_width = p->acc_rates = 0;				p->mode = 0;				snd_printd("%s: Unsupported CSP codec type: 0x%04x\n",					   __FUNCTION__,					   LE_SHORT(funcdesc_h.VOC_type));				return -EINVAL;			}			p->acc_channels = LE_SHORT(funcdesc_h.flags_stereo_mono);			p->acc_width = LE_SHORT(funcdesc_h.flags_16bit_8bit);			p->acc_rates = LE_SHORT(funcdesc_h.flags_rates);			/* Decouple CSP from IRQ and DMAREQ lines */			spin_lock_irqsave(&p->chip->reg_lock, flags);			set_mode_register(p->chip, 0xfc);			set_mode_register(p->chip, 0x00);			spin_unlock_irqrestore(&p->chip->reg_lock, flags);			/* finished loading successfully */			p->running = SNDRV_SB_CSP_ST_LOADED;	/* set LOADED flag */			return 0;		}	}	snd_printd("%s: Function #%d not found\n", __FUNCTION__, info.func_req);	return -EINVAL;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/31bbf8f5d55c706f2e429f7cfa7b339a332e785e/sb16_csp.c/clean/sound/isa/sb/sb16_csp.c