ASoC: core: Two step component registration
Modify snd_soc_add_component so it calls snd_soc_component_initialize no longer and thus providing true two-step registration. Drivers may choose to change component's fields before actually adding it to ASoC subsystem. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20200731144146.6678-4-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
7274d4cd85
commit
ea029dd8d0
@ -417,11 +417,9 @@ int snd_soc_poweroff(struct device *dev);
|
|||||||
int snd_soc_component_initialize(struct snd_soc_component *component,
|
int snd_soc_component_initialize(struct snd_soc_component *component,
|
||||||
const struct snd_soc_component_driver *driver,
|
const struct snd_soc_component_driver *driver,
|
||||||
struct device *dev);
|
struct device *dev);
|
||||||
int snd_soc_add_component(struct device *dev,
|
int snd_soc_add_component(struct snd_soc_component *component,
|
||||||
struct snd_soc_component *component,
|
struct snd_soc_dai_driver *dai_drv,
|
||||||
const struct snd_soc_component_driver *component_driver,
|
int num_dai);
|
||||||
struct snd_soc_dai_driver *dai_drv,
|
|
||||||
int num_dai);
|
|
||||||
int snd_soc_register_component(struct device *dev,
|
int snd_soc_register_component(struct device *dev,
|
||||||
const struct snd_soc_component_driver *component_driver,
|
const struct snd_soc_component_driver *component_driver,
|
||||||
struct snd_soc_dai_driver *dai_drv, int num_dai);
|
struct snd_soc_dai_driver *dai_drv, int num_dai);
|
||||||
|
@ -2460,22 +2460,16 @@ int snd_soc_component_initialize(struct snd_soc_component *component,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(snd_soc_component_initialize);
|
EXPORT_SYMBOL_GPL(snd_soc_component_initialize);
|
||||||
|
|
||||||
int snd_soc_add_component(struct device *dev,
|
int snd_soc_add_component(struct snd_soc_component *component,
|
||||||
struct snd_soc_component *component,
|
struct snd_soc_dai_driver *dai_drv,
|
||||||
const struct snd_soc_component_driver *component_driver,
|
int num_dai)
|
||||||
struct snd_soc_dai_driver *dai_drv,
|
|
||||||
int num_dai)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_lock(&client_mutex);
|
mutex_lock(&client_mutex);
|
||||||
|
|
||||||
ret = snd_soc_component_initialize(component, component_driver, dev);
|
if (component->driver->endianness) {
|
||||||
if (ret)
|
|
||||||
goto err_free;
|
|
||||||
|
|
||||||
if (component_driver->endianness) {
|
|
||||||
for (i = 0; i < num_dai; i++) {
|
for (i = 0; i < num_dai; i++) {
|
||||||
convert_endianness_formats(&dai_drv[i].playback);
|
convert_endianness_formats(&dai_drv[i].playback);
|
||||||
convert_endianness_formats(&dai_drv[i].capture);
|
convert_endianness_formats(&dai_drv[i].capture);
|
||||||
@ -2484,7 +2478,8 @@ int snd_soc_add_component(struct device *dev,
|
|||||||
|
|
||||||
ret = snd_soc_register_dais(component, dai_drv, num_dai);
|
ret = snd_soc_register_dais(component, dai_drv, num_dai);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "ASoC: Failed to register DAIs: %d\n", ret);
|
dev_err(component->dev, "ASoC: Failed to register DAIs: %d\n",
|
||||||
|
ret);
|
||||||
goto err_cleanup;
|
goto err_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2502,7 +2497,7 @@ int snd_soc_add_component(struct device *dev,
|
|||||||
err_cleanup:
|
err_cleanup:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
snd_soc_del_component_unlocked(component);
|
snd_soc_del_component_unlocked(component);
|
||||||
err_free:
|
|
||||||
mutex_unlock(&client_mutex);
|
mutex_unlock(&client_mutex);
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
@ -2518,13 +2513,17 @@ int snd_soc_register_component(struct device *dev,
|
|||||||
int num_dai)
|
int num_dai)
|
||||||
{
|
{
|
||||||
struct snd_soc_component *component;
|
struct snd_soc_component *component;
|
||||||
|
int ret;
|
||||||
|
|
||||||
component = devm_kzalloc(dev, sizeof(*component), GFP_KERNEL);
|
component = devm_kzalloc(dev, sizeof(*component), GFP_KERNEL);
|
||||||
if (!component)
|
if (!component)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
return snd_soc_add_component(dev, component, component_driver,
|
ret = snd_soc_component_initialize(component, component_driver, dev);
|
||||||
dai_drv, num_dai);
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return snd_soc_add_component(component, dai_drv, num_dai);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(snd_soc_register_component);
|
EXPORT_SYMBOL_GPL(snd_soc_register_component);
|
||||||
|
|
||||||
|
@ -424,6 +424,7 @@ static void dmaengine_pcm_release_chan(struct dmaengine_pcm *pcm)
|
|||||||
int snd_dmaengine_pcm_register(struct device *dev,
|
int snd_dmaengine_pcm_register(struct device *dev,
|
||||||
const struct snd_dmaengine_pcm_config *config, unsigned int flags)
|
const struct snd_dmaengine_pcm_config *config, unsigned int flags)
|
||||||
{
|
{
|
||||||
|
const struct snd_soc_component_driver *driver;
|
||||||
struct dmaengine_pcm *pcm;
|
struct dmaengine_pcm *pcm;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -442,12 +443,15 @@ int snd_dmaengine_pcm_register(struct device *dev,
|
|||||||
goto err_free_dma;
|
goto err_free_dma;
|
||||||
|
|
||||||
if (config && config->process)
|
if (config && config->process)
|
||||||
ret = snd_soc_add_component(dev, &pcm->component,
|
driver = &dmaengine_pcm_component_process;
|
||||||
&dmaengine_pcm_component_process,
|
|
||||||
NULL, 0);
|
|
||||||
else
|
else
|
||||||
ret = snd_soc_add_component(dev, &pcm->component,
|
driver = &dmaengine_pcm_component;
|
||||||
&dmaengine_pcm_component, NULL, 0);
|
|
||||||
|
ret = snd_soc_component_initialize(&pcm->component, driver, dev);
|
||||||
|
if (ret)
|
||||||
|
goto err_free_dma;
|
||||||
|
|
||||||
|
ret = snd_soc_add_component(&pcm->component, NULL, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_free_dma;
|
goto err_free_dma;
|
||||||
|
|
||||||
|
@ -344,12 +344,17 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
|
|||||||
component = devm_kzalloc(&pdev->dev, sizeof(*component), GFP_KERNEL);
|
component = devm_kzalloc(&pdev->dev, sizeof(*component), GFP_KERNEL);
|
||||||
if (!component)
|
if (!component)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
ret = snd_soc_component_initialize(component,
|
||||||
|
&stm32_adfsdm_soc_platform,
|
||||||
|
&pdev->dev);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
#ifdef CONFIG_DEBUG_FS
|
#ifdef CONFIG_DEBUG_FS
|
||||||
component->debugfs_prefix = "pcm";
|
component->debugfs_prefix = "pcm";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = snd_soc_add_component(&pdev->dev, component,
|
ret = snd_soc_add_component(component, NULL, 0);
|
||||||
&stm32_adfsdm_soc_platform, NULL, 0);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(&pdev->dev, "%s: Failed to register PCM platform\n",
|
dev_err(&pdev->dev, "%s: Failed to register PCM platform\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
Loading…
Reference in New Issue
Block a user