Commit 337b7b0b authored by Takashi Iwai's avatar Takashi Iwai

ALSA: pcm_dmaengine: Unify two close functions

Both snd_dmaengine_pcm_close() and
snd_dmaengine_pcm_close_release_chan() are almost identical except for
a call of dma_release_channel() in the latter.  For code
simplification, unify them internally.

Just a code refactoring, and no functional changes.

Link: https://patch.msgid.link/20240625113356.2123-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 6f7dae64
...@@ -349,13 +349,8 @@ int snd_dmaengine_pcm_open_request_chan(struct snd_pcm_substream *substream, ...@@ -349,13 +349,8 @@ int snd_dmaengine_pcm_open_request_chan(struct snd_pcm_substream *substream,
} }
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_open_request_chan); EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_open_request_chan);
/** static void __snd_dmaengine_pcm_close(struct snd_pcm_substream *substream,
* snd_dmaengine_pcm_close - Close a dmaengine based PCM substream bool release_channel)
* @substream: PCM substream
*
* Return: 0 on success, a negative error code otherwise
*/
int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream)
{ {
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream); struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
struct dma_tx_state state; struct dma_tx_state state;
...@@ -366,8 +361,20 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream) ...@@ -366,8 +361,20 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream)
dmaengine_terminate_async(prtd->dma_chan); dmaengine_terminate_async(prtd->dma_chan);
dmaengine_synchronize(prtd->dma_chan); dmaengine_synchronize(prtd->dma_chan);
if (release_channel)
dma_release_channel(prtd->dma_chan);
kfree(prtd); kfree(prtd);
}
/**
* snd_dmaengine_pcm_close - Close a dmaengine based PCM substream
* @substream: PCM substream
*
* Return: 0 on success, a negative error code otherwise
*/
int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream)
{
__snd_dmaengine_pcm_close(substream, false);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close); EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close);
...@@ -383,18 +390,7 @@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close); ...@@ -383,18 +390,7 @@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close);
*/ */
int snd_dmaengine_pcm_close_release_chan(struct snd_pcm_substream *substream) int snd_dmaengine_pcm_close_release_chan(struct snd_pcm_substream *substream)
{ {
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream); __snd_dmaengine_pcm_close(substream, true);
struct dma_tx_state state;
enum dma_status status;
status = dmaengine_tx_status(prtd->dma_chan, prtd->cookie, &state);
if (status == DMA_PAUSED)
dmaengine_terminate_async(prtd->dma_chan);
dmaengine_synchronize(prtd->dma_chan);
dma_release_channel(prtd->dma_chan);
kfree(prtd);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close_release_chan); EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close_release_chan);
......
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