diff options
author | Takashi Iwai <tiwai@suse.de> | 2019-05-28 09:05:31 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-05-28 09:05:31 +0200 |
commit | f23a09eea1e7947611d985d8cd13d55428ff0af8 (patch) | |
tree | 430c10328cbfeb92c08c9712d6bdf1a98513771f /sound/usb/line6 | |
parent | be8fd484e9c23e49ffe1d163c8d32c8c7b745941 (diff) | |
download | linux-f23a09eea1e7947611d985d8cd13d55428ff0af8.tar.bz2 |
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 { int device_id; }; +#define line6_to_pod(x) container_of(x, struct usb_line6_pod, line6) + #define POD_SYSEX_CODE 3 /* *INDENT-OFF* */ @@ -177,7 +179,7 @@ static char *pod_alloc_sysex_buffer(struct usb_line6_pod *pod, int code, */ static void line6_pod_process_message(struct usb_line6 *line6) { - struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; + struct usb_line6_pod *pod = line6_to_pod(line6); const unsigned char *buf = pod->line6.buffer_message; if (memcmp(buf, pod_version_header, sizeof(pod_version_header)) == 0) { @@ -274,7 +276,7 @@ static ssize_t device_id_show(struct device *dev, static void pod_startup(struct usb_line6 *line6) { - struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; + struct usb_line6_pod *pod = line6_to_pod(line6); switch (pod->startup_progress) { case POD_STARTUP_VERSIONREQ: @@ -328,7 +330,7 @@ static int snd_pod_control_monitor_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); - struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6; + struct usb_line6_pod *pod = line6_to_pod(line6pcm->line6); ucontrol->value.integer.value[0] = pod->monitor_level; return 0; @@ -339,7 +341,7 @@ static int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); - struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6; + struct usb_line6_pod *pod = line6_to_pod(line6pcm->line6); if (ucontrol->value.integer.value[0] == pod->monitor_level) return 0; @@ -368,7 +370,7 @@ static int pod_init(struct usb_line6 *line6, const struct usb_device_id *id) { int err; - struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; + struct usb_line6_pod *pod = line6_to_pod(line6); line6->process_message = line6_pod_process_message; 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 { int firmware_version; }; +#define line6_to_podhd(x) container_of(x, struct usb_line6_podhd, line6) + static struct snd_ratden podhd_ratden = { .num_min = 48000, .num_max = 48000, @@ -231,7 +233,7 @@ exit: static void podhd_startup(struct usb_line6 *line6) { - struct usb_line6_podhd *pod = (struct usb_line6_podhd *)line6; + struct usb_line6_podhd *pod = line6_to_podhd(line6); podhd_dev_start(pod); line6_read_serial_number(&pod->line6, &pod->serial_number); @@ -241,7 +243,7 @@ static void podhd_startup(struct usb_line6 *line6) static void podhd_disconnect(struct usb_line6 *line6) { - struct usb_line6_podhd *pod = (struct usb_line6_podhd *)line6; + struct usb_line6_podhd *pod = line6_to_podhd(line6); if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL_INFO) { struct usb_interface *intf; @@ -260,7 +262,7 @@ static int podhd_init(struct usb_line6 *line6, const struct usb_device_id *id) { int err; - struct usb_line6_podhd *pod = (struct usb_line6_podhd *) line6; + struct usb_line6_podhd *pod = line6_to_podhd(line6); struct usb_interface *intf; 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 { struct toneport_led leds[2]; }; +#define line6_to_toneport(x) container_of(x, struct usb_line6_toneport, line6) + static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2); #define TONEPORT_PCM_DELAY 1 @@ -211,8 +213,8 @@ static int snd_toneport_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); - struct usb_line6_toneport *toneport = - (struct usb_line6_toneport *)line6pcm->line6; + struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6); + ucontrol->value.enumerated.item[0] = toneport->source; return 0; } @@ -222,8 +224,7 @@ static int snd_toneport_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); - struct usb_line6_toneport *toneport = - (struct usb_line6_toneport *)line6pcm->line6; + struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6); unsigned int source; source = ucontrol->value.enumerated.item[0]; @@ -397,8 +398,7 @@ static int toneport_setup(struct usb_line6_toneport *toneport) */ static void line6_toneport_disconnect(struct usb_line6 *line6) { - struct usb_line6_toneport *toneport = - (struct usb_line6_toneport *)line6; + struct usb_line6_toneport *toneport = line6_to_toneport(line6); if (toneport_has_led(toneport)) toneport_remove_leds(toneport); @@ -412,7 +412,7 @@ static int toneport_init(struct usb_line6 *line6, const struct usb_device_id *id) { int err; - struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6; + struct usb_line6_toneport *toneport = line6_to_toneport(line6); toneport->type = id->driver_info; 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 { int startup_progress; }; +#define line6_to_variax(x) container_of(x, struct usb_line6_variax, line6) + #define VARIAX_OFFSET_ACTIVATE 7 /* @@ -86,7 +88,7 @@ static void variax_activate_async(struct usb_line6_variax *variax, int a) static void variax_startup(struct usb_line6 *line6) { - struct usb_line6_variax *variax = (struct usb_line6_variax *)line6; + struct usb_line6_variax *variax = line6_to_variax(line6); switch (variax->startup_progress) { case VARIAX_STARTUP_VERSIONREQ: @@ -115,7 +117,7 @@ static void variax_startup(struct usb_line6 *line6) */ static void line6_variax_process_message(struct usb_line6 *line6) { - struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; + struct usb_line6_variax *variax = line6_to_variax(line6); const unsigned char *buf = variax->line6.buffer_message; switch (buf[0]) { @@ -149,7 +151,7 @@ static void line6_variax_process_message(struct usb_line6 *line6) */ static void line6_variax_disconnect(struct usb_line6 *line6) { - struct usb_line6_variax *variax = (struct usb_line6_variax *)line6; + struct usb_line6_variax *variax = line6_to_variax(line6); kfree(variax->buffer_activate); } @@ -160,7 +162,7 @@ static void line6_variax_disconnect(struct usb_line6 *line6) static int variax_init(struct usb_line6 *line6, const struct usb_device_id *id) { - struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; + struct usb_line6_variax *variax = line6_to_variax(line6); int err; line6->process_message = line6_variax_process_message; |