From patchwork Fri Feb 6 14:51:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Rorvick X-Patchwork-Id: 5792251 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 33C01BF440 for ; Fri, 6 Feb 2015 14:52:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D5182011B for ; Fri, 6 Feb 2015 14:52:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id F2F8E200FE for ; Fri, 6 Feb 2015 14:52:08 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 04BE126524C; Fri, 6 Feb 2015 15:52:08 +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, 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 40703265134; Fri, 6 Feb 2015 15:51:36 +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 86228265134; Fri, 6 Feb 2015 15:51:34 +0100 (CET) Received: from mail-yh0-f43.google.com (mail-yh0-f43.google.com [209.85.213.43]) by alsa0.perex.cz (Postfix) with ESMTP id 895512605E8 for ; Fri, 6 Feb 2015 15:51:28 +0100 (CET) Received: by mail-yh0-f43.google.com with SMTP id 29so6417891yhl.2 for ; Fri, 06 Feb 2015 06:51:27 -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=0v5ByIzEIxDnO0/L7sodNm/Hq1Qtxk1z0V0IDk9V/QI=; b=WqoHfOyPEToPAT2krcM2UItyEfP6q4+XemjhG306bhbE3JT1lyPZI/LCcN1UJVELY/ +i2pRhgtiyu7iI9uSqbIMsob4ZEf+k4AE8GdP1IJrpy1pRu+bT6disrtTxo/mMt3azSN IcrEhOaz0DLTa5/2I0Gv+tX5O0ZI6gWxZ1UACRMj7PsZYrcwXZJuGQq8HcVVidjpTS8O 3VqQVEZxRBvFkq180Q+lYF6zWjT2llZTctGjl/qfDuvaefrmNRigmScae1H0BMfEFK12 1uWI/+/PEdDZXOuWs/U17GWwiSsH6hSeGzpWh8/q1QoyJNM+6UCX/jnf6vj3ea623iXe tb+A== X-Received: by 10.236.1.38 with SMTP id 26mr1451652yhc.163.1423234287568; Fri, 06 Feb 2015 06:51:27 -0800 (PST) Received: from localhost.localdomain.localdomain ([173.209.212.239]) by mx.google.com with ESMTPSA id a91sm690467yhq.17.2015.02.06.06.51.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Feb 2015 06:51:27 -0800 (PST) From: Chris Rorvick To: Takashi Iwai 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> Cc: Stefan Hajnoczi , alsa-devel@alsa-project.org, Chris Rorvick , linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH 1/4] 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..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);