Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e6a8ffb authored by Stefan Hajnoczi's avatar Stefan Hajnoczi Committed by Greg Kroah-Hartman
Browse files

staging: line6: clean up line6_pod_process_message()



Previous versions of the line6 driver snooped MIDI traffic in order to
make device state accessible via sysfs attributes.  This involved a lot
of logic in line6_pod_process_message() that has since been removed.

Drop unused conditionals in line6_pod_process_message() and reduce the
levels of indentation.  Only two MIDI messages are still tracked: the
POD version message on startup and monitor level changes originating
from the device.

Signed-off-by: default avatarStefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 98115f1d
Loading
Loading
Loading
Loading
+19 −77
Original line number Original line Diff line number Diff line
@@ -135,85 +135,27 @@ void line6_pod_process_message(struct usb_line6_pod *pod)
{
{
	const unsigned char *buf = pod->line6.buffer_message;
	const unsigned char *buf = pod->line6.buffer_message;


	/* filter messages by type */
	if (memcmp(buf, pod_version_header, sizeof(pod_version_header)) == 0) {
	switch (buf[0] & 0xf0) {
		pod->firmware_version = buf[13] * 100 + buf[14] * 10 + buf[15];
	case LINE6_PARAM_CHANGE:
		pod->device_id = ((int)buf[8] << 16) | ((int)buf[9] << 8) |
	case LINE6_PROGRAM_CHANGE:
				 (int) buf[10];
	case LINE6_SYSEX_BEGIN:
		pod_startup3(pod);
		break;		/* handle these further down */
		return;

	default:
		return;		/* ignore all others */
	}
	}


	/* process all remaining messages */
	/* Only look for sysex messages from this device */
	switch (buf[0]) {
	if (buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE) &&
	case LINE6_PARAM_CHANGE | LINE6_CHANNEL_DEVICE:
	    buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN)) {
	case LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST:
		return;
		break;

	case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE:
	case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST:
		break;

	case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE:
	case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN:
		if (memcmp(buf + 1, line6_midi_id,
			   sizeof(line6_midi_id)) == 0) {
			switch (buf[5]) {
			case POD_SYSEX_DUMP:
				break;

			case POD_SYSEX_SYSTEM:{
					short value =
					    ((int)buf[7] << 12) | ((int)buf[8]
								   << 8) |
					    ((int)buf[9] << 4) | (int)buf[10];

					if (buf[6] == POD_MONITOR_LEVEL)
						pod->monitor_level = value;
					break;
	}
	}

	if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) != 0) {
			case POD_SYSEX_FINISH:
		return;
				/* do we need to respond to this? */
				break;

			case POD_SYSEX_SAVE:
				break;

			case POD_SYSEX_STORE:
				dev_dbg(pod->line6.ifcdev,
					"message %02X not yet implemented\n",
					buf[5]);
				break;

			default:
				dev_dbg(pod->line6.ifcdev,
					"unknown sysex message %02X\n",
					buf[5]);
	}
	}
		} else
		    if (memcmp
			(buf, pod_version_header,
			 sizeof(pod_version_header)) == 0) {
			pod->firmware_version =
			    buf[13] * 100 + buf[14] * 10 + buf[15];
			pod->device_id =
			    ((int)buf[8] << 16) | ((int)buf[9] << 8) | (int)
			    buf[10];
			pod_startup3(pod);
		} else
			dev_dbg(pod->line6.ifcdev, "unknown sysex header\n");


		break;
	if (buf[5] == POD_SYSEX_SYSTEM && buf[6] == POD_MONITOR_LEVEL) {

		short value = ((int)buf[7] << 12) | ((int)buf[8] << 8) |
	case LINE6_SYSEX_END:
			      ((int)buf[9] << 4) | (int)buf[10];
		break;
		pod->monitor_level = value;

	default:
		dev_dbg(pod->line6.ifcdev, "POD: unknown message %02X\n",
			buf[0]);
	}
	}
}
}