Skip to content

Commit

Permalink
Merge series "ASoC: core: Two step component registration" from Cezar…
Browse files Browse the repository at this point in the history
…y Rojewski <cezary.rojewski@intel.com>:

Provide a mechanism for true two-step component registration. This
mimics device registration flow where initialization is the first step
while addition goes as second in line. Drivers may choose to modify
component's fields before registering component to ASoC subsystem via
snd_soc_add_component.

Patchset achieves status quo - behavior of snd_soc_register_component
remains unchanged.

Cezary Rojewski (3):
  ASoC: core: Relocate and expose snd_soc_component_initialize
  ASoC: core: Simplify snd_soc_component_initialize declaration
  ASoC: core: Two step component registration

 include/sound/soc-component.h         |  3 --
 include/sound/soc.h                   | 11 +++---
 sound/soc/soc-component.c             | 16 ---------
 sound/soc/soc-core.c                  | 52 +++++++++++++++++----------
 sound/soc/soc-generic-dmaengine-pcm.c | 14 +++++---
 sound/soc/stm/stm32_adfsdm.c          |  9 +++--
 6 files changed, 55 insertions(+), 50 deletions(-)

--
2.17.1
  • Loading branch information
Mark Brown committed Jul 31, 2020

Unverified

No user is associated with the committer email.
2 parents 2dbf11e + ea029dd commit 8e34f1e
Showing 6 changed files with 55 additions and 50 deletions.
3 changes: 0 additions & 3 deletions include/sound/soc-component.h
Original file line number Diff line number Diff line change
@@ -325,9 +325,6 @@ static inline int snd_soc_component_cache_sync(
return regcache_sync(component->regmap);
}

int snd_soc_component_initialize(struct snd_soc_component *component,
const struct snd_soc_component_driver *driver,
struct device *dev, const char *name);
void snd_soc_component_set_aux(struct snd_soc_component *component,
struct snd_soc_aux_dev *aux);
int snd_soc_component_init(struct snd_soc_component *component);
11 changes: 6 additions & 5 deletions include/sound/soc.h
Original file line number Diff line number Diff line change
@@ -414,11 +414,12 @@ static inline int snd_soc_resume(struct device *dev)
}
#endif
int snd_soc_poweroff(struct device *dev);
int snd_soc_add_component(struct device *dev,
struct snd_soc_component *component,
const struct snd_soc_component_driver *component_driver,
struct snd_soc_dai_driver *dai_drv,
int num_dai);
int snd_soc_component_initialize(struct snd_soc_component *component,
const struct snd_soc_component_driver *driver,
struct device *dev);
int snd_soc_add_component(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv,
int num_dai);
int snd_soc_register_component(struct device *dev,
const struct snd_soc_component_driver *component_driver,
struct snd_soc_dai_driver *dai_drv, int num_dai);
16 changes: 0 additions & 16 deletions sound/soc/soc-component.c
Original file line number Diff line number Diff line change
@@ -33,22 +33,6 @@ static inline int _soc_component_ret(struct snd_soc_component *component,
return ret;
}

int snd_soc_component_initialize(struct snd_soc_component *component,
const struct snd_soc_component_driver *driver,
struct device *dev, const char *name)
{
INIT_LIST_HEAD(&component->dai_list);
INIT_LIST_HEAD(&component->dobj_list);
INIT_LIST_HEAD(&component->card_list);
mutex_init(&component->io_mutex);

component->name = name;
component->dev = dev;
component->driver = driver;

return 0;
}

void snd_soc_component_set_aux(struct snd_soc_component *component,
struct snd_soc_aux_dev *aux)
{
52 changes: 33 additions & 19 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
@@ -2438,29 +2438,38 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
list_del(&component->list);
}

int snd_soc_add_component(struct device *dev,
struct snd_soc_component *component,
const struct snd_soc_component_driver *component_driver,
struct snd_soc_dai_driver *dai_drv,
int num_dai)
int snd_soc_component_initialize(struct snd_soc_component *component,
const struct snd_soc_component_driver *driver,
struct device *dev)
{
const char *name = fmt_single_name(dev, &component->id);
int ret;
int i;
INIT_LIST_HEAD(&component->dai_list);
INIT_LIST_HEAD(&component->dobj_list);
INIT_LIST_HEAD(&component->card_list);
mutex_init(&component->io_mutex);

if (!name) {
component->name = fmt_single_name(dev, &component->id);
if (!component->name) {
dev_err(dev, "ASoC: Failed to allocate name\n");
return -ENOMEM;
}

mutex_lock(&client_mutex);
component->dev = dev;
component->driver = driver;

ret = snd_soc_component_initialize(component, component_driver,
dev, name);
if (ret)
goto err_free;
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_initialize);

int snd_soc_add_component(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv,
int num_dai)
{
int ret;
int i;

mutex_lock(&client_mutex);

if (component_driver->endianness) {
if (component->driver->endianness) {
for (i = 0; i < num_dai; i++) {
convert_endianness_formats(&dai_drv[i].playback);
convert_endianness_formats(&dai_drv[i].capture);
@@ -2469,7 +2478,8 @@ int snd_soc_add_component(struct device *dev,

ret = snd_soc_register_dais(component, dai_drv, num_dai);
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;
}

@@ -2487,7 +2497,7 @@ int snd_soc_add_component(struct device *dev,
err_cleanup:
if (ret < 0)
snd_soc_del_component_unlocked(component);
err_free:

mutex_unlock(&client_mutex);

if (ret == 0)
@@ -2503,13 +2513,17 @@ int snd_soc_register_component(struct device *dev,
int num_dai)
{
struct snd_soc_component *component;
int ret;

component = devm_kzalloc(dev, sizeof(*component), GFP_KERNEL);
if (!component)
return -ENOMEM;

return snd_soc_add_component(dev, component, component_driver,
dai_drv, num_dai);
ret = snd_soc_component_initialize(component, component_driver, dev);
if (ret < 0)
return ret;

return snd_soc_add_component(component, dai_drv, num_dai);
}
EXPORT_SYMBOL_GPL(snd_soc_register_component);

14 changes: 9 additions & 5 deletions sound/soc/soc-generic-dmaengine-pcm.c
Original file line number Diff line number Diff line change
@@ -424,6 +424,7 @@ static void dmaengine_pcm_release_chan(struct dmaengine_pcm *pcm)
int snd_dmaengine_pcm_register(struct device *dev,
const struct snd_dmaengine_pcm_config *config, unsigned int flags)
{
const struct snd_soc_component_driver *driver;
struct dmaengine_pcm *pcm;
int ret;

@@ -442,12 +443,15 @@ int snd_dmaengine_pcm_register(struct device *dev,
goto err_free_dma;

if (config && config->process)
ret = snd_soc_add_component(dev, &pcm->component,
&dmaengine_pcm_component_process,
NULL, 0);
driver = &dmaengine_pcm_component_process;
else
ret = snd_soc_add_component(dev, &pcm->component,
&dmaengine_pcm_component, NULL, 0);
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);
if (ret)
goto err_free_dma;

9 changes: 7 additions & 2 deletions sound/soc/stm/stm32_adfsdm.c
Original file line number Diff line number Diff line change
@@ -344,12 +344,17 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
component = devm_kzalloc(&pdev->dev, sizeof(*component), GFP_KERNEL);
if (!component)
return -ENOMEM;

ret = snd_soc_component_initialize(component,
&stm32_adfsdm_soc_platform,
&pdev->dev);
if (ret < 0)
return ret;
#ifdef CONFIG_DEBUG_FS
component->debugfs_prefix = "pcm";
#endif

ret = snd_soc_add_component(&pdev->dev, component,
&stm32_adfsdm_soc_platform, NULL, 0);
ret = snd_soc_add_component(component, NULL, 0);
if (ret < 0)
dev_err(&pdev->dev, "%s: Failed to register PCM platform\n",
__func__);

0 comments on commit 8e34f1e

Please sign in to comment.