Skip to content

Commit 7274d4c

Browse files
crojewsk-intelbroonie
authored andcommitted
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: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 08ff720 commit 7274d4c

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

include/sound/soc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static inline int snd_soc_resume(struct device *dev)
416416
int snd_soc_poweroff(struct device *dev);
417417
int snd_soc_component_initialize(struct snd_soc_component *component,
418418
const struct snd_soc_component_driver *driver,
419-
struct device *dev, const char *name);
419+
struct device *dev);
420420
int snd_soc_add_component(struct device *dev,
421421
struct snd_soc_component *component,
422422
const struct snd_soc_component_driver *component_driver,

sound/soc/soc-core.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,14 +2440,19 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
24402440

24412441
int snd_soc_component_initialize(struct snd_soc_component *component,
24422442
const struct snd_soc_component_driver *driver,
2443-
struct device *dev, const char *name)
2443+
struct device *dev)
24442444
{
24452445
INIT_LIST_HEAD(&component->dai_list);
24462446
INIT_LIST_HEAD(&component->dobj_list);
24472447
INIT_LIST_HEAD(&component->card_list);
24482448
mutex_init(&component->io_mutex);
24492449

2450-
component->name = name;
2450+
component->name = fmt_single_name(dev, &component->id);
2451+
if (!component->name) {
2452+
dev_err(dev, "ASoC: Failed to allocate name\n");
2453+
return -ENOMEM;
2454+
}
2455+
24512456
component->dev = dev;
24522457
component->driver = driver;
24532458

@@ -2461,19 +2466,12 @@ int snd_soc_add_component(struct device *dev,
24612466
struct snd_soc_dai_driver *dai_drv,
24622467
int num_dai)
24632468
{
2464-
const char *name = fmt_single_name(dev, &component->id);
24652469
int ret;
24662470
int i;
24672471

2468-
if (!name) {
2469-
dev_err(dev, "ASoC: Failed to allocate name\n");
2470-
return -ENOMEM;
2471-
}
2472-
24732472
mutex_lock(&client_mutex);
24742473

2475-
ret = snd_soc_component_initialize(component, component_driver,
2476-
dev, name);
2474+
ret = snd_soc_component_initialize(component, component_driver, dev);
24772475
if (ret)
24782476
goto err_free;
24792477

0 commit comments

Comments
 (0)