diff options
author | Takashi Iwai <tiwai@suse.de> | 2019-05-28 03:05:31 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-05-28 03:05:31 -0400 |
commit | f23a09eea1e7947611d985d8cd13d55428ff0af8 (patch) | |
tree | 430c10328cbfeb92c08c9712d6bdf1a98513771f /sound/usb/line6 | |
parent | be8fd484e9c23e49ffe1d163c8d32c8c7b745941 (diff) |
ALSA: line6: Use container_of()
... instead of unconditional cast.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/line6')
-rw-r--r-- | sound/usb/line6/pod.c | 12 | ||||
-rw-r--r-- | sound/usb/line6/podhd.c | 8 | ||||
-rw-r--r-- | sound/usb/line6/toneport.c | 14 | ||||
-rw-r--r-- | sound/usb/line6/variax.c | 10 |
4 files changed, 25 insertions, 19 deletions
diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 995e6ccc8122..9ea720b4b2ab 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c | |||
@@ -74,6 +74,8 @@ struct usb_line6_pod { | |||
74 | int device_id; | 74 | int device_id; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | #define line6_to_pod(x) container_of(x, struct usb_line6_pod, line6) | ||
78 | |||
77 | #define POD_SYSEX_CODE 3 | 79 | #define POD_SYSEX_CODE 3 |
78 | 80 | ||
79 | /* *INDENT-OFF* */ | 81 | /* *INDENT-OFF* */ |
@@ -177,7 +179,7 @@ static char *pod_alloc_sysex_buffer(struct usb_line6_pod *pod, int code, | |||
177 | */ | 179 | */ |
178 | static void line6_pod_process_message(struct usb_line6 *line6) | 180 | static void line6_pod_process_message(struct usb_line6 *line6) |
179 | { | 181 | { |
180 | struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; | 182 | struct usb_line6_pod *pod = line6_to_pod(line6); |
181 | const unsigned char *buf = pod->line6.buffer_message; | 183 | const unsigned char *buf = pod->line6.buffer_message; |
182 | 184 | ||
183 | if (memcmp(buf, pod_version_header, sizeof(pod_version_header)) == 0) { | 185 | if (memcmp(buf, pod_version_header, sizeof(pod_version_header)) == 0) { |
@@ -274,7 +276,7 @@ static ssize_t device_id_show(struct device *dev, | |||
274 | 276 | ||
275 | static void pod_startup(struct usb_line6 *line6) | 277 | static void pod_startup(struct usb_line6 *line6) |
276 | { | 278 | { |
277 | struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; | 279 | struct usb_line6_pod *pod = line6_to_pod(line6); |
278 | 280 | ||
279 | switch (pod->startup_progress) { | 281 | switch (pod->startup_progress) { |
280 | case POD_STARTUP_VERSIONREQ: | 282 | case POD_STARTUP_VERSIONREQ: |
@@ -328,7 +330,7 @@ static int snd_pod_control_monitor_get(struct snd_kcontrol *kcontrol, | |||
328 | struct snd_ctl_elem_value *ucontrol) | 330 | struct snd_ctl_elem_value *ucontrol) |
329 | { | 331 | { |
330 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); | 332 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); |
331 | struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6; | 333 | struct usb_line6_pod *pod = line6_to_pod(line6pcm->line6); |
332 | 334 | ||
333 | ucontrol->value.integer.value[0] = pod->monitor_level; | 335 | ucontrol->value.integer.value[0] = pod->monitor_level; |
334 | return 0; | 336 | return 0; |
@@ -339,7 +341,7 @@ static int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol, | |||
339 | struct snd_ctl_elem_value *ucontrol) | 341 | struct snd_ctl_elem_value *ucontrol) |
340 | { | 342 | { |
341 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); | 343 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); |
342 | struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6; | 344 | struct usb_line6_pod *pod = line6_to_pod(line6pcm->line6); |
343 | 345 | ||
344 | if (ucontrol->value.integer.value[0] == pod->monitor_level) | 346 | if (ucontrol->value.integer.value[0] == pod->monitor_level) |
345 | return 0; | 347 | return 0; |
@@ -368,7 +370,7 @@ static int pod_init(struct usb_line6 *line6, | |||
368 | const struct usb_device_id *id) | 370 | const struct usb_device_id *id) |
369 | { | 371 | { |
370 | int err; | 372 | int err; |
371 | struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; | 373 | struct usb_line6_pod *pod = line6_to_pod(line6); |
372 | 374 | ||
373 | line6->process_message = line6_pod_process_message; | 375 | line6->process_message = line6_pod_process_message; |
374 | line6->startup = pod_startup; | 376 | line6->startup = pod_startup; |
diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 722fc5db09c5..395ae1692f45 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c | |||
@@ -44,6 +44,8 @@ struct usb_line6_podhd { | |||
44 | int firmware_version; | 44 | int firmware_version; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | #define line6_to_podhd(x) container_of(x, struct usb_line6_podhd, line6) | ||
48 | |||
47 | static struct snd_ratden podhd_ratden = { | 49 | static struct snd_ratden podhd_ratden = { |
48 | .num_min = 48000, | 50 | .num_min = 48000, |
49 | .num_max = 48000, | 51 | .num_max = 48000, |
@@ -231,7 +233,7 @@ exit: | |||
231 | 233 | ||
232 | static void podhd_startup(struct usb_line6 *line6) | 234 | static void podhd_startup(struct usb_line6 *line6) |
233 | { | 235 | { |
234 | struct usb_line6_podhd *pod = (struct usb_line6_podhd *)line6; | 236 | struct usb_line6_podhd *pod = line6_to_podhd(line6); |
235 | 237 | ||
236 | podhd_dev_start(pod); | 238 | podhd_dev_start(pod); |
237 | line6_read_serial_number(&pod->line6, &pod->serial_number); | 239 | line6_read_serial_number(&pod->line6, &pod->serial_number); |
@@ -241,7 +243,7 @@ static void podhd_startup(struct usb_line6 *line6) | |||
241 | 243 | ||
242 | static void podhd_disconnect(struct usb_line6 *line6) | 244 | static void podhd_disconnect(struct usb_line6 *line6) |
243 | { | 245 | { |
244 | struct usb_line6_podhd *pod = (struct usb_line6_podhd *)line6; | 246 | struct usb_line6_podhd *pod = line6_to_podhd(line6); |
245 | 247 | ||
246 | if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL_INFO) { | 248 | if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL_INFO) { |
247 | struct usb_interface *intf; | 249 | struct usb_interface *intf; |
@@ -260,7 +262,7 @@ static int podhd_init(struct usb_line6 *line6, | |||
260 | const struct usb_device_id *id) | 262 | const struct usb_device_id *id) |
261 | { | 263 | { |
262 | int err; | 264 | int err; |
263 | struct usb_line6_podhd *pod = (struct usb_line6_podhd *) line6; | 265 | struct usb_line6_podhd *pod = line6_to_podhd(line6); |
264 | struct usb_interface *intf; | 266 | struct usb_interface *intf; |
265 | 267 | ||
266 | line6->disconnect = podhd_disconnect; | 268 | line6->disconnect = podhd_disconnect; |
diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 55865f7e437d..94a9764110d3 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c | |||
@@ -61,6 +61,8 @@ struct usb_line6_toneport { | |||
61 | struct toneport_led leds[2]; | 61 | struct toneport_led leds[2]; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | #define line6_to_toneport(x) container_of(x, struct usb_line6_toneport, line6) | ||
65 | |||
64 | static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2); | 66 | static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2); |
65 | 67 | ||
66 | #define TONEPORT_PCM_DELAY 1 | 68 | #define TONEPORT_PCM_DELAY 1 |
@@ -211,8 +213,8 @@ static int snd_toneport_source_get(struct snd_kcontrol *kcontrol, | |||
211 | struct snd_ctl_elem_value *ucontrol) | 213 | struct snd_ctl_elem_value *ucontrol) |
212 | { | 214 | { |
213 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); | 215 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); |
214 | struct usb_line6_toneport *toneport = | 216 | struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6); |
215 | (struct usb_line6_toneport *)line6pcm->line6; | 217 | |
216 | ucontrol->value.enumerated.item[0] = toneport->source; | 218 | ucontrol->value.enumerated.item[0] = toneport->source; |
217 | return 0; | 219 | return 0; |
218 | } | 220 | } |
@@ -222,8 +224,7 @@ static int snd_toneport_source_put(struct snd_kcontrol *kcontrol, | |||
222 | struct snd_ctl_elem_value *ucontrol) | 224 | struct snd_ctl_elem_value *ucontrol) |
223 | { | 225 | { |
224 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); | 226 | struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); |
225 | struct usb_line6_toneport *toneport = | 227 | struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6); |
226 | (struct usb_line6_toneport *)line6pcm->line6; | ||
227 | unsigned int source; | 228 | unsigned int source; |
228 | 229 | ||
229 | source = ucontrol->value.enumerated.item[0]; | 230 | source = ucontrol->value.enumerated.item[0]; |
@@ -397,8 +398,7 @@ static int toneport_setup(struct usb_line6_toneport *toneport) | |||
397 | */ | 398 | */ |
398 | static void line6_toneport_disconnect(struct usb_line6 *line6) | 399 | static void line6_toneport_disconnect(struct usb_line6 *line6) |
399 | { | 400 | { |
400 | struct usb_line6_toneport *toneport = | 401 | struct usb_line6_toneport *toneport = line6_to_toneport(line6); |
401 | (struct usb_line6_toneport *)line6; | ||
402 | 402 | ||
403 | if (toneport_has_led(toneport)) | 403 | if (toneport_has_led(toneport)) |
404 | toneport_remove_leds(toneport); | 404 | toneport_remove_leds(toneport); |
@@ -412,7 +412,7 @@ static int toneport_init(struct usb_line6 *line6, | |||
412 | const struct usb_device_id *id) | 412 | const struct usb_device_id *id) |
413 | { | 413 | { |
414 | int err; | 414 | int err; |
415 | struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6; | 415 | struct usb_line6_toneport *toneport = line6_to_toneport(line6); |
416 | 416 | ||
417 | toneport->type = id->driver_info; | 417 | toneport->type = id->driver_info; |
418 | 418 | ||
diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index fb114156b7ca..0d0de907d497 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c | |||
@@ -47,6 +47,8 @@ struct usb_line6_variax { | |||
47 | int startup_progress; | 47 | int startup_progress; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | #define line6_to_variax(x) container_of(x, struct usb_line6_variax, line6) | ||
51 | |||
50 | #define VARIAX_OFFSET_ACTIVATE 7 | 52 | #define VARIAX_OFFSET_ACTIVATE 7 |
51 | 53 | ||
52 | /* | 54 | /* |
@@ -86,7 +88,7 @@ static void variax_activate_async(struct usb_line6_variax *variax, int a) | |||
86 | 88 | ||
87 | static void variax_startup(struct usb_line6 *line6) | 89 | static void variax_startup(struct usb_line6 *line6) |
88 | { | 90 | { |
89 | struct usb_line6_variax *variax = (struct usb_line6_variax *)line6; | 91 | struct usb_line6_variax *variax = line6_to_variax(line6); |
90 | 92 | ||
91 | switch (variax->startup_progress) { | 93 | switch (variax->startup_progress) { |
92 | case VARIAX_STARTUP_VERSIONREQ: | 94 | case VARIAX_STARTUP_VERSIONREQ: |
@@ -115,7 +117,7 @@ static void variax_startup(struct usb_line6 *line6) | |||
115 | */ | 117 | */ |
116 | static void line6_variax_process_message(struct usb_line6 *line6) | 118 | static void line6_variax_process_message(struct usb_line6 *line6) |
117 | { | 119 | { |
118 | struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; | 120 | struct usb_line6_variax *variax = line6_to_variax(line6); |
119 | const unsigned char *buf = variax->line6.buffer_message; | 121 | const unsigned char *buf = variax->line6.buffer_message; |
120 | 122 | ||
121 | switch (buf[0]) { | 123 | switch (buf[0]) { |
@@ -149,7 +151,7 @@ static void line6_variax_process_message(struct usb_line6 *line6) | |||
149 | */ | 151 | */ |
150 | static void line6_variax_disconnect(struct usb_line6 *line6) | 152 | static void line6_variax_disconnect(struct usb_line6 *line6) |
151 | { | 153 | { |
152 | struct usb_line6_variax *variax = (struct usb_line6_variax *)line6; | 154 | struct usb_line6_variax *variax = line6_to_variax(line6); |
153 | 155 | ||
154 | kfree(variax->buffer_activate); | 156 | kfree(variax->buffer_activate); |
155 | } | 157 | } |
@@ -160,7 +162,7 @@ static void line6_variax_disconnect(struct usb_line6 *line6) | |||
160 | static int variax_init(struct usb_line6 *line6, | 162 | static int variax_init(struct usb_line6 *line6, |
161 | const struct usb_device_id *id) | 163 | const struct usb_device_id *id) |
162 | { | 164 | { |
163 | struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; | 165 | struct usb_line6_variax *variax = line6_to_variax(line6); |
164 | int err; | 166 | int err; |
165 | 167 | ||
166 | line6->process_message = line6_variax_process_message; | 168 | line6->process_message = line6_variax_process_message; |