hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/sound/usb/midi.c
....@@ -91,7 +91,7 @@
9191 __u8 bDescriptorType;
9292 __u8 bDescriptorSubtype;
9393 __u8 bNumEmbMIDIJack;
94
- __u8 baAssocJackID[0];
94
+ __u8 baAssocJackID[];
9595 } __attribute__ ((packed));
9696
9797 struct snd_usb_midi_in_endpoint;
....@@ -142,7 +142,7 @@
142142 unsigned int active_urbs;
143143 unsigned int drain_urbs;
144144 int max_transfer; /* size of urb buffer */
145
- struct tasklet_struct tasklet;
145
+ struct work_struct work;
146146 unsigned int next_urb;
147147 spinlock_t buffer_lock;
148148
....@@ -344,10 +344,10 @@
344344 spin_unlock_irqrestore(&ep->buffer_lock, flags);
345345 }
346346
347
-static void snd_usbmidi_out_tasklet(unsigned long data)
347
+static void snd_usbmidi_out_work(struct work_struct *work)
348348 {
349349 struct snd_usb_midi_out_endpoint *ep =
350
- (struct snd_usb_midi_out_endpoint *) data;
350
+ container_of(work, struct snd_usb_midi_out_endpoint, work);
351351
352352 snd_usbmidi_do_output(ep);
353353 }
....@@ -1149,10 +1149,8 @@
11491149 port = &umidi->endpoints[i].out->ports[j];
11501150 break;
11511151 }
1152
- if (!port) {
1153
- snd_BUG();
1152
+ if (!port)
11541153 return -ENXIO;
1155
- }
11561154
11571155 substream->runtime->private_data = port;
11581156 port->state = STATE_UNKNOWN;
....@@ -1161,6 +1159,9 @@
11611159
11621160 static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
11631161 {
1162
+ struct usbmidi_out_port *port = substream->runtime->private_data;
1163
+
1164
+ cancel_work_sync(&port->ep->work);
11641165 return substream_open(substream, 0, 0);
11651166 }
11661167
....@@ -1175,11 +1176,10 @@
11751176 if (port->ep->umidi->disconnected) {
11761177 /* gobble up remaining bytes to prevent wait in
11771178 * snd_rawmidi_drain_output */
1178
- while (!snd_rawmidi_transmit_empty(substream))
1179
- snd_rawmidi_transmit_ack(substream, 1);
1179
+ snd_rawmidi_proceed(substream);
11801180 return;
11811181 }
1182
- tasklet_schedule(&port->ep->tasklet);
1182
+ queue_work(system_highpri_wq, &port->ep->work);
11831183 }
11841184 }
11851185
....@@ -1211,6 +1211,7 @@
12111211 } while (drain_urbs && timeout);
12121212 finish_wait(&ep->drain_wait, &wait);
12131213 }
1214
+ port->active = 0;
12141215 spin_unlock_irq(&ep->buffer_lock);
12151216 }
12161217
....@@ -1409,8 +1410,8 @@
14091410 /*
14101411 * Some devices only work with 9 bytes packet size:
14111412 */
1412
- case USB_ID(0x0644, 0x800E): /* Tascam US-122L */
1413
- case USB_ID(0x0644, 0x800F): /* Tascam US-144 */
1413
+ case USB_ID(0x0644, 0x800e): /* Tascam US-122L */
1414
+ case USB_ID(0x0644, 0x800f): /* Tascam US-144 */
14141415 ep->max_transfer = 9;
14151416 break;
14161417 }
....@@ -1442,7 +1443,7 @@
14421443 }
14431444
14441445 spin_lock_init(&ep->buffer_lock);
1445
- tasklet_init(&ep->tasklet, snd_usbmidi_out_tasklet, (unsigned long)ep);
1446
+ INIT_WORK(&ep->work, snd_usbmidi_out_work);
14461447 init_waitqueue_head(&ep->drain_wait);
14471448
14481449 for (i = 0; i < 0x10; ++i)
....@@ -1505,7 +1506,7 @@
15051506 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
15061507 struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i];
15071508 if (ep->out)
1508
- tasklet_kill(&ep->out->tasklet);
1509
+ cancel_work_sync(&ep->out->work);
15091510 if (ep->out) {
15101511 for (j = 0; j < OUTPUT_URBS; ++j)
15111512 usb_kill_urb(ep->out->urbs[j].urb);
....@@ -2417,7 +2418,7 @@
24172418 break;
24182419 case QUIRK_MIDI_US122L:
24192420 umidi->usb_protocol_ops = &snd_usbmidi_122l_ops;
2420
- /* fall through */
2421
+ fallthrough;
24212422 case QUIRK_MIDI_FIXED_ENDPOINT:
24222423 memcpy(&endpoints[0], quirk->data,
24232424 sizeof(struct snd_usb_midi_endpoint_info));