ASoC: Let snd_soc_platform subclass snd_soc_component
There is an increasing amount of code that is very similar between platforms,
CODECS and other components. Making platforms a component will allow us to
share this code. For now the patch just adds component and component_driver
fields to the platform and platform_driver structs and registers the platform as
a component. Followup patches will be used to consolidate code between the
different types of components.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 3314efb3..a95c7e5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3921,6 +3921,8 @@
int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
const struct snd_soc_platform_driver *platform_drv)
{
+ int ret;
+
/* create platform component name */
platform->name = fmt_single_name(dev, &platform->id);
if (platform->name == NULL)
@@ -3933,6 +3935,16 @@
platform->dapm.stream_event = platform_drv->stream_event;
mutex_init(&platform->mutex);
+ /* register component */
+ ret = __snd_soc_register_component(dev, &platform->component,
+ &platform_drv->component_driver,
+ NULL, NULL, 0, false);
+ if (ret < 0) {
+ dev_err(platform->component.dev,
+ "ASoC: Failed to register component: %d\n", ret);
+ return ret;
+ }
+
mutex_lock(&client_mutex);
list_add(&platform->list, &platform_list);
mutex_unlock(&client_mutex);
@@ -3974,6 +3986,8 @@
*/
void snd_soc_remove_platform(struct snd_soc_platform *platform)
{
+ snd_soc_unregister_component(platform->dev);
+
mutex_lock(&client_mutex);
list_del(&platform->list);
mutex_unlock(&client_mutex);