diff options
| author | Lars-Peter Clausen <lars@metafoo.de> | 2013-04-15 13:19:49 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-04-17 09:18:26 -0400 |
| commit | 71a45cda444f9c47bd63516cf4c24fb6d1ccb151 (patch) | |
| tree | c47295f905b9ba67ce71b72696bcafa8d43d799e | |
| parent | 8b1b054f6be2c3f94bf027ad37bc85d9ec67677f (diff) | |
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>
| -rw-r--r-- | include/sound/soc.h | 4 | ||||
| -rw-r--r-- | sound/soc/soc-core.c | 85 |
2 files changed, 66 insertions, 23 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index f619905f0a65..4429254aa195 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
| @@ -373,6 +373,10 @@ int snd_soc_poweroff(struct device *dev); | |||
| 373 | int snd_soc_register_platform(struct device *dev, | 373 | int snd_soc_register_platform(struct device *dev, |
| 374 | const struct snd_soc_platform_driver *platform_drv); | 374 | const struct snd_soc_platform_driver *platform_drv); |
| 375 | void snd_soc_unregister_platform(struct device *dev); | 375 | void snd_soc_unregister_platform(struct device *dev); |
| 376 | int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, | ||
| 377 | const struct snd_soc_platform_driver *platform_drv); | ||
| 378 | void snd_soc_remove_platform(struct snd_soc_platform *platform); | ||
| 379 | struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev); | ||
| 376 | int snd_soc_register_codec(struct device *dev, | 380 | int snd_soc_register_codec(struct device *dev, |
| 377 | const struct snd_soc_codec_driver *codec_drv, | 381 | const struct snd_soc_codec_driver *codec_drv, |
| 378 | struct snd_soc_dai_driver *dai_drv, int num_dai); | 382 | struct snd_soc_dai_driver *dai_drv, int num_dai); |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4d24b5ea3ba7..0e64af1a7df9 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
| @@ -3901,21 +3901,14 @@ void snd_soc_unregister_dais(struct device *dev, size_t count) | |||
| 3901 | EXPORT_SYMBOL_GPL(snd_soc_unregister_dais); | 3901 | EXPORT_SYMBOL_GPL(snd_soc_unregister_dais); |
| 3902 | 3902 | ||
| 3903 | /** | 3903 | /** |
| 3904 | * snd_soc_register_platform - Register a platform with the ASoC core | 3904 | * snd_soc_add_platform - Add a platform to the ASoC core |
| 3905 | * | 3905 | * @dev: The parent device for the platform |
| 3906 | * @platform: platform to register | 3906 | * @platform: The platform to add |
| 3907 | * @platform_driver: The driver for the platform | ||
| 3907 | */ | 3908 | */ |
| 3908 | int snd_soc_register_platform(struct device *dev, | 3909 | int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, |
| 3909 | const struct snd_soc_platform_driver *platform_drv) | 3910 | const struct snd_soc_platform_driver *platform_drv) |
| 3910 | { | 3911 | { |
| 3911 | struct snd_soc_platform *platform; | ||
| 3912 | |||
| 3913 | dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev)); | ||
| 3914 | |||
| 3915 | platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL); | ||
| 3916 | if (platform == NULL) | ||
| 3917 | return -ENOMEM; | ||
| 3918 | |||
| 3919 | /* create platform component name */ | 3912 | /* create platform component name */ |
| 3920 | platform->name = fmt_single_name(dev, &platform->id); | 3913 | platform->name = fmt_single_name(dev, &platform->id); |
| 3921 | if (platform->name == NULL) { | 3914 | if (platform->name == NULL) { |
| @@ -3938,30 +3931,76 @@ int snd_soc_register_platform(struct device *dev, | |||
| 3938 | 3931 | ||
| 3939 | return 0; | 3932 | return 0; |
| 3940 | } | 3933 | } |
| 3941 | EXPORT_SYMBOL_GPL(snd_soc_register_platform); | 3934 | EXPORT_SYMBOL_GPL(snd_soc_add_platform); |
| 3942 | 3935 | ||
| 3943 | /** | 3936 | /** |
| 3944 | * snd_soc_unregister_platform - Unregister a platform from the ASoC core | 3937 | * snd_soc_register_platform - Register a platform with the ASoC core |
| 3945 | * | 3938 | * |
| 3946 | * @platform: platform to unregister | 3939 | * @platform: platform to register |
| 3947 | */ | 3940 | */ |
| 3948 | void snd_soc_unregister_platform(struct device *dev) | 3941 | int snd_soc_register_platform(struct device *dev, |
| 3942 | const struct snd_soc_platform_driver *platform_drv) | ||
| 3949 | { | 3943 | { |
| 3950 | struct snd_soc_platform *platform; | 3944 | struct snd_soc_platform *platform; |
| 3945 | int ret; | ||
| 3951 | 3946 | ||
| 3952 | list_for_each_entry(platform, &platform_list, list) { | 3947 | dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev)); |
| 3953 | if (dev == platform->dev) | ||
| 3954 | goto found; | ||
| 3955 | } | ||
| 3956 | return; | ||
| 3957 | 3948 | ||
| 3958 | found: | 3949 | platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL); |
| 3950 | if (platform == NULL) | ||
| 3951 | return -ENOMEM; | ||
| 3952 | |||
| 3953 | ret = snd_soc_add_platform(dev, platform, platform_drv); | ||
| 3954 | if (ret) | ||
| 3955 | kfree(platform); | ||
| 3956 | |||
| 3957 | return ret; | ||
| 3958 | } | ||
| 3959 | EXPORT_SYMBOL_GPL(snd_soc_register_platform); | ||
| 3960 | |||
| 3961 | /** | ||
| 3962 | * snd_soc_remove_platform - Remove a platform from the ASoC core | ||
| 3963 | * @platform: the platform to remove | ||
| 3964 | */ | ||
| 3965 | void snd_soc_remove_platform(struct snd_soc_platform *platform) | ||
| 3966 | { | ||
| 3959 | mutex_lock(&client_mutex); | 3967 | mutex_lock(&client_mutex); |
| 3960 | list_del(&platform->list); | 3968 | list_del(&platform->list); |
| 3961 | mutex_unlock(&client_mutex); | 3969 | mutex_unlock(&client_mutex); |
| 3962 | 3970 | ||
| 3963 | dev_dbg(dev, "ASoC: Unregistered platform '%s'\n", platform->name); | 3971 | dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n", |
| 3972 | platform->name); | ||
| 3964 | kfree(platform->name); | 3973 | kfree(platform->name); |
| 3974 | } | ||
| 3975 | EXPORT_SYMBOL_GPL(snd_soc_remove_platform); | ||
| 3976 | |||
| 3977 | struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev) | ||
| 3978 | { | ||
| 3979 | struct snd_soc_platform *platform; | ||
| 3980 | |||
| 3981 | list_for_each_entry(platform, &platform_list, list) { | ||
| 3982 | if (dev == platform->dev) | ||
| 3983 | return platform; | ||
| 3984 | } | ||
| 3985 | |||
| 3986 | return NULL; | ||
| 3987 | } | ||
| 3988 | EXPORT_SYMBOL_GPL(snd_soc_lookup_platform); | ||
| 3989 | |||
| 3990 | /** | ||
| 3991 | * snd_soc_unregister_platform - Unregister a platform from the ASoC core | ||
| 3992 | * | ||
| 3993 | * @platform: platform to unregister | ||
| 3994 | */ | ||
| 3995 | void snd_soc_unregister_platform(struct device *dev) | ||
| 3996 | { | ||
| 3997 | struct snd_soc_platform *platform; | ||
| 3998 | |||
| 3999 | platform = snd_soc_lookup_platform(dev); | ||
| 4000 | if (!platform) | ||
| 4001 | return; | ||
| 4002 | |||
| 4003 | snd_soc_remove_platform(platform); | ||
| 3965 | kfree(platform); | 4004 | kfree(platform); |
| 3966 | } | 4005 | } |
| 3967 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); | 4006 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); |
