Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756398AbbBFOxI (ORCPT ); Fri, 6 Feb 2015 09:53:08 -0500 Received: from mail-yk0-f180.google.com ([209.85.160.180]:49609 "EHLO mail-yk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755889AbbBFOva (ORCPT ); Fri, 6 Feb 2015 09:51:30 -0500 From: Chris Rorvick To: Takashi Iwai Cc: Chris Rorvick , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Stefan Hajnoczi Subject: [PATCH 2/4] ALSA: line6: Pass toneport pointer to toneport_has_led() Date: Fri, 6 Feb 2015 08:51:10 -0600 Message-Id: <1423234272-7348-3-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: 2271 Lines: 70 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 de56180a..b2c0b2c 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 1; + + default: + return 0; + } } 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; -- 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/