Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: msnd: Remove midi code

Nothing calls snd_msndmidi_new()
thus nothing sets chip->msndmidi_mpu
The call to snd_msndmidi_input_read is gated on that being set,
so snd_msndmidi_input_read() won't be called either.

This is probably a missing call to snd_msndmidi_new(), but since
this is ancient code, it's probably best to remove it (especially
since I don't have the hardware to test it).

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Link: https://patch.msgid.link/20250511172957.1001583-1-linux@treblig.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Dr. David Alan Gilbert and committed by
Takashi Iwai
174d9664 b95a1e89

+1 -173
+1 -1
sound/isa/msnd/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - snd-msnd-lib-y := msnd.o msnd_midi.o msnd_pinnacle_mixer.o 3 + snd-msnd-lib-y := msnd.o msnd_pinnacle_mixer.o 4 4 snd-msnd-pinnacle-y := msnd_pinnacle.o 5 5 snd-msnd-classic-y := msnd_classic.o 6 6
-4
sound/isa/msnd/msnd.h
··· 216 216 int captureLimit; 217 217 int capturePeriods; 218 218 struct snd_card *card; 219 - void *msndmidi_mpu; 220 219 struct snd_rawmidi *rmidi; 221 220 222 221 /* Hardware resources */ ··· 284 285 int snd_msnd_DAPQ(struct snd_msnd *chip, int start); 285 286 int snd_msnd_DARQ(struct snd_msnd *chip, int start); 286 287 int snd_msnd_pcm(struct snd_card *card, int device); 287 - 288 - int snd_msndmidi_new(struct snd_card *card, int device); 289 - void snd_msndmidi_input_read(void *mpu); 290 288 291 289 void snd_msndmix_setup(struct snd_msnd *chip); 292 290 int snd_msndmix_new(struct snd_card *card);
-163
sound/isa/msnd/msnd_midi.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 4 - * Copyright (c) 2009 by Krzysztof Helt 5 - * Routines for control of MPU-401 in UART mode 6 - * 7 - * MPU-401 supports UART mode which is not capable generate transmit 8 - * interrupts thus output is done via polling. Also, if irq < 0, then 9 - * input is done also via polling. Do not expect good performance. 10 - */ 11 - 12 - #include <linux/io.h> 13 - #include <linux/slab.h> 14 - #include <linux/delay.h> 15 - #include <linux/ioport.h> 16 - #include <linux/errno.h> 17 - #include <linux/export.h> 18 - #include <sound/core.h> 19 - #include <sound/rawmidi.h> 20 - 21 - #include "msnd.h" 22 - 23 - #define MSNDMIDI_MODE_BIT_INPUT 0 24 - #define MSNDMIDI_MODE_BIT_OUTPUT 1 25 - #define MSNDMIDI_MODE_BIT_INPUT_TRIGGER 2 26 - #define MSNDMIDI_MODE_BIT_OUTPUT_TRIGGER 3 27 - 28 - struct snd_msndmidi { 29 - struct snd_msnd *dev; 30 - 31 - unsigned long mode; /* MSNDMIDI_MODE_XXXX */ 32 - 33 - struct snd_rawmidi_substream *substream_input; 34 - 35 - spinlock_t input_lock; 36 - }; 37 - 38 - /* 39 - * input/output open/close - protected by open_mutex in rawmidi.c 40 - */ 41 - static int snd_msndmidi_input_open(struct snd_rawmidi_substream *substream) 42 - { 43 - struct snd_msndmidi *mpu; 44 - 45 - mpu = substream->rmidi->private_data; 46 - 47 - mpu->substream_input = substream; 48 - 49 - snd_msnd_enable_irq(mpu->dev); 50 - 51 - snd_msnd_send_dsp_cmd(mpu->dev, HDEX_MIDI_IN_START); 52 - set_bit(MSNDMIDI_MODE_BIT_INPUT, &mpu->mode); 53 - return 0; 54 - } 55 - 56 - static int snd_msndmidi_input_close(struct snd_rawmidi_substream *substream) 57 - { 58 - struct snd_msndmidi *mpu; 59 - 60 - mpu = substream->rmidi->private_data; 61 - snd_msnd_send_dsp_cmd(mpu->dev, HDEX_MIDI_IN_STOP); 62 - clear_bit(MSNDMIDI_MODE_BIT_INPUT, &mpu->mode); 63 - mpu->substream_input = NULL; 64 - snd_msnd_disable_irq(mpu->dev); 65 - return 0; 66 - } 67 - 68 - static void snd_msndmidi_input_drop(struct snd_msndmidi *mpu) 69 - { 70 - u16 tail; 71 - 72 - tail = readw(mpu->dev->MIDQ + JQS_wTail); 73 - writew(tail, mpu->dev->MIDQ + JQS_wHead); 74 - } 75 - 76 - /* 77 - * trigger input 78 - */ 79 - static void snd_msndmidi_input_trigger(struct snd_rawmidi_substream *substream, 80 - int up) 81 - { 82 - unsigned long flags; 83 - struct snd_msndmidi *mpu; 84 - 85 - mpu = substream->rmidi->private_data; 86 - spin_lock_irqsave(&mpu->input_lock, flags); 87 - if (up) { 88 - if (!test_and_set_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER, 89 - &mpu->mode)) 90 - snd_msndmidi_input_drop(mpu); 91 - } else { 92 - clear_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER, &mpu->mode); 93 - } 94 - spin_unlock_irqrestore(&mpu->input_lock, flags); 95 - if (up) 96 - snd_msndmidi_input_read(mpu); 97 - } 98 - 99 - void snd_msndmidi_input_read(void *mpuv) 100 - { 101 - unsigned long flags; 102 - struct snd_msndmidi *mpu = mpuv; 103 - void __iomem *pwMIDQData = mpu->dev->mappedbase + MIDQ_DATA_BUFF; 104 - u16 head, tail, size; 105 - 106 - spin_lock_irqsave(&mpu->input_lock, flags); 107 - head = readw(mpu->dev->MIDQ + JQS_wHead); 108 - tail = readw(mpu->dev->MIDQ + JQS_wTail); 109 - size = readw(mpu->dev->MIDQ + JQS_wSize); 110 - if (head > size || tail > size) 111 - goto out; 112 - while (head != tail) { 113 - unsigned char val = readw(pwMIDQData + 2 * head); 114 - 115 - if (test_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER, &mpu->mode)) 116 - snd_rawmidi_receive(mpu->substream_input, &val, 1); 117 - if (++head > size) 118 - head = 0; 119 - writew(head, mpu->dev->MIDQ + JQS_wHead); 120 - } 121 - out: 122 - spin_unlock_irqrestore(&mpu->input_lock, flags); 123 - } 124 - EXPORT_SYMBOL(snd_msndmidi_input_read); 125 - 126 - static const struct snd_rawmidi_ops snd_msndmidi_input = { 127 - .open = snd_msndmidi_input_open, 128 - .close = snd_msndmidi_input_close, 129 - .trigger = snd_msndmidi_input_trigger, 130 - }; 131 - 132 - static void snd_msndmidi_free(struct snd_rawmidi *rmidi) 133 - { 134 - struct snd_msndmidi *mpu = rmidi->private_data; 135 - kfree(mpu); 136 - } 137 - 138 - int snd_msndmidi_new(struct snd_card *card, int device) 139 - { 140 - struct snd_msnd *chip = card->private_data; 141 - struct snd_msndmidi *mpu; 142 - struct snd_rawmidi *rmidi; 143 - int err; 144 - 145 - err = snd_rawmidi_new(card, "MSND-MIDI", device, 1, 1, &rmidi); 146 - if (err < 0) 147 - return err; 148 - mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); 149 - if (mpu == NULL) { 150 - snd_device_free(card, rmidi); 151 - return -ENOMEM; 152 - } 153 - mpu->dev = chip; 154 - chip->msndmidi_mpu = mpu; 155 - rmidi->private_data = mpu; 156 - rmidi->private_free = snd_msndmidi_free; 157 - spin_lock_init(&mpu->input_lock); 158 - strcpy(rmidi->name, "MSND MIDI"); 159 - snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, 160 - &snd_msndmidi_input); 161 - rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; 162 - return 0; 163 - }
-5
sound/isa/msnd/msnd_pinnacle.c
··· 142 142 } 143 143 break; 144 144 145 - case HIMT_MIDI_IN_UCHAR: 146 - if (chip->msndmidi_mpu) 147 - snd_msndmidi_input_read(chip->msndmidi_mpu); 148 - break; 149 - 150 145 default: 151 146 dev_dbg(chip->card->dev, LOGNAME ": HIMT message %d 0x%02x\n", 152 147 HIBYTE(wMessage), HIBYTE(wMessage));