^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Line 6 Linux USB driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "midibuf.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) static int midibuf_message_length(unsigned char code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) int message_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) if (code < 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) message_length = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) else if (code < 0xf0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static const int length[] = { 3, 3, 3, 3, 2, 2, 3 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) message_length = length[(code >> 4) - 8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) Note that according to the MIDI specification 0xf2 is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) the "Song Position Pointer", but this is used by Line 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) to send sysex messages to the host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static const int length[] = { -1, 2, -1, 2, -1, -1, 1, 1, 1, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 1, 1, 1, -1, 1, 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) message_length = length[code & 0x0f];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) return message_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static int midibuf_is_empty(struct midi_buffer *this)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) return (this->pos_read == this->pos_write) && !this->full;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static int midibuf_is_full(struct midi_buffer *this)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return this->full;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) void line6_midibuf_reset(struct midi_buffer *this)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) this->pos_read = this->pos_write = this->full = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) this->command_prev = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int line6_midibuf_init(struct midi_buffer *this, int size, int split)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) this->buf = kmalloc(size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) if (this->buf == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) this->size = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) this->split = split;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) line6_midibuf_reset(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int line6_midibuf_bytes_free(struct midi_buffer *this)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) midibuf_is_full(this) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 0 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) (this->pos_read - this->pos_write + this->size - 1) % this->size +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int line6_midibuf_bytes_used(struct midi_buffer *this)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) midibuf_is_empty(this) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 0 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) (this->pos_write - this->pos_read + this->size - 1) % this->size +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int line6_midibuf_write(struct midi_buffer *this, unsigned char *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int bytes_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int length1, length2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) int skip_active_sense = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (midibuf_is_full(this) || (length <= 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /* skip trailing active sense */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (data[length - 1] == 0xfe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) --length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) skip_active_sense = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) bytes_free = line6_midibuf_bytes_free(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (length > bytes_free)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) length = bytes_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (length > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) length1 = this->size - this->pos_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) if (length < length1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* no buffer wraparound */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) memcpy(this->buf + this->pos_write, data, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) this->pos_write += length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* buffer wraparound */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) length2 = length - length1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) memcpy(this->buf + this->pos_write, data, length1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) memcpy(this->buf, data + length1, length2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) this->pos_write = length2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (this->pos_write == this->pos_read)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) this->full = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) return length + skip_active_sense;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int line6_midibuf_read(struct midi_buffer *this, unsigned char *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int bytes_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int length1, length2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int midi_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int repeat = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* we need to be able to store at least a 3 byte MIDI message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (length < 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (midibuf_is_empty(this))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) bytes_used = line6_midibuf_bytes_used(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (length > bytes_used)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) length = bytes_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) length1 = this->size - this->pos_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* check MIDI command length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) command = this->buf[this->pos_read];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (command & 0x80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) midi_length = midibuf_message_length(command);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) this->command_prev = command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) if (this->command_prev > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) int midi_length_prev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) midibuf_message_length(this->command_prev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (midi_length_prev > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) midi_length = midi_length_prev - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) repeat = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) midi_length = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) midi_length = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (midi_length < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /* search for end of message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (length < length1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* no buffer wraparound */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) for (i = 1; i < length; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (this->buf[this->pos_read + i] & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) midi_length = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /* buffer wraparound */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) length2 = length - length1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) for (i = 1; i < length1; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (this->buf[this->pos_read + i] & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (i < length1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) midi_length = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) for (i = 0; i < length2; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (this->buf[i] & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) midi_length = length1 + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (midi_length == length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) midi_length = -1; /* end of message not found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (midi_length < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (!this->split)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return 0; /* command is not yet complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (length < midi_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return 0; /* command is not yet complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) length = midi_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (length < length1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /* no buffer wraparound */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) memcpy(data + repeat, this->buf + this->pos_read, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) this->pos_read += length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /* buffer wraparound */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) length2 = length - length1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) memcpy(data + repeat, this->buf + this->pos_read, length1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) memcpy(data + repeat + length1, this->buf, length2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) this->pos_read = length2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (repeat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) data[0] = this->command_prev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) this->full = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) return length + repeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) int line6_midibuf_ignore(struct midi_buffer *this, int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) int bytes_used = line6_midibuf_bytes_used(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (length > bytes_used)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) length = bytes_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) this->pos_read = (this->pos_read + length) % this->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) this->full = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) return length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) void line6_midibuf_destroy(struct midi_buffer *this)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) kfree(this->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) this->buf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }