From patchwork Sat Feb 7 16:43:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Rorvick X-Patchwork-Id: 5796311 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 1E997BF440 for ; Sat, 7 Feb 2015 16:45:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52F8A2014A for ; Sat, 7 Feb 2015 16:45:16 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2D06E2012E for ; Sat, 7 Feb 2015 16:45:15 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 571D6260600; Sat, 7 Feb 2015 17:45:14 +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 CE1D32605B6; Sat, 7 Feb 2015 17:44:31 +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 39AB5260617; Sat, 7 Feb 2015 17:44:30 +0100 (CET) Received: from mail-ie0-f173.google.com (mail-ie0-f173.google.com [209.85.223.173]) by alsa0.perex.cz (Postfix) with ESMTP id 525EA2605B6 for ; Sat, 7 Feb 2015 17:44:12 +0100 (CET) Received: by iecrd18 with SMTP id rd18so8061046iec.12 for ; Sat, 07 Feb 2015 08:44:11 -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=wW/jDJtsVrtGUuh4dGYyNs0lAMbyJlod3LcJ6ETXIQE=; b=rxoGexIH9a2QgDx1xrrBCD3mJNCWwClazJ2YsnlO6FiRvLyB1CTI/Xz4WBDL9ooCN7 DTIMoCMkhMzGCkBOrl7KqYD1pPlHVl5OxG5njM2qnfTWC4fY+dulh2qrbGU1hAnhTH7a hiCHNeqeynUFjuxdFOb01iSaxilkWNhTKHVrw6qp3oHYO+XJyFdL6zUE1sAbQ8/rf0lQ 913bhaJxg6a85pR4/y7GsHMY+pi6wUmo17laEYfOak1qF2mscGgdHskFOpmvMoRq3DBv 2Siwi0gNVv5vOqP/s/ZzvjVJv1efW12NICovsuz3cRa9JdLIJQTsoSi4cEE2E9HjlthT qecw== X-Received: by 10.107.37.149 with SMTP id l143mr17308613iol.76.1423327451571; Sat, 07 Feb 2015 08:44:11 -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.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Feb 2015 08:44:11 -0800 (PST) From: Chris Rorvick To: Takashi Iwai Date: Sat, 7 Feb 2015 10:43:18 -0600 Message-Id: <1423327399-12619-3-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 2/3] ALSA: line6: Pass toneport pointer to toneport_has_led() 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 It is unlikely this function would ever be used in a context without a pointer to a `struct usb_line6_toneport', so grab the device type from it rather than having the caller do it. Signed-off-by: Chris Rorvick --- sound/usb/line6/toneport.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 6dd6d4f..2420d2f 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -278,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" }; @@ -379,7 +384,7 @@ static void toneport_setup(struct usb_line6_toneport *toneport) toneport_source_info[toneport->source].code, 0x0000); - if (toneport_has_led(toneport->type)) + if (toneport_has_led(toneport)) toneport_update_led(toneport); mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ); @@ -395,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); } @@ -440,7 +445,7 @@ static int toneport_init(struct usb_line6 *line6, 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;