/* Sun May 11 12:34:56 UTC 2003 Clemens Ladisch  */
irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb *chip)
/* Sun May 11 12:34:56 UTC 2003 Clemens Ladisch  */
irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb *chip)
{
	struct snd_rawmidi *rmidi;
	int max = 64;
	char byte;
	if (!chip)
		return IRQ_NONE;
	rmidi = chip->rmidi;
	if (!rmidi) {
		inb(SBP(chip, DATA_AVAIL));
		return IRQ_NONE;
	}
	spin_lock(&chip->midi_input_lock);
	while (max-- > 0) {
		if (inb(SBP(chip, DATA_AVAIL)) & 0x80) {
			byte = inb(SBP(chip, READ));
			if (chip->open & SB_OPEN_MIDI_INPUT_TRIGGER) {
				snd_rawmidi_receive(chip->midi_substream_input, &byte, 1);
			}
		}
	}
	spin_unlock(&chip->midi_input_lock);
	return IRQ_HANDLED;
}