Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755933AbbBFOvb (ORCPT ); Fri, 6 Feb 2015 09:51:31 -0500 Received: from mail-yh0-f50.google.com ([209.85.213.50]:43791 "EHLO mail-yh0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755631AbbBFOv2 (ORCPT ); Fri, 6 Feb 2015 09:51:28 -0500 From: Chris Rorvick To: Takashi Iwai Cc: Chris Rorvick , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Stefan Hajnoczi Subject: [PATCH 1/4] ALSA: line6: Add toneport_has_source_select() Date: Fri, 6 Feb 2015 08:51:09 -0600 Message-Id: <1423234272-7348-2-git-send-email-chris@rorvick.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423234272-7348-1-git-send-email-chris@rorvick.com> References: <1423234272-7348-1-git-send-email-chris@rorvick.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2215 Lines: 82 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 --- sound/usb/line6/toneport.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index b107cf4..de56180a 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -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 1; + + default: + return 0; + } +} + /* 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); -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/