Merge tag 'gfs2-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2...
[firefly-linux-kernel-4.4.55.git] / sound / usb / line6 / toneport.c
index 819e06b3f3dba31f8fbd835244515a121cc8f2ee..6d4c50c9b17d87175cac330703ebd2ff0aba4cc9 100644 (file)
@@ -21,7 +21,6 @@
 #include "capture.h"
 #include "driver.h"
 #include "playback.h"
-#include "usbdefs.h"
 
 enum line6_device_type {
        LINE6_GUITARPORT,
@@ -43,34 +42,22 @@ struct toneport_led {
 };
 
 struct usb_line6_toneport {
-       /**
-               Generic Line 6 USB data.
-       */
+       /* Generic Line 6 USB data */
        struct usb_line6 line6;
 
-       /**
-               Source selector.
-       */
+       /* Source selector */
        int source;
 
-       /**
-               Serial number of device.
-       */
-       int serial_number;
+       /* Serial number of device */
+       u32 serial_number;
 
-       /**
-               Firmware version (x 100).
-       */
-       int firmware_version;
+       /* Firmware version (x 100) */
+       u8 firmware_version;
 
-       /**
-                Timer for delayed PCM startup.
-       */
+       /* Timer for delayed PCM startup */
        struct timer_list timer;
 
-       /**
-                Device type.
-       */
+       /* Device type */
        enum line6_device_type type;
 
        /* LED instances */
@@ -89,7 +76,7 @@ static struct snd_ratden toneport_ratden = {
 };
 
 static struct line6_pcm_properties toneport_pcm_properties = {
-       .snd_line6_playback_hw = {
+       .playback_hw = {
                                  .info = (SNDRV_PCM_INFO_MMAP |
                                           SNDRV_PCM_INFO_INTERLEAVED |
                                           SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -107,7 +94,7 @@ static struct line6_pcm_properties toneport_pcm_properties = {
                                  .period_bytes_max = 8192,
                                  .periods_min = 1,
                                  .periods_max = 1024},
-       .snd_line6_capture_hw = {
+       .capture_hw = {
                                 .info = (SNDRV_PCM_INFO_MMAP |
                                          SNDRV_PCM_INFO_INTERLEAVED |
                                          SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -124,7 +111,7 @@ static struct line6_pcm_properties toneport_pcm_properties = {
                                 .period_bytes_max = 8192,
                                 .periods_min = 1,
                                 .periods_max = 1024},
-       .snd_line6_rates = {
+       .rates = {
                            .nrats = 1,
                            .rats = &toneport_ratden},
        .bytes_per_frame = 4
@@ -291,12 +278,17 @@ static struct snd_kcontrol_new toneport_control_source = {
        (void cmd_0x02(byte red, byte green)
 */
 
-static bool toneport_has_led(enum line6_device_type type)
+static bool toneport_has_led(struct usb_line6_toneport *toneport)
 {
-       return
-           (type == LINE6_GUITARPORT) ||
-           (type == LINE6_TONEPORT_GX);
+       switch (toneport->type) {
+       case LINE6_GUITARPORT:
+       case LINE6_TONEPORT_GX:
        /* add your device here if you are missing support for the LEDs */
+               return true;
+
+       default:
+               return false;
+       }
 }
 
 static const char * const led_colors[2] = { "red", "green" };
@@ -356,6 +348,20 @@ static void toneport_remove_leds(struct usb_line6_toneport *toneport)
        }
 }
 
+static bool toneport_has_source_select(struct usb_line6_toneport *toneport)
+{
+       switch (toneport->type) {
+       case LINE6_TONEPORT_UX1:
+       case LINE6_TONEPORT_UX2:
+       case LINE6_PODSTUDIO_UX1:
+       case LINE6_PODSTUDIO_UX2:
+               return true;
+
+       default:
+               return false;
+       }
+}
+
 /*
        Setup Toneport device.
 */
@@ -373,19 +379,12 @@ static void toneport_setup(struct usb_line6_toneport *toneport)
        toneport_send_cmd(usbdev, 0x0301, 0x0000);
 
        /* initialize source select: */
-       switch (toneport->type) {
-       case LINE6_TONEPORT_UX1:
-       case LINE6_TONEPORT_UX2:
-       case LINE6_PODSTUDIO_UX1:
-       case LINE6_PODSTUDIO_UX2:
+       if (toneport_has_source_select(toneport))
                toneport_send_cmd(usbdev,
                                  toneport_source_info[toneport->source].code,
                                  0x0000);
-       default:
-               break;
-       }
 
-       if (toneport_has_led(toneport->type))
+       if (toneport_has_led(toneport))
                toneport_update_led(toneport);
 
        mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ);
@@ -401,7 +400,7 @@ static void line6_toneport_disconnect(struct usb_line6 *line6)
 
        del_timer_sync(&toneport->timer);
 
-       if (toneport_has_led(toneport->type))
+       if (toneport_has_led(toneport))
                toneport_remove_leds(toneport);
 }
 
@@ -434,26 +433,19 @@ static int toneport_init(struct usb_line6 *line6,
                return err;
 
        /* register source select control: */
-       switch (toneport->type) {
-       case LINE6_TONEPORT_UX1:
-       case LINE6_TONEPORT_UX2:
-       case LINE6_PODSTUDIO_UX1:
-       case LINE6_PODSTUDIO_UX2:
+       if (toneport_has_source_select(toneport)) {
                err =
                    snd_ctl_add(line6->card,
                                snd_ctl_new1(&toneport_control_source,
                                             line6->line6pcm));
                if (err < 0)
                        return err;
-
-       default:
-               break;
        }
 
        line6_read_serial_number(line6, &toneport->serial_number);
        line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
 
-       if (toneport_has_led(toneport->type)) {
+       if (toneport_has_led(toneport)) {
                err = toneport_init_leds(toneport);
                if (err < 0)
                        return err;
@@ -565,7 +557,7 @@ static const struct line6_properties toneport_properties_table[] = {
 static int toneport_probe(struct usb_interface *interface,
                          const struct usb_device_id *id)
 {
-       return line6_probe(interface, id,
+       return line6_probe(interface, id, "Line6-TonePort",
                           &toneport_properties_table[id->driver_info],
                           toneport_init, sizeof(struct usb_line6_toneport));
 }