forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/usb/usx2y/us122l.c
....@@ -1,19 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2007, 2008 Karsten Wiese <fzu@wemgehoertderstaat.de>
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms of the GNU General Public License as published by the
6
- * Free Software Foundation; either version 2 of the License, or (at your
7
- * option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful, but
10
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
- * for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, write to the Free Software Foundation,
16
- * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
174 */
185
196 #include <linux/slab.h>
....@@ -53,13 +40,13 @@
5340
5441 static int us122l_create_usbmidi(struct snd_card *card)
5542 {
56
- static struct snd_usb_midi_endpoint_info quirk_data = {
43
+ static const struct snd_usb_midi_endpoint_info quirk_data = {
5744 .out_ep = 4,
5845 .in_ep = 3,
5946 .out_cables = 0x001,
6047 .in_cables = 0x001
6148 };
62
- static struct snd_usb_audio_quirk quirk = {
49
+ static const struct snd_usb_audio_quirk quirk = {
6350 .vendor_name = "US122L",
6451 .product_name = NAME_ALLCAPS,
6552 .ifnum = 1,
....@@ -75,13 +62,13 @@
7562
7663 static int us144_create_usbmidi(struct snd_card *card)
7764 {
78
- static struct snd_usb_midi_endpoint_info quirk_data = {
65
+ static const struct snd_usb_midi_endpoint_info quirk_data = {
7966 .out_ep = 4,
8067 .in_ep = 3,
8168 .out_cables = 0x001,
8269 .in_cables = 0x001
8370 };
84
- static struct snd_usb_audio_quirk quirk = {
71
+ static const struct snd_usb_audio_quirk quirk = {
8572 .vendor_name = "US144",
8673 .product_name = NAME_ALLCAPS,
8774 .ifnum = 0,
....@@ -95,40 +82,13 @@
9582 &US122L(card)->midi_list, &quirk);
9683 }
9784
98
-/*
99
- * Wrapper for usb_control_msg().
100
- * Allocates a temp buffer to prevent dmaing from/to the stack.
101
- */
102
-static int us122l_ctl_msg(struct usb_device *dev, unsigned int pipe,
103
- __u8 request, __u8 requesttype,
104
- __u16 value, __u16 index, void *data,
105
- __u16 size, int timeout)
106
-{
107
- int err;
108
- void *buf = NULL;
109
-
110
- if (size > 0) {
111
- buf = kmemdup(data, size, GFP_KERNEL);
112
- if (!buf)
113
- return -ENOMEM;
114
- }
115
- err = usb_control_msg(dev, pipe, request, requesttype,
116
- value, index, buf, size, timeout);
117
- if (size > 0) {
118
- memcpy(data, buf, size);
119
- kfree(buf);
120
- }
121
- return err;
122
-}
123
-
12485 static void pt_info_set(struct usb_device *dev, u8 v)
12586 {
12687 int ret;
12788
128
- ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
129
- 'I',
130
- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
131
- v, 0, NULL, 0, 1000);
89
+ ret = usb_control_msg_send(dev, 0, 'I',
90
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
91
+ v, 0, NULL, 0, 1000, GFP_NOIO);
13292 snd_printdd(KERN_DEBUG "%i\n", ret);
13393 }
13494
....@@ -318,10 +278,11 @@
318278 data[0] = rate;
319279 data[1] = rate >> 8;
320280 data[2] = rate >> 16;
321
- err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
322
- USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
323
- UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000);
324
- if (err < 0)
281
+ err = usb_control_msg_send(dev, 0, UAC_SET_CUR,
282
+ USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT,
283
+ UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3,
284
+ 1000, GFP_NOIO);
285
+ if (err)
325286 snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n",
326287 dev->devnum, rate, ep);
327288 return err;