mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-07 15:18:15 +00:00
ASoC: Add snd_soc_{add, remove}_platform
snd_soc_{add,remove}_platform are similar to snd_soc_register_platform and snd_soc_unregister_platform with the difference that they won't allocate and free the snd_soc_platform structure. Also add snd_soc_lookup_platform which looks up a platform by the device it has been registered for. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Stephen Warren <swarren@nvidia.com> Tested-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
8b1b054f6b
commit
71a45cda44
2 changed files with 67 additions and 24 deletions
|
@ -373,6 +373,10 @@ int snd_soc_poweroff(struct device *dev);
|
||||||
int snd_soc_register_platform(struct device *dev,
|
int snd_soc_register_platform(struct device *dev,
|
||||||
const struct snd_soc_platform_driver *platform_drv);
|
const struct snd_soc_platform_driver *platform_drv);
|
||||||
void snd_soc_unregister_platform(struct device *dev);
|
void snd_soc_unregister_platform(struct device *dev);
|
||||||
|
int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
|
||||||
|
const struct snd_soc_platform_driver *platform_drv);
|
||||||
|
void snd_soc_remove_platform(struct snd_soc_platform *platform);
|
||||||
|
struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev);
|
||||||
int snd_soc_register_codec(struct device *dev,
|
int snd_soc_register_codec(struct device *dev,
|
||||||
const struct snd_soc_codec_driver *codec_drv,
|
const struct snd_soc_codec_driver *codec_drv,
|
||||||
struct snd_soc_dai_driver *dai_drv, int num_dai);
|
struct snd_soc_dai_driver *dai_drv, int num_dai);
|
||||||
|
|
|
@ -3901,21 +3901,14 @@ void snd_soc_unregister_dais(struct device *dev, size_t count)
|
||||||
EXPORT_SYMBOL_GPL(snd_soc_unregister_dais);
|
EXPORT_SYMBOL_GPL(snd_soc_unregister_dais);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* snd_soc_register_platform - Register a platform with the ASoC core
|
* snd_soc_add_platform - Add a platform to the ASoC core
|
||||||
*
|
* @dev: The parent device for the platform
|
||||||
* @platform: platform to register
|
* @platform: The platform to add
|
||||||
|
* @platform_driver: The driver for the platform
|
||||||
*/
|
*/
|
||||||
int snd_soc_register_platform(struct device *dev,
|
int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
|
||||||
const struct snd_soc_platform_driver *platform_drv)
|
const struct snd_soc_platform_driver *platform_drv)
|
||||||
{
|
{
|
||||||
struct snd_soc_platform *platform;
|
|
||||||
|
|
||||||
dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev));
|
|
||||||
|
|
||||||
platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL);
|
|
||||||
if (platform == NULL)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
/* create platform component name */
|
/* create platform component name */
|
||||||
platform->name = fmt_single_name(dev, &platform->id);
|
platform->name = fmt_single_name(dev, &platform->id);
|
||||||
if (platform->name == NULL) {
|
if (platform->name == NULL) {
|
||||||
|
@ -3938,8 +3931,62 @@ int snd_soc_register_platform(struct device *dev,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(snd_soc_add_platform);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* snd_soc_register_platform - Register a platform with the ASoC core
|
||||||
|
*
|
||||||
|
* @platform: platform to register
|
||||||
|
*/
|
||||||
|
int snd_soc_register_platform(struct device *dev,
|
||||||
|
const struct snd_soc_platform_driver *platform_drv)
|
||||||
|
{
|
||||||
|
struct snd_soc_platform *platform;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev));
|
||||||
|
|
||||||
|
platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL);
|
||||||
|
if (platform == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
ret = snd_soc_add_platform(dev, platform, platform_drv);
|
||||||
|
if (ret)
|
||||||
|
kfree(platform);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
EXPORT_SYMBOL_GPL(snd_soc_register_platform);
|
EXPORT_SYMBOL_GPL(snd_soc_register_platform);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* snd_soc_remove_platform - Remove a platform from the ASoC core
|
||||||
|
* @platform: the platform to remove
|
||||||
|
*/
|
||||||
|
void snd_soc_remove_platform(struct snd_soc_platform *platform)
|
||||||
|
{
|
||||||
|
mutex_lock(&client_mutex);
|
||||||
|
list_del(&platform->list);
|
||||||
|
mutex_unlock(&client_mutex);
|
||||||
|
|
||||||
|
dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n",
|
||||||
|
platform->name);
|
||||||
|
kfree(platform->name);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(snd_soc_remove_platform);
|
||||||
|
|
||||||
|
struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev)
|
||||||
|
{
|
||||||
|
struct snd_soc_platform *platform;
|
||||||
|
|
||||||
|
list_for_each_entry(platform, &platform_list, list) {
|
||||||
|
if (dev == platform->dev)
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(snd_soc_lookup_platform);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* snd_soc_unregister_platform - Unregister a platform from the ASoC core
|
* snd_soc_unregister_platform - Unregister a platform from the ASoC core
|
||||||
*
|
*
|
||||||
|
@ -3949,19 +3996,11 @@ void snd_soc_unregister_platform(struct device *dev)
|
||||||
{
|
{
|
||||||
struct snd_soc_platform *platform;
|
struct snd_soc_platform *platform;
|
||||||
|
|
||||||
list_for_each_entry(platform, &platform_list, list) {
|
platform = snd_soc_lookup_platform(dev);
|
||||||
if (dev == platform->dev)
|
if (!platform)
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
found:
|
snd_soc_remove_platform(platform);
|
||||||
mutex_lock(&client_mutex);
|
|
||||||
list_del(&platform->list);
|
|
||||||
mutex_unlock(&client_mutex);
|
|
||||||
|
|
||||||
dev_dbg(dev, "ASoC: Unregistered platform '%s'\n", platform->name);
|
|
||||||
kfree(platform->name);
|
|
||||||
kfree(platform);
|
kfree(platform);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(snd_soc_unregister_platform);
|
EXPORT_SYMBOL_GPL(snd_soc_unregister_platform);
|
||||||
|
|
Loading…
Add table
Reference in a new issue