All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Stefan Hajnoczi <stefanha@gmail.com>, Chris Rorvick <chris@rorvick.com>
Subject: [PATCH 09/16] ALSA: line6: Use incremental loop
Date: Fri, 23 Jan 2015 18:13:16 +0100	[thread overview]
Message-ID: <1422033203-23254-10-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1422033203-23254-1-git-send-email-tiwai@suse.de>

Using a decremental loop without particular reasons worsens the
readability a lot.  Use incremental loops instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 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;
-- 
2.2.2

  parent reply	other threads:[~2015-01-23 17:13 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 17:13 [PATCH 00/16] Yet more cleanups of line6 drivers Takashi Iwai
2015-01-23 17:13 ` [PATCH 01/16] ALSA: line6: Minor refactoring Takashi Iwai
2015-01-23 17:13 ` [PATCH 02/16] ALSA: line6: Fix memory leak at probe error path Takashi Iwai
2015-01-25  8:06   ` Chris Rorvick
2015-01-26 12:47     ` Takashi Iwai
2015-01-23 17:13 ` [PATCH 03/16] ALSA: line6: Remove unused line6_nop_read() Takashi Iwai
2015-01-23 17:13 ` [PATCH 04/16] ALSA: line6: Reduce superfluous spinlock in midi.c Takashi Iwai
2015-01-23 17:13 ` [PATCH 05/16] ALSA: line6: Fix missing error handling in line6_pcm_acquire() Takashi Iwai
2015-01-23 17:13 ` [PATCH 06/16] ALSA: line6: Use logical OR Takashi Iwai
2015-01-23 17:13 ` [PATCH 07/16] ALSA: line6: Fix the error recovery in line6_pcm_acquire() Takashi Iwai
2015-01-23 17:13 ` [PATCH 08/16] ALSA: line6: Drop superfluous spinlock for trigger Takashi Iwai
2015-01-27  6:22   ` Chris Rorvick
2015-01-27 10:27     ` Takashi Iwai
2015-01-27 12:48       ` Chris Rorvick
2015-01-27 16:10         ` Takashi Iwai
2015-01-28  6:03           ` Chris Rorvick
2015-01-28  6:26             ` Takashi Iwai
2015-01-28 14:02               ` Chris Rorvick
2015-01-23 17:13 ` Takashi Iwai [this message]
2015-01-23 17:13 ` [PATCH 10/16] ALSA: line6: Drop voodoo workarounds Takashi Iwai
2015-01-27  3:58   ` Chris Rorvick
2015-01-23 17:13 ` [PATCH 11/16] ALSA: line6: Rearrange PCM structure Takashi Iwai
2015-01-23 17:13 ` [PATCH 12/16] ALSA: line6: Consolidate URB unlink and sync helpers Takashi Iwai
2015-01-23 17:13 ` [PATCH 13/16] ALSA: line6: Use dev_err() Takashi Iwai
2015-01-23 17:13 ` [PATCH 14/16] ALSA: line6: Consolidate PCM stream buffer allocation and free Takashi Iwai
2015-01-23 17:13 ` [PATCH 15/16] ALSA: line6: Do clipping in volume / monitor manipulations Takashi Iwai
2015-01-23 17:13 ` [PATCH 16/16] ALSA: line6: Skip volume manipulation during silence copying Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422033203-23254-10-git-send-email-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=chris@rorvick.com \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.