if ((file->f_flags & O_APPEND) || maj != CONFIG_SND_MAJOR) /* OSS emul? */ 
if ((file->f_flags & O_APPEND) || maj == SOUND_MAJOR) /* OSS emul? */ 
static int snd_rawmidi_open(struct inode *inode, struct file *file){	int maj = imajor(inode);	int cardnum;	snd_card_t *card;	int device, subdevice;	unsigned short fflags;	int err;	snd_rawmidi_t *rmidi;	snd_rawmidi_file_t *rawmidi_file;	wait_queue_t wait;	struct list_head *list;	snd_ctl_file_t *kctl;	switch (maj) {	case CONFIG_SND_MAJOR:		cardnum = SNDRV_MINOR_CARD(iminor(inode));		cardnum %= SNDRV_CARDS;		device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_RAWMIDI;		device %= SNDRV_MINOR_RAWMIDIS;		break;#ifdef CONFIG_SND_OSSEMUL	case SOUND_MAJOR:		cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));		cardnum %= SNDRV_CARDS;		device = SNDRV_MINOR_OSS_DEVICE(iminor(inode)) == SNDRV_MINOR_OSS_MIDI ?			midi_map[cardnum] : amidi_map[cardnum];		break;#endif	default:		return -ENXIO;	}	rmidi = snd_rawmidi_devices[(cardnum * SNDRV_RAWMIDI_DEVICES) + device];	if (rmidi == NULL)		return -ENODEV;#ifdef CONFIG_SND_OSSEMUL	if (maj == SOUND_MAJOR && !rmidi->ossreg)		return -ENXIO;#endif	if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK)) 		return -EINVAL;		/* invalid combination */	card = rmidi->card;	err = snd_card_file_add(card, file);	if (err < 0)		return -ENODEV;	fflags = snd_rawmidi_file_flags(file);	if ((file->f_flags & O_APPEND) || maj != CONFIG_SND_MAJOR) /* OSS emul? */		fflags |= SNDRV_RAWMIDI_LFLG_APPEND;	fflags |= SNDRV_RAWMIDI_LFLG_NOOPENLOCK;	rawmidi_file = kmalloc(sizeof(*rawmidi_file), GFP_KERNEL);	if (rawmidi_file == NULL) {		snd_card_file_remove(card, file);		return -ENOMEM;	}	init_waitqueue_entry(&wait, current);	add_wait_queue(&rmidi->open_wait, &wait);	down(&rmidi->open_mutex);	while (1) {		subdevice = -1;		down_read(&card->controls_rwsem);		list_for_each(list, &card->ctl_files) {			kctl = snd_ctl_file(list);			if (kctl->pid == current->pid) {				subdevice = kctl->prefer_rawmidi_subdevice;				break;			}		}		up_read(&card->controls_rwsem);		err = snd_rawmidi_kernel_open(cardnum, device, subdevice, fflags, rawmidi_file);		if (err >= 0)			break;		if (err == -EAGAIN) {			if (file->f_flags & O_NONBLOCK) {				err = -EBUSY;				break;			}		} else			break;		set_current_state(TASK_INTERRUPTIBLE);		up(&rmidi->open_mutex);		schedule();		down(&rmidi->open_mutex);		if (signal_pending(current)) {			err = -ERESTARTSYS;			break;		}	}#ifdef CONFIG_SND_OSSEMUL	if (rawmidi_file->input && rawmidi_file->input->runtime)		rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR);	if (rawmidi_file->output && rawmidi_file->output->runtime)		rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR);#endif	remove_wait_queue(&rmidi->open_wait, &wait);	if (err >= 0) {		file->private_data = rawmidi_file;	} else {		snd_card_file_remove(card, file);		kfree(rawmidi_file);	}	up(&rmidi->open_mutex);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/f1902860161ff212c515e7ea629e880fec856a37/rawmidi.c/buggy/sound/core/rawmidi.c