} else { switch (quirk->type) { case QUIRK_MIDI_FIXED_ENDPOINT: memcpy(&endpoints[0], quirk->data, sizeof(snd_usb_midi_endpoint_info_t)); err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1); break; case QUIRK_MIDI_YAMAHA: err = snd_usbmidi_detect_yamaha(umidi, &endpoints[0]); break; case QUIRK_MIDI_MIDIMAN: umidi->usb_protocol_ops = &snd_usbmidi_midiman_ops; memcpy(&endpoints[0], quirk->data, sizeof(snd_usb_midi_endpoint_info_t)); err = 0; break; case QUIRK_MIDI_NOVATION: umidi->usb_protocol_ops = &snd_usbmidi_novation_ops; err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); break; case QUIRK_MIDI_RAW: umidi->usb_protocol_ops = &snd_usbmidi_raw_ops; err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); break; case QUIRK_MIDI_EMAGIC: umidi->usb_protocol_ops = &snd_usbmidi_emagic_ops; memcpy(&endpoints[0], quirk->data, sizeof(snd_usb_midi_endpoint_info_t)); err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1); break; case QUIRK_MIDI_MIDITECH: err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); break; default: snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type); err = -ENXIO; break; } 
break; case QUIRK_MIDI_FIXED_ENDPOINT: memcpy(&endpoints[0], quirk->data, sizeof(snd_usb_midi_endpoint_info_t)); err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1); break; case QUIRK_MIDI_YAMAHA: err = snd_usbmidi_detect_yamaha(umidi, &endpoints[0]); break; case QUIRK_MIDI_MIDIMAN: umidi->usb_protocol_ops = &snd_usbmidi_midiman_ops; memcpy(&endpoints[0], quirk->data, sizeof(snd_usb_midi_endpoint_info_t)); err = 0; break; case QUIRK_MIDI_NOVATION: umidi->usb_protocol_ops = &snd_usbmidi_novation_ops; err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); break; case QUIRK_MIDI_RAW: umidi->usb_protocol_ops = &snd_usbmidi_raw_ops; err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); break; case QUIRK_MIDI_EMAGIC: umidi->usb_protocol_ops = &snd_usbmidi_emagic_ops; memcpy(&endpoints[0], quirk->data, sizeof(snd_usb_midi_endpoint_info_t)); err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1); break; case QUIRK_MIDI_MIDITECH: err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); break; default: snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type); err = -ENXIO; break; 
int snd_usb_create_midi_interface(snd_usb_audio_t* chip,				  struct usb_interface* iface,				  const snd_usb_audio_quirk_t* quirk){	snd_usb_midi_t* umidi;	snd_usb_midi_endpoint_info_t endpoints[MIDI_MAX_ENDPOINTS];	int out_ports, in_ports;	int i, err;	umidi = kzalloc(sizeof(*umidi), GFP_KERNEL);	if (!umidi)		return -ENOMEM;	umidi->chip = chip;	umidi->iface = iface;	umidi->quirk = quirk;	umidi->usb_protocol_ops = &snd_usbmidi_standard_ops;	init_timer(&umidi->error_timer);	umidi->error_timer.function = snd_usbmidi_error_timer;	umidi->error_timer.data = (unsigned long)umidi;	/* detect the endpoint(s) to use */	memset(endpoints, 0, sizeof(endpoints));	if (!quirk) {		err = snd_usbmidi_get_ms_info(umidi, endpoints);	} else {		switch (quirk->type) {		case QUIRK_MIDI_FIXED_ENDPOINT:			memcpy(&endpoints[0], quirk->data,			       sizeof(snd_usb_midi_endpoint_info_t));			err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1);			break;		case QUIRK_MIDI_YAMAHA:			err = snd_usbmidi_detect_yamaha(umidi, &endpoints[0]);			break;		case QUIRK_MIDI_MIDIMAN:			umidi->usb_protocol_ops = &snd_usbmidi_midiman_ops;			memcpy(&endpoints[0], quirk->data,			       sizeof(snd_usb_midi_endpoint_info_t));			err = 0;			break;		case QUIRK_MIDI_NOVATION:			umidi->usb_protocol_ops = &snd_usbmidi_novation_ops;			err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);			break;		case QUIRK_MIDI_RAW:			umidi->usb_protocol_ops = &snd_usbmidi_raw_ops;			err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);			break;		case QUIRK_MIDI_EMAGIC:			umidi->usb_protocol_ops = &snd_usbmidi_emagic_ops;			memcpy(&endpoints[0], quirk->data,			       sizeof(snd_usb_midi_endpoint_info_t));			err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1);			break;		case QUIRK_MIDI_MIDITECH:			err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);			break;		default:			snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);			err = -ENXIO;			break;		}	}	if (err < 0) {		kfree(umidi);		return err;	}	/* create rawmidi device */	out_ports = 0;	in_ports = 0;	for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {		out_ports += snd_usbmidi_count_bits(endpoints[i].out_cables);		in_ports += snd_usbmidi_count_bits(endpoints[i].in_cables);	}	err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports);	if (err < 0) {		kfree(umidi);		return err;	}	/* create endpoint/port structures */	if (quirk && quirk->type == QUIRK_MIDI_MIDIMAN)		err = snd_usbmidi_create_endpoints_midiman(umidi, &endpoints[0]);	else		err = snd_usbmidi_create_endpoints(umidi, endpoints);	if (err < 0) {		snd_usbmidi_free(umidi);		return err;	}	list_add(&umidi->list, &umidi->chip->midi_list);	for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)		snd_usbmidi_input_start_ep(umidi->endpoints[i].in);	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/d1bda0455478a9e2a13381044e9bb80a17ec92d2/usbmidi.c/buggy/sound/usb/usbmidi.c