From patchwork Sat Feb 7 16:43:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Rorvick X-Patchwork-Id: 5796301 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 32161BF440 for ; Sat, 7 Feb 2015 16:44:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 758D720142 for ; Sat, 7 Feb 2015 16:44:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 4EC322012E for ; Sat, 7 Feb 2015 16:44:46 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 774F7260568; Sat, 7 Feb 2015 17:44:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id D81AD26060E; Sat, 7 Feb 2015 17:44:26 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id DA71626060E; Sat, 7 Feb 2015 17:44:25 +0100 (CET) Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) by alsa0.perex.cz (Postfix) with ESMTP id 5F65C260529 for ; Sat, 7 Feb 2015 17:44:03 +0100 (CET) Received: by iery20 with SMTP id y20so8063537ier.1 for ; Sat, 07 Feb 2015 08:44:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0mz0awaLmGFiIDPiWHQvr/1x8cMTaZqrGAaUSqWrhJ0=; b=QYb15mlX+P8TkXfJ/F+rtmbCj/XncRN0QHUHI1RtD2MnkhnD7f8a05r+Y8ygxRC7qa bjia+YOBD0OGpJb1EvYiTvvZrmQ7OYz34v09Uk9EwEsy7x2hQpUDMrONwJ8k0WUqbHOO 8GkEIoZDWToEaqwcYP/SiwuidgUEOq6jyis9SbBVWkS/OIV/AWEhsfmT2mC+2rMLMJYi mhe67BTIv1MG1WHyEy+RRie/NgscrRroi64mcnqIEW/B5sMwtJvL4TF0zfGI7qnyN4eN hJD5W8/cU3bmCGprqfTS54zzK8jfN8LtD3GvL3yhSYFAoKDpyoLx0f/SfAmqJwJGMJHP OBtA== X-Received: by 10.50.119.9 with SMTP id kq9mr8300682igb.36.1423327442541; Sat, 07 Feb 2015 08:44:02 -0800 (PST) Received: from localhost.localdomain.com (adsl-99-142-29-188.dsl.emhril.sbcglobal.net. [99.142.29.188]) by mx.google.com with ESMTPSA id m77sm3245278iom.38.2015.02.07.08.44.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Feb 2015 08:44:01 -0800 (PST) From: Chris Rorvick To: Takashi Iwai Date: Sat, 7 Feb 2015 10:43:17 -0600 Message-Id: <1423327399-12619-2-git-send-email-chris@rorvick.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423327399-12619-1-git-send-email-chris@rorvick.com> References: <1423327399-12619-1-git-send-email-chris@rorvick.com> Cc: Stefan Hajnoczi , alsa-devel@alsa-project.org, Chris Rorvick , linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH v2 1/3] ALSA: line6: Add toneport_has_source_select() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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..6dd6d4f 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 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);