Browse Source

ASoC: Track which components have been registered with snd_soc_register_component()

snd_soc_unregister_component() takes the parent device of the component as a
parameter and then looks up the component based on this. This is a problem if
multiple components are registered for the same parent device. Currently drivers
do not do this, but some drivers register a CPU DAI component and a platform for
the same parent device. This will become a problem once platforms are also made
components. To make sure that snd_soc_unregister_component() will not
accidentally unregister the platform in such a case only consider components
that were registered with snd_soc_register_component(). This is only meant as
short term stopgap solution to be able to continue componentisation. Long term
we'll need something different.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Lars-Peter Clausen 11 năm trước cách đây
mục cha
commit
98e639fb8a
2 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 1 0
      include/sound/soc.h
  2. 2 1
      sound/soc/soc-core.c

+ 1 - 0
include/sound/soc.h

@@ -662,6 +662,7 @@ struct snd_soc_component {
 	unsigned int active;
 	unsigned int active;
 
 
 	unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
 	unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
+	unsigned int registered_as_component:1;
 
 
 	struct list_head list;
 	struct list_head list;
 
 

+ 2 - 1
sound/soc/soc-core.c

@@ -3879,6 +3879,7 @@ int snd_soc_register_component(struct device *dev,
 	}
 	}
 
 
 	cmpnt->ignore_pmdown_time = true;
 	cmpnt->ignore_pmdown_time = true;
+	cmpnt->registered_as_component = true;
 
 
 	return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, NULL,
 	return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, NULL,
 					    dai_drv, num_dai, true);
 					    dai_drv, num_dai, true);
@@ -3894,7 +3895,7 @@ void snd_soc_unregister_component(struct device *dev)
 	struct snd_soc_component *cmpnt;
 	struct snd_soc_component *cmpnt;
 
 
 	list_for_each_entry(cmpnt, &component_list, list) {
 	list_for_each_entry(cmpnt, &component_list, list) {
-		if (dev == cmpnt->dev)
+		if (dev == cmpnt->dev && cmpnt->registered_as_component)
 			goto found;
 			goto found;
 	}
 	}
 	return;
 	return;