Commit 7274d4cd8506bbff9bf2d7c2f73b2febff99abef

Authored by Cezary Rojewski
Committed by Mark Brown
1 parent 08ff7209fa

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 <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20200731144146.6678-3-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

Showing 2 changed files with 9 additions and 11 deletions Side-by-side Diff

... ... @@ -416,7 +416,7 @@
416 416 int snd_soc_poweroff(struct device *dev);
417 417 int snd_soc_component_initialize(struct snd_soc_component *component,
418 418 const struct snd_soc_component_driver *driver,
419   - struct device *dev, const char *name);
  419 + struct device *dev);
420 420 int snd_soc_add_component(struct device *dev,
421 421 struct snd_soc_component *component,
422 422 const struct snd_soc_component_driver *component_driver,
sound/soc/soc-core.c
... ... @@ -2440,14 +2440,19 @@
2440 2440  
2441 2441 int snd_soc_component_initialize(struct snd_soc_component *component,
2442 2442 const struct snd_soc_component_driver *driver,
2443   - struct device *dev, const char *name)
  2443 + struct device *dev)
2444 2444 {
2445 2445 INIT_LIST_HEAD(&component->dai_list);
2446 2446 INIT_LIST_HEAD(&component->dobj_list);
2447 2447 INIT_LIST_HEAD(&component->card_list);
2448 2448 mutex_init(&component->io_mutex);
2449 2449  
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 +
2451 2456 component->dev = dev;
2452 2457 component->driver = driver;
2453 2458  
2454 2459  
2455 2460  
... ... @@ -2461,19 +2466,12 @@
2461 2466 struct snd_soc_dai_driver *dai_drv,
2462 2467 int num_dai)
2463 2468 {
2464   - const char *name = fmt_single_name(dev, &component->id);
2465 2469 int ret;
2466 2470 int i;
2467 2471  
2468   - if (!name) {
2469   - dev_err(dev, "ASoC: Failed to allocate name\n");
2470   - return -ENOMEM;
2471   - }
2472   -
2473 2472 mutex_lock(&client_mutex);
2474 2473  
2475   - ret = snd_soc_component_initialize(component, component_driver,
2476   - dev, name);
  2474 + ret = snd_soc_component_initialize(component, component_driver, dev);
2477 2475 if (ret)
2478 2476 goto err_free;
2479 2477