Skip to contentSkip to conversation

ASoC: wm_hubs: Remove unneeded count variable in wait_for_dc_servo

PATCH In review Axel Lin 2 participants 2 messages Oct 7, 2011

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 ASoC: wm_hubs: Remove unneeded count variable in wait_for_dc_servo

The count variable is not required, decrement timeout in the while loop can achieve the same effect.

---
 sound/soc/codecs/wm_hubs.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
sound/soc/codecs/wm_hubs.c +3 -4
index 84f33d4..6e2e122 100644
@@ -66,7 +66,6 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
 {
 	struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
 	unsigned int reg;
-	int count = 0;
 	int timeout;
 	unsigned int val;
 
@@ -83,7 +82,7 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
 		timeout = 400;
 
 	do {
-		count++;
+		timeout--;
 
 		if (hubs->dcs_done_irq)
 			wait_for_completion_timeout(&hubs->dcs_done,
@@ -93,9 +92,9 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
 
 		reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
 		dev_dbg(codec->dev, "DC servo: %x\n", reg);
-	} while (reg & op && count < timeout);
+	} while ((reg & op) && timeout);
 
-	if (reg & op)
+	if (timeout == 0)
 		dev_err(codec->dev, "Timed out waiting for DC Servo %x\n",
 			op);
 }
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 2 lines · Axel Lin

The count variable is not required, decrement timeout in the while loop can achieve the same effect.

Having the count original timeout there is helpful when debugging and there's not going to be any meaningful cost from having both.