Merge tag 'asoc-v5.3' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[linux-block.git] / sound / usb / line6 / toneport.c
index 55865f7e437dc4b6646b463550446e0fa13ccbc6..d0a555dbe324f0e8049023e1327fec7a6b58b584 100644 (file)
@@ -1,13 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Line 6 Linux USB driver
  *
  * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
  *                         Emil Myhrman (emil.myhrman@gmail.com)
- *
- *     This program is free software; you can redistribute it and/or
- *     modify it under the terms of the GNU General Public License as
- *     published by the Free Software Foundation, version 2.
- *
  */
 
 #include <linux/wait.h>
@@ -61,6 +57,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 +209,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 +220,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 +394,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 +408,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;