ASoC: soc-generic-dmaengine-pcm: use snd_soc_register_component()

it is calling snd_soc_component_initialize() / snd_soc_add_component().
We can now use snd_soc_register_component() instead.

It is using container_of() to get dmaengine_pcm from component, but
will not be able to use it when capsuling has done.
We can now use snd_soc_component_to_priv() instead.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/87ldb2rz79.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto
2026-07-23 06:34:50 +00:00
committed by Mark Brown
parent c8eaeedcac
commit 695cc675f0
3 changed files with 19 additions and 21 deletions

View File

@@ -175,12 +175,6 @@ int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream,
struct dmaengine_pcm {
struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1];
const struct snd_dmaengine_pcm_config *config;
struct snd_soc_component component;
unsigned int flags;
};
static inline struct dmaengine_pcm *soc_component_to_pcm(struct snd_soc_component *p)
{
return container_of(p, struct dmaengine_pcm, component);
}
#endif

View File

@@ -219,7 +219,9 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
*/
component_be = snd_soc_lookup_component_nolocked(dev_be, SND_DMAENGINE_PCM_DRV_NAME);
if (component_be) {
be_chan = soc_component_to_pcm(component_be)->chan[substream->stream];
struct dmaengine_pcm *pcm = snd_soc_component_to_priv(component_be);
be_chan = pcm->chan[substream->stream];
tmp_chan = be_chan;
}
if (!tmp_chan) {

View File

@@ -78,7 +78,7 @@ static int dmaengine_pcm_hw_params(struct snd_soc_component *component,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
struct dmaengine_pcm *pcm = snd_soc_component_to_priv(component);
struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
struct dma_slave_config slave_config;
int ret;
@@ -100,7 +100,7 @@ dmaengine_pcm_set_runtime_hwparams(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
struct dmaengine_pcm *pcm = snd_soc_component_to_priv(component);
struct device *dma_dev = dmaengine_dma_dev(pcm, substream);
struct dma_chan *chan = pcm->chan[substream->stream];
struct snd_dmaengine_dai_dma_data *dma_data;
@@ -149,7 +149,7 @@ dmaengine_pcm_set_runtime_hwparams(struct snd_soc_component *component,
static int dmaengine_pcm_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
struct dmaengine_pcm *pcm = snd_soc_component_to_priv(component);
struct dma_chan *chan = pcm->chan[substream->stream];
int ret;
@@ -177,7 +177,7 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel(
struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_substream *substream)
{
struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
struct dmaengine_pcm *pcm = snd_soc_component_to_priv(component);
struct snd_dmaengine_dai_dma_data *dma_data;
if (rtd->dai_link->num_cpus > 1) {
@@ -220,7 +220,7 @@ static bool dmaengine_pcm_can_report_residue(struct device *dev,
static int dmaengine_pcm_new(struct snd_soc_component *component,
struct snd_soc_pcm_runtime *rtd)
{
struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
struct dmaengine_pcm *pcm = snd_soc_component_to_priv(component);
const struct snd_dmaengine_pcm_config *config = pcm->config;
struct device *dev = component->dev;
size_t prealloc_buffer_size;
@@ -280,7 +280,7 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer(
struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
struct dmaengine_pcm *pcm = snd_soc_component_to_priv(component);
if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE)
return snd_dmaengine_pcm_pointer_no_residue(substream);
@@ -294,7 +294,7 @@ static int dmaengine_copy(struct snd_soc_component *component,
struct iov_iter *iter, unsigned long bytes)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
struct dmaengine_pcm *pcm = snd_soc_component_to_priv(component);
int (*process)(struct snd_pcm_substream *substream,
int channel, unsigned long hwoff,
unsigned long bytes) = pcm->config->process;
@@ -463,10 +463,15 @@ static const struct snd_dmaengine_pcm_config snd_dmaengine_pcm_default_config =
int snd_dmaengine_pcm_register(struct device *dev,
const struct snd_dmaengine_pcm_config *config, unsigned int flags)
{
struct snd_soc_component *component;
const struct snd_soc_component_driver *driver;
struct dmaengine_pcm *pcm;
int ret;
component = snd_soc_component_alloc(dev);
if (!component)
return -ENOMEM;
pcm = kzalloc_obj(*pcm);
if (!pcm)
return -ENOMEM;
@@ -477,7 +482,8 @@ int snd_dmaengine_pcm_register(struct device *dev,
pcm->flags = flags;
if (config->name)
pcm->component.name = config->name;
snd_soc_component_set_name(component, config->name);
snd_soc_component_set_priv(component, pcm);
ret = dmaengine_pcm_request_chan_of(pcm, dev, config);
if (ret)
@@ -488,11 +494,7 @@ int snd_dmaengine_pcm_register(struct device *dev,
else
driver = &dmaengine_pcm_component;
ret = snd_soc_component_initialize(&pcm->component, driver, dev);
if (ret)
goto err_free_dma;
ret = snd_soc_add_component(&pcm->component, NULL, 0);
ret = snd_soc_register_component(component, driver, NULL, 0);
if (ret)
goto err_free_dma;
@@ -521,7 +523,7 @@ void snd_dmaengine_pcm_unregister(struct device *dev)
if (!component)
return;
pcm = soc_component_to_pcm(component);
pcm = snd_soc_component_to_priv(component);
snd_soc_unregister_component_by_driver(dev, component->driver);
dmaengine_pcm_release_chan(pcm);