Commit 690eceb5 authored by Manuel Lauss's avatar Manuel Lauss Committed by Jaroslav Kysela

[ALSA] ASoC: sh: improve generated code for HAC module (AC97)

Change loops in ac97_read/write functions to count down to zero
rather than up. Gcc will then use the 'dt' (decrement-and-test) op
instead of an increment/compare op-pair.
Signed-off-by: default avatarManuel Lauss <mano@roarinelk.homelinux.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent e035b841
...@@ -105,7 +105,7 @@ static int hac_get_codec_data(struct hac_priv *hac, unsigned short r, ...@@ -105,7 +105,7 @@ static int hac_get_codec_data(struct hac_priv *hac, unsigned short r,
unsigned int to1, to2, i; unsigned int to1, to2, i;
unsigned short adr; unsigned short adr;
for (i = 0; i < AC97_READ_RETRY; ++i) { for (i = AC97_READ_RETRY; i; i--) {
*v = 0; *v = 0;
/* wait for HAC to receive something from the codec */ /* wait for HAC to receive something from the codec */
for (to1 = TMO_E4; for (to1 = TMO_E4;
...@@ -132,7 +132,7 @@ static int hac_get_codec_data(struct hac_priv *hac, unsigned short r, ...@@ -132,7 +132,7 @@ static int hac_get_codec_data(struct hac_priv *hac, unsigned short r,
udelay(21); udelay(21);
} }
HACREG(HACRSR) &= ~(RSR_STDRY | RSR_STARY); HACREG(HACRSR) &= ~(RSR_STDRY | RSR_STARY);
return (i < AC97_READ_RETRY); return i;
} }
static unsigned short hac_read_codec_aux(struct hac_priv *hac, static unsigned short hac_read_codec_aux(struct hac_priv *hac,
...@@ -141,7 +141,7 @@ static unsigned short hac_read_codec_aux(struct hac_priv *hac, ...@@ -141,7 +141,7 @@ static unsigned short hac_read_codec_aux(struct hac_priv *hac,
unsigned short val; unsigned short val;
unsigned int i, to; unsigned int i, to;
for (i = 0; i < AC97_READ_RETRY; i++) { for (i = AC97_READ_RETRY; i; i--) {
/* send_read_request */ /* send_read_request */
local_irq_disable(); local_irq_disable();
HACREG(HACTSR) &= ~(TSR_CMDAMT); HACREG(HACTSR) &= ~(TSR_CMDAMT);
...@@ -159,10 +159,7 @@ static unsigned short hac_read_codec_aux(struct hac_priv *hac, ...@@ -159,10 +159,7 @@ static unsigned short hac_read_codec_aux(struct hac_priv *hac,
break; break;
} }
if (i == AC97_READ_RETRY) return i ? val : ~0;
return ~0;
return val;
} }
static void hac_ac97_write(struct snd_ac97 *ac97, unsigned short reg, static void hac_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
...@@ -172,7 +169,7 @@ static void hac_ac97_write(struct snd_ac97 *ac97, unsigned short reg, ...@@ -172,7 +169,7 @@ static void hac_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
struct hac_priv *hac = &hac_cpu_data[unit_id]; struct hac_priv *hac = &hac_cpu_data[unit_id];
unsigned int i, to; unsigned int i, to;
/* write_codec_aux */ /* write_codec_aux */
for (i = 0; i < AC97_WRITE_RETRY; i++) { for (i = AC97_WRITE_RETRY; i; i--) {
/* send_write_request */ /* send_write_request */
local_irq_disable(); local_irq_disable();
HACREG(HACTSR) &= ~(TSR_CMDDMT | TSR_CMDAMT); HACREG(HACTSR) &= ~(TSR_CMDDMT | TSR_CMDAMT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment