/* Spaceball 4000 FLX packets all start with a one letter packet-type decriptor, and end in 0x0d. It uses '^' as an escape for CR, XOFF and XON characters which can occur in the axis values.  */
static irqreturn_t spaceball_interrupt(struct serio *serio, unsigned char data, unsigned int flags)
/* Spaceball 4000 FLX packets all start with a one letter packet-type decriptor, and end in 0x0d. It uses '^' as an escape for CR, XOFF and XON characters which can occur in the axis values.  */
static irqreturn_t spaceball_interrupt(struct serio *serio, unsigned char data, unsigned int flags)
{
	struct spaceball *spaceball = serio_get_drvdata(serio);
	switch (data) {
		case 0xd:
			spaceball_process_packet(spaceball);
			spaceball->idx = 0;
			spaceball->escape = 0;
			break;
		case '^':
			if (!spaceball->escape) {
				spaceball->escape = 1;
				break;
			}
			spaceball->escape = 0;
		case 'M':
		case 'Q':
		case 'S':
			if (spaceball->escape) {
				spaceball->escape = 0;
				data &= 0x1f;
			}
		default:
			if (spaceball->escape)
				spaceball->escape = 0;
			if (spaceball->idx < SPACEBALL_MAX_LENGTH)
				spaceball->data[spaceball->idx++] = data;
			break;
	}
	return IRQ_HANDLED;
}