Commit 7276d3f3 authored by Lad Prabhakar's avatar Lad Prabhakar Committed by Mark Brown

ASoC: sh: rz-ssi: Use a do-while loop in rz_ssi_pio_recv()

Use a do-while loop while reading the samples from RX FIFO. The "done"
flag was only changed as an outcome of the last if-statement (last step)
in this entire procedure. This patch moves the condition from if
statement to while and drops the "done" variable for readability.

While at it, also drop the unneeded parentheses around runtime->dma_area.
Signed-off-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/20220125132457.14984-2-prabhakar.mahadev-lad.rj@bp.renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9ebb50df
...@@ -408,7 +408,6 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) ...@@ -408,7 +408,6 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
{ {
struct snd_pcm_substream *substream = strm->substream; struct snd_pcm_substream *substream = strm->substream;
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
bool done = false;
u16 *buf; u16 *buf;
int fifo_samples; int fifo_samples;
int frames_left; int frames_left;
...@@ -420,7 +419,7 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) ...@@ -420,7 +419,7 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
runtime = substream->runtime; runtime = substream->runtime;
while (!done) { do {
/* frames left in this period */ /* frames left in this period */
frames_left = runtime->period_size - frames_left = runtime->period_size -
(strm->buffer_pos % runtime->period_size); (strm->buffer_pos % runtime->period_size);
...@@ -444,7 +443,7 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) ...@@ -444,7 +443,7 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
break; break;
/* calculate new buffer index */ /* calculate new buffer index */
buf = (u16 *)(runtime->dma_area); buf = (u16 *)runtime->dma_area;
buf += strm->buffer_pos * runtime->channels; buf += strm->buffer_pos * runtime->channels;
/* Note, only supports 16-bit samples */ /* Note, only supports 16-bit samples */
...@@ -453,11 +452,7 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) ...@@ -453,11 +452,7 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
rz_ssi_reg_mask_setl(ssi, SSIFSR, SSIFSR_RDF, 0); rz_ssi_reg_mask_setl(ssi, SSIFSR, SSIFSR_RDF, 0);
rz_ssi_pointer_update(strm, samples / runtime->channels); rz_ssi_pointer_update(strm, samples / runtime->channels);
} while (!frames_left && fifo_samples >= runtime->channels);
/* check if there are no more samples in the RX FIFO */
if (!(!frames_left && fifo_samples >= runtime->channels))
done = true;
}
return 0; return 0;
} }
......
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