[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1494836350-28790-2-git-send-email-geert@linux-m68k.org>
Date: Mon, 15 May 2017 10:19:10 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Clemens Ladisch <clemens@...isch.de>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Takashi Sakamoto <o-takashi@...amocchi.jp>
Cc: Arnd Bergmann <arnd@...db.de>, alsa-devel@...a-project.org,
linux-kernel@...r.kernel.org,
Geert Uytterhoeven <geert@...ux-m68k.org>
Subject: [PATCH 2/2] ALSA: firewire-tascam: Use do { } while for loops executed at least once
If a loop is intended to be executed at least once, it is better to use
"do { ... } while (...)" instead of "while (...) { ... }".
The former is easier to understand for the casual reviewer, and doesn't
require preinitializing the canary variable.
Signed-off-by: Geert Uytterhoeven <geert@...ux-m68k.org>
---
Compile-tested only.
---
sound/firewire/tascam/tascam-stream.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c
index e433b92ac6904db5..4ea6845aae87fdef 100644
--- a/sound/firewire/tascam/tascam-stream.c
+++ b/sound/firewire/tascam/tascam-stream.c
@@ -80,17 +80,17 @@ static int set_clock(struct snd_tscm *tscm, unsigned int rate,
int snd_tscm_stream_get_rate(struct snd_tscm *tscm, unsigned int *rate)
{
- u32 data = 0x0;
unsigned int trials = 0;
+ u32 data;
int err;
- while (data == 0x0 && trials++ < 5) {
+ do {
err = get_clock(tscm, &data);
if (err < 0)
return err;
data = (data & 0xff000000) >> 24;
- }
+ } while (data == 0x0 && ++trials < 5);
/* Check base rate. */
if ((data & 0x0f) == 0x01)
--
2.7.4
Powered by blists - more mailing lists