]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ALSA: line6: Add toneport_has_source_select()
authorChris Rorvick <chris@rorvick.com>
Sat, 7 Feb 2015 16:43:17 +0000 (10:43 -0600)
committerTakashi Iwai <tiwai@suse.de>
Sun, 8 Feb 2015 08:05:56 +0000 (09:05 +0100)
Add a predicate for testing if the device supports source selection to
make the conditional logic around this a bit cleaner.

Signed-off-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/line6/toneport.c

index b107cf4818191ebd24e0d6d8e304ab8f02f0937f..6dd6d4f41310457bc570b6abae64c338e12b70b1 100644 (file)
@@ -343,6 +343,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.
 */
@@ -360,17 +374,10 @@ 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))
                toneport_update_led(toneport);
@@ -421,20 +428,13 @@ 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);