Commit 7274d4cd authored by Cezary Rojewski's avatar Cezary Rojewski Committed by Mark Brown

ASoC: core: Simplify snd_soc_component_initialize declaration

Move 'name' field initialization responsibility back to
snd_soc_component_initialize to prepare snd_soc_add_component function
for being called separatelly as a second registration step.
Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20200731144146.6678-3-cezary.rojewski@intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 08ff7209
...@@ -416,7 +416,7 @@ static inline int snd_soc_resume(struct device *dev) ...@@ -416,7 +416,7 @@ static inline int snd_soc_resume(struct device *dev)
int snd_soc_poweroff(struct device *dev); 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, const char *name); struct device *dev);
int snd_soc_add_component(struct device *dev, int snd_soc_add_component(struct device *dev,
struct snd_soc_component *component, struct snd_soc_component *component,
const struct snd_soc_component_driver *component_driver, const struct snd_soc_component_driver *component_driver,
......
...@@ -2440,14 +2440,19 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component) ...@@ -2440,14 +2440,19 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
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, const char *name) struct device *dev)
{ {
INIT_LIST_HEAD(&component->dai_list); INIT_LIST_HEAD(&component->dai_list);
INIT_LIST_HEAD(&component->dobj_list); INIT_LIST_HEAD(&component->dobj_list);
INIT_LIST_HEAD(&component->card_list); INIT_LIST_HEAD(&component->card_list);
mutex_init(&component->io_mutex); mutex_init(&component->io_mutex);
component->name = name; component->name = fmt_single_name(dev, &component->id);
if (!component->name) {
dev_err(dev, "ASoC: Failed to allocate name\n");
return -ENOMEM;
}
component->dev = dev; component->dev = dev;
component->driver = driver; component->driver = driver;
...@@ -2461,19 +2466,12 @@ int snd_soc_add_component(struct device *dev, ...@@ -2461,19 +2466,12 @@ int snd_soc_add_component(struct device *dev,
struct snd_soc_dai_driver *dai_drv, struct snd_soc_dai_driver *dai_drv,
int num_dai) int num_dai)
{ {
const char *name = fmt_single_name(dev, &component->id);
int ret; int ret;
int i; int i;
if (!name) {
dev_err(dev, "ASoC: Failed to allocate name\n");
return -ENOMEM;
}
mutex_lock(&client_mutex); mutex_lock(&client_mutex);
ret = snd_soc_component_initialize(component, component_driver, ret = snd_soc_component_initialize(component, component_driver, dev);
dev, name);
if (ret) if (ret)
goto err_free; goto err_free;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment