ASoC: dmaengine: Drop unused iov_iter for process callback
Subsystems (7)
PATCH 1/2 ASoC: dmaengine: Drop unused iov_iter for process callback
Passing the iov_iter to the process callback is rather buggy, as the iterator has been already processed for playback. Similarly, it makes the copy for capture buggy after the process callback reading the iterator out. Moreover, all existing process callbacks don't refer to the passed iterator at all. So, it's better to drop the argument from the process callback.
--- include/sound/dmaengine_pcm.h | 2 +- sound/soc/atmel/mchp-pdmc.c | 2 +- sound/soc/soc-generic-dmaengine-pcm.c | 4 ++-- sound/soc/stm/stm32_sai_sub.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
include/sound/dmaengine_pcm.h +1 -1
@@ -142,7 +142,7 @@ struct snd_dmaengine_pcm_config { struct snd_pcm_substream *substream);int (*process)(struct snd_pcm_substream *substream,int channel,unsigned long hwoff, -struct iov_iter *buf,unsigned long bytes); +unsigned long bytes);dma_filter_fn compat_filter_fn;struct device *dma_dev;const char *chan_names[SNDRV_PCM_STREAM_LAST +1 ];
sound/soc/atmel/mchp-pdmc.c +1 -1
@@ -954,7 +954,7 @@ static int mchp_pdmc_dt_init(struct mchp_pdmc *dd)/* used to clean the channel index found on RHR's MSB */ static int mchp_pdmc_process (struct snd_pcm_substream *substream,int channel,unsigned long hwoff, -struct iov_iter *buf,unsigned long bytes) +unsigned long bytes) {struct snd_pcm_runtime *runtime = substream->runtime; u8 *dma_ptr = runtime->dma_area + hwoff +
sound/soc/soc-generic-dmaengine-pcm.c +2 -2
@@ -296,7 +296,7 @@ static int dmaengine_copy(struct snd_soc_component *component,struct dmaengine_pcm *pcm =soc_component_to_pcm (component);int (*process)(struct snd_pcm_substream *substream,int channel,unsigned long hwoff, -struct iov_iter *buf,unsigned long bytes) = pcm->config->process; +unsigned long bytes) = pcm->config->process;bool is_playback = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ;void *dma_ptr = runtime->dma_area + hwoff + channel * (runtime->dma_bytes / runtime->channels);
@@ -306,7 +306,7 @@ static int dmaengine_copy(struct snd_soc_component *component,return -EFAULT ;if (process) { -int ret =process (substream, channel, hwoff, buf, bytes); +int ret =process (substream, channel, hwoff, bytes);if (ret <0 )return ret; }
sound/soc/stm/stm32_sai_sub.c +1 -1
@@ -1246,7 +1246,7 @@ static const struct snd_soc_dai_ops stm32_sai_pcm_dai_ops2 = {static int stm32_sai_pcm_process_spdif (struct snd_pcm_substream *substream,int channel,unsigned long hwoff, -struct iov_iter *buf,unsigned long bytes) +unsigned long bytes) {struct snd_pcm_runtime *runtime = substream->runtime;struct snd_soc_pcm_runtime *rtd =asoc_substream_to_rtd (substream);
Signature · 1 line
2.35.3
PATCH 2/2 ASoC: Name iov_iter argument as iterator instead of buffer
While transitioning ASoC code for iov_iter usages, I kept the argument name as "buf" as the original code. But, iov_iter is an iterator, and using the name "buf" may be misleading: the crucial difference is that iov_iter can be proceeded after the operation, hence it can't be passed twice, while a simple "buffer" sounds as if reusable.
To make the usage clearer, rename the argument from "buf" to "iter". There is no functional changes, just names.
--- include/sound/soc-component.h | 4 ++-- sound/soc/soc-component.c | 4 ++-- sound/soc/soc-generic-dmaengine-pcm.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
include/sound/soc-component.h +2 -2
@@ -139,7 +139,7 @@ struct snd_soc_component_driver { struct snd_pcm_audio_tstamp_report *audio_tstamp_report);int (*copy)(struct snd_soc_component *component,struct snd_pcm_substream *substream,int channel, -unsigned long pos,struct iov_iter *buf, +unsigned long pos,struct iov_iter *iter,unsigned long bytes); struct page *(*page)(struct snd_soc_component *component, struct snd_pcm_substream *substream,
@@ -511,7 +511,7 @@ int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,int snd_soc_pcm_component_sync_stop (struct snd_pcm_substream *substream);int snd_soc_pcm_component_copy (struct snd_pcm_substream *substream,int channel,unsigned long pos, -struct iov_iter *buf,unsigned long bytes); +struct iov_iter *iter,unsigned long bytes);struct page *snd_soc_pcm_component_page (struct snd_pcm_substream *substream,unsigned long offset); int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
sound/soc/soc-component.c +2 -2
@@ -1054,7 +1054,7 @@ int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream)int snd_soc_pcm_component_copy (struct snd_pcm_substream *substream,int channel,unsigned long pos, -struct iov_iter *buf,unsigned long bytes) +struct iov_iter *iter,unsigned long bytes) {struct snd_soc_pcm_runtime *rtd =asoc_substream_to_rtd (substream);struct snd_soc_component *component;
@@ -1065,7 +1065,7 @@ int snd_soc_pcm_component_copy(struct snd_pcm_substream *substream,if (component->driver->copy)return soc_component_ret (component, component->driver->copy (component, substream, - channel, pos, buf, bytes)); + channel, pos, iter, bytes));return -EINVAL ; }
sound/soc/soc-generic-dmaengine-pcm.c +3 -3
@@ -290,7 +290,7 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer(static int dmaengine_copy (struct snd_soc_component *component,struct snd_pcm_substream *substream,int channel,unsigned long hwoff, -struct iov_iter *buf,unsigned long bytes) +struct iov_iter *iter,unsigned long bytes) {struct snd_pcm_runtime *runtime = substream->runtime;struct dmaengine_pcm *pcm =soc_component_to_pcm (component);
@@ -302,7 +302,7 @@ static int dmaengine_copy(struct snd_soc_component *component, channel * (runtime->dma_bytes / runtime->channels);if (is_playback) -if (copy_from_iter (dma_ptr, bytes, buf) != bytes) +if (copy_from_iter (dma_ptr, bytes, iter) != bytes)return -EFAULT ;if (process) {
@@ -312,7 +312,7 @@ static int dmaengine_copy(struct snd_soc_component *component, }if (!is_playback) -if (copy_to_iter (dma_ptr, bytes, buf) != bytes) +if (copy_to_iter (dma_ptr, bytes, iter) != bytes)return -EFAULT ;return 0 ;
Signature · 1 line
2.35.3
Re: [PATCH 2/2] ASoC: Name iov_iter argument as iterator instead of buffer
Quoted 5 lines · Takashi Iwai
While transitioning ASoC code for
iov_iterusages, I kept the argument name as "buf" as the original code. But,iov_iteris an iterator, and using the name "buf" may be misleading: the crucial difference is thatiov_itercan be proceeded after the operation, hence it can't be passed twice, while a simple "buffer" sounds as if reusable.
Quoted 6 lines · Takashi Iwai
Passing the
iov_iterto the process callback is rather buggy, as the iterator has been already processed for playback. Similarly, it makes the copy for capture buggy after the process callback reading the iterator out. Moreover, all existing process callbacks don't refer to the passed iterator at all. So, it's better to drop the argument from the process callback.