.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Line 6 Linux USB driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) |
---|
5 | 6 | * Emil Myhrman (emil.myhrman@gmail.com) |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or |
---|
8 | | - * modify it under the terms of the GNU General Public License as |
---|
9 | | - * published by the Free Software Foundation, version 2. |
---|
10 | | - * |
---|
11 | 7 | */ |
---|
12 | 8 | |
---|
13 | 9 | #include <linux/wait.h> |
---|
.. | .. |
---|
61 | 57 | struct toneport_led leds[2]; |
---|
62 | 58 | }; |
---|
63 | 59 | |
---|
| 60 | +#define line6_to_toneport(x) container_of(x, struct usb_line6_toneport, line6) |
---|
| 61 | + |
---|
64 | 62 | static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2); |
---|
65 | 63 | |
---|
66 | 64 | #define TONEPORT_PCM_DELAY 1 |
---|
67 | 65 | |
---|
68 | | -static struct snd_ratden toneport_ratden = { |
---|
| 66 | +static const struct snd_ratden toneport_ratden = { |
---|
69 | 67 | .num_min = 44100, |
---|
70 | 68 | .num_max = 44100, |
---|
71 | 69 | .num_step = 1, |
---|
.. | .. |
---|
128 | 126 | { |
---|
129 | 127 | int ret; |
---|
130 | 128 | |
---|
131 | | - ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, |
---|
132 | | - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, |
---|
133 | | - cmd1, cmd2, NULL, 0, LINE6_TIMEOUT); |
---|
| 129 | + ret = usb_control_msg_send(usbdev, 0, 0x67, |
---|
| 130 | + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, |
---|
| 131 | + cmd1, cmd2, NULL, 0, LINE6_TIMEOUT, |
---|
| 132 | + GFP_KERNEL); |
---|
134 | 133 | |
---|
135 | | - if (ret < 0) { |
---|
| 134 | + if (ret) { |
---|
136 | 135 | dev_err(&usbdev->dev, "send failed (error %d)\n", ret); |
---|
137 | 136 | return ret; |
---|
138 | 137 | } |
---|
.. | .. |
---|
211 | 210 | struct snd_ctl_elem_value *ucontrol) |
---|
212 | 211 | { |
---|
213 | 212 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); |
---|
214 | | - struct usb_line6_toneport *toneport = |
---|
215 | | - (struct usb_line6_toneport *)line6pcm->line6; |
---|
| 213 | + struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6); |
---|
| 214 | + |
---|
216 | 215 | ucontrol->value.enumerated.item[0] = toneport->source; |
---|
217 | 216 | return 0; |
---|
218 | 217 | } |
---|
.. | .. |
---|
222 | 221 | struct snd_ctl_elem_value *ucontrol) |
---|
223 | 222 | { |
---|
224 | 223 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); |
---|
225 | | - struct usb_line6_toneport *toneport = |
---|
226 | | - (struct usb_line6_toneport *)line6pcm->line6; |
---|
| 224 | + struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6); |
---|
227 | 225 | unsigned int source; |
---|
228 | 226 | |
---|
229 | 227 | source = ucontrol->value.enumerated.item[0]; |
---|
.. | .. |
---|
285 | 283 | } |
---|
286 | 284 | } |
---|
287 | 285 | |
---|
288 | | -static const char * const led_colors[2] = { "red", "green" }; |
---|
289 | | -static const int led_init_vals[2] = { 0x00, 0x26 }; |
---|
| 286 | +static const char * const toneport_led_colors[2] = { "red", "green" }; |
---|
| 287 | +static const int toneport_led_init_vals[2] = { 0x00, 0x26 }; |
---|
290 | 288 | |
---|
291 | 289 | static void toneport_update_led(struct usb_line6_toneport *toneport) |
---|
292 | 290 | { |
---|
.. | .. |
---|
314 | 312 | |
---|
315 | 313 | led->toneport = toneport; |
---|
316 | 314 | snprintf(led->name, sizeof(led->name), "%s::%s", |
---|
317 | | - dev_name(dev), led_colors[i]); |
---|
| 315 | + dev_name(dev), toneport_led_colors[i]); |
---|
318 | 316 | leddev->name = led->name; |
---|
319 | | - leddev->brightness = led_init_vals[i]; |
---|
| 317 | + leddev->brightness = toneport_led_init_vals[i]; |
---|
320 | 318 | leddev->max_brightness = 0x26; |
---|
321 | 319 | leddev->brightness_set = toneport_led_brightness_set; |
---|
322 | 320 | err = led_classdev_register(dev, leddev); |
---|
.. | .. |
---|
397 | 395 | */ |
---|
398 | 396 | static void line6_toneport_disconnect(struct usb_line6 *line6) |
---|
399 | 397 | { |
---|
400 | | - struct usb_line6_toneport *toneport = |
---|
401 | | - (struct usb_line6_toneport *)line6; |
---|
| 398 | + struct usb_line6_toneport *toneport = line6_to_toneport(line6); |
---|
402 | 399 | |
---|
403 | 400 | if (toneport_has_led(toneport)) |
---|
404 | 401 | toneport_remove_leds(toneport); |
---|
.. | .. |
---|
412 | 409 | const struct usb_device_id *id) |
---|
413 | 410 | { |
---|
414 | 411 | int err; |
---|
415 | | - struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6; |
---|
| 412 | + struct usb_line6_toneport *toneport = line6_to_toneport(line6); |
---|
416 | 413 | |
---|
417 | 414 | toneport->type = id->driver_info; |
---|
418 | 415 | |
---|