summaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index defd96b14c28..fe23e936e2d1 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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);