| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * 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. |
|---|
| 17 | 4 | */ |
|---|
| 18 | 5 | |
|---|
| 19 | 6 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 53 | 40 | |
|---|
| 54 | 41 | static int us122l_create_usbmidi(struct snd_card *card) |
|---|
| 55 | 42 | { |
|---|
| 56 | | - static struct snd_usb_midi_endpoint_info quirk_data = { |
|---|
| 43 | + static const struct snd_usb_midi_endpoint_info quirk_data = { |
|---|
| 57 | 44 | .out_ep = 4, |
|---|
| 58 | 45 | .in_ep = 3, |
|---|
| 59 | 46 | .out_cables = 0x001, |
|---|
| 60 | 47 | .in_cables = 0x001 |
|---|
| 61 | 48 | }; |
|---|
| 62 | | - static struct snd_usb_audio_quirk quirk = { |
|---|
| 49 | + static const struct snd_usb_audio_quirk quirk = { |
|---|
| 63 | 50 | .vendor_name = "US122L", |
|---|
| 64 | 51 | .product_name = NAME_ALLCAPS, |
|---|
| 65 | 52 | .ifnum = 1, |
|---|
| .. | .. |
|---|
| 75 | 62 | |
|---|
| 76 | 63 | static int us144_create_usbmidi(struct snd_card *card) |
|---|
| 77 | 64 | { |
|---|
| 78 | | - static struct snd_usb_midi_endpoint_info quirk_data = { |
|---|
| 65 | + static const struct snd_usb_midi_endpoint_info quirk_data = { |
|---|
| 79 | 66 | .out_ep = 4, |
|---|
| 80 | 67 | .in_ep = 3, |
|---|
| 81 | 68 | .out_cables = 0x001, |
|---|
| 82 | 69 | .in_cables = 0x001 |
|---|
| 83 | 70 | }; |
|---|
| 84 | | - static struct snd_usb_audio_quirk quirk = { |
|---|
| 71 | + static const struct snd_usb_audio_quirk quirk = { |
|---|
| 85 | 72 | .vendor_name = "US144", |
|---|
| 86 | 73 | .product_name = NAME_ALLCAPS, |
|---|
| 87 | 74 | .ifnum = 0, |
|---|
| .. | .. |
|---|
| 95 | 82 | &US122L(card)->midi_list, &quirk); |
|---|
| 96 | 83 | } |
|---|
| 97 | 84 | |
|---|
| 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 | | - |
|---|
| 124 | 85 | static void pt_info_set(struct usb_device *dev, u8 v) |
|---|
| 125 | 86 | { |
|---|
| 126 | 87 | int ret; |
|---|
| 127 | 88 | |
|---|
| 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); |
|---|
| 132 | 92 | snd_printdd(KERN_DEBUG "%i\n", ret); |
|---|
| 133 | 93 | } |
|---|
| 134 | 94 | |
|---|
| .. | .. |
|---|
| 318 | 278 | data[0] = rate; |
|---|
| 319 | 279 | data[1] = rate >> 8; |
|---|
| 320 | 280 | 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) |
|---|
| 325 | 286 | snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", |
|---|
| 326 | 287 | dev->devnum, rate, ep); |
|---|
| 327 | 288 | return err; |
|---|