ALSA: line6: Use incremental loop
authorTakashi Iwai <tiwai@suse.de>
Fri, 23 Jan 2015 14:08:40 +0000 (15:08 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 28 Jan 2015 06:21:06 +0000 (07:21 +0100)
Using a decremental loop without particular reasons worsens the
readability a lot.  Use incremental loops instead.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/line6/capture.c
sound/usb/line6/pcm.c
sound/usb/line6/playback.c

index 5a010ba163fa1d11f6f9cac92676c6de1f1f050a..97283e631e4522513727d5f013add02c9307c638 100644 (file)
@@ -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++;
                }
index adbcac46b78589000dc94146b7d058e90d3e6fec..43474c4ebb6bc516af23d9fb8ac09d3bd7efa09b 100644 (file)
@@ -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]);
index 1c9f95a370ff771cb01a25b28987db90df16fdd8..ab9a83f0f8647d3d8895975c490b814437024fdb 100644 (file)
@@ -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;