Commit 4b14f179 authored by Biju Das's avatar Biju Das Committed by Mark Brown

ASoC: sh: rz-ssi: Improve error handling in rz_ssi_dma_request function

dma_request_chan() returns error pointer in case of failures, but
the rz_ssi_dma_request() checked for NULL pointer instead.

This patch fixes the issue by checking for ERR_PTR() instead of
NULL and sets the DMA pointers to NULL in error case so that ssi
can fallback to PIO mode.

Fixes: 26ac471c ("ASoC: sh: rz-ssi: Add SSI DMAC support")
Signed-off-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/20210818101450.15948-1-biju.das.jz@bp.renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2fbbcffe
...@@ -185,7 +185,7 @@ rz_ssi_stream_get(struct rz_ssi_priv *ssi, struct snd_pcm_substream *substream) ...@@ -185,7 +185,7 @@ rz_ssi_stream_get(struct rz_ssi_priv *ssi, struct snd_pcm_substream *substream)
static inline bool rz_ssi_is_dma_enabled(struct rz_ssi_priv *ssi) static inline bool rz_ssi_is_dma_enabled(struct rz_ssi_priv *ssi)
{ {
return (ssi->playback.dma_ch || ssi->capture.dma_ch); return (ssi->playback.dma_ch && (ssi->dma_rt || ssi->capture.dma_ch));
} }
static int rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi, static int rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi,
...@@ -676,15 +676,26 @@ static void rz_ssi_release_dma_channels(struct rz_ssi_priv *ssi) ...@@ -676,15 +676,26 @@ static void rz_ssi_release_dma_channels(struct rz_ssi_priv *ssi)
static int rz_ssi_dma_request(struct rz_ssi_priv *ssi, struct device *dev) static int rz_ssi_dma_request(struct rz_ssi_priv *ssi, struct device *dev)
{ {
ssi->playback.dma_ch = dma_request_chan(dev, "tx"); ssi->playback.dma_ch = dma_request_chan(dev, "tx");
if (IS_ERR(ssi->playback.dma_ch))
ssi->playback.dma_ch = NULL;
ssi->capture.dma_ch = dma_request_chan(dev, "rx"); ssi->capture.dma_ch = dma_request_chan(dev, "rx");
if (IS_ERR(ssi->capture.dma_ch))
ssi->capture.dma_ch = NULL;
if (!ssi->playback.dma_ch && !ssi->capture.dma_ch) { if (!ssi->playback.dma_ch && !ssi->capture.dma_ch) {
ssi->playback.dma_ch = dma_request_chan(dev, "rt"); ssi->playback.dma_ch = dma_request_chan(dev, "rt");
if (!ssi->playback.dma_ch) if (IS_ERR(ssi->playback.dma_ch)) {
ssi->playback.dma_ch = NULL;
goto no_dma; goto no_dma;
}
ssi->dma_rt = true; ssi->dma_rt = true;
} }
if (!rz_ssi_is_dma_enabled(ssi))
goto no_dma;
if (ssi->playback.dma_ch && if (ssi->playback.dma_ch &&
(rz_ssi_dma_slave_config(ssi, ssi->playback.dma_ch, true) < 0)) (rz_ssi_dma_slave_config(ssi, ssi->playback.dma_ch, true) < 0))
goto no_dma; goto no_dma;
......
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