From patchwork Fri Jan 23 17:13:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 5697011 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 86E0CC058D for ; Fri, 23 Jan 2015 17:26:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52F1220265 for ; Fri, 23 Jan 2015 17:26:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 26FB7201EF for ; Fri, 23 Jan 2015 17:26:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A6D50265727; Fri, 23 Jan 2015 18:21:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 5FE3D265917; Fri, 23 Jan 2015 18:18:09 +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 2B4052654E0; Fri, 23 Jan 2015 18:14:02 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id A2076265529 for ; Fri, 23 Jan 2015 18:13:42 +0100 (CET) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0A8D9ADCA; Fri, 23 Jan 2015 17:13:39 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Fri, 23 Jan 2015 18:13:16 +0100 Message-Id: <1422033203-23254-10-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422033203-23254-1-git-send-email-tiwai@suse.de> References: <1422033203-23254-1-git-send-email-tiwai@suse.de> Cc: Stefan Hajnoczi , Chris Rorvick Subject: [alsa-devel] [PATCH 09/16] ALSA: line6: Use incremental loop 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 Using a decremental loop without particular reasons worsens the readability a lot. Use incremental loops instead. Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 4 ++-- sound/usb/line6/pcm.c | 6 +++--- sound/usb/line6/playback.c | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 5a010ba163fa..97283e631e45 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -91,7 +91,7 @@ void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm) { unsigned int i; - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (test_bit(i, &line6pcm->active_urb_in)) { if (!test_and_set_bit(i, &line6pcm->unlink_urb_in)) { struct urb *u = line6pcm->urb_audio_in[i]; @@ -114,7 +114,7 @@ void line6_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) do { alive = 0; - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (test_bit(i, &line6pcm->active_urb_in)) alive++; } diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index adbcac46b785..43474c4ebb6b 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -273,7 +273,7 @@ static int snd_line6_control_playback_get(struct snd_kcontrol *kcontrol, int i; struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); - for (i = 2; i--;) + for (i = 0; i < 2; i++) ucontrol->value.integer.value[i] = line6pcm->volume_playback[i]; return 0; @@ -286,7 +286,7 @@ static int snd_line6_control_playback_put(struct snd_kcontrol *kcontrol, int i, changed = 0; struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); - for (i = 2; i--;) + for (i = 0; i < 2; i++) if (line6pcm->volume_playback[i] != ucontrol->value.integer.value[i]) { line6pcm->volume_playback[i] = @@ -330,7 +330,7 @@ static void line6_cleanup_pcm(struct snd_pcm *pcm) int i; struct snd_line6_pcm *line6pcm = snd_pcm_chip(pcm); - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (line6pcm->urb_audio_out[i]) { usb_kill_urb(line6pcm->urb_audio_out[i]); usb_free_urb(line6pcm->urb_audio_out[i]); diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 1c9f95a370ff..ab9a83f0f864 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -297,7 +297,7 @@ void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm) { unsigned int i; - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (test_bit(i, &line6pcm->active_urb_out)) { if (!test_and_set_bit(i, &line6pcm->unlink_urb_out)) { struct urb *u = line6pcm->urb_audio_out[i]; @@ -320,7 +320,7 @@ void line6_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) do { alive = 0; - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (test_bit(i, &line6pcm->active_urb_out)) alive++; } @@ -366,14 +366,14 @@ static void audio_out_callback(struct urb *urb) line6pcm->last_frame_out = urb->start_frame; /* find index of URB */ - for (index = LINE6_ISO_BUFFERS; index--;) + for (index = 0; index < LINE6_ISO_BUFFERS; index++) if (urb == line6pcm->urb_audio_out[index]) break; - if (index < 0) + if (index >= LINE6_ISO_BUFFERS) return; /* URB has been unlinked asynchronously */ - for (i = LINE6_ISO_PACKETS; i--;) + for (i = 0; i < LINE6_ISO_PACKETS; i++) length += urb->iso_frame_desc[i].length; spin_lock_irqsave(&line6pcm->lock_audio_out, flags); @@ -390,7 +390,7 @@ static void audio_out_callback(struct urb *urb) clear_bit(index, &line6pcm->active_urb_out); - for (i = LINE6_ISO_PACKETS; i--;) + for (i = 0; i < LINE6_ISO_PACKETS; i++) if (urb->iso_frame_desc[i].status == -EXDEV) { shutdown = 1; break;