Date: | 2013-04-15 19:19:49 (10 years 1 month ago) |
---|---|
Author: | Lars C. |
Commit: | 9529ae761db851eb2c86ddc61032059b831738f3 |
Message: | 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> |
Files: |
include/sound/soc.h (1 diff) sound/soc/soc-core.c (2 diffs) |
Change Details
include/sound/soc.h | ||
---|---|---|
373 | 373 | int snd_soc_register_platform(struct device *dev, |
374 | 374 | const struct snd_soc_platform_driver *platform_drv); |
375 | 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 | 380 | int snd_soc_register_codec(struct device *dev, |
377 | 381 | const struct snd_soc_codec_driver *codec_drv, |
378 | 382 | struct snd_soc_dai_driver *dai_drv, int num_dai); |
sound/soc/soc-core.c | ||
---|---|---|
3903 | 3903 | EXPORT_SYMBOL_GPL(snd_soc_unregister_dais); |
3904 | 3904 | |
3905 | 3905 | /** |
3906 | * snd_soc_register_platform - Register a platform with the ASoC core | |
3907 | * | |
3908 | * @platform: platform to register | |
3906 | * snd_soc_add_platform - Add a platform to the ASoC core | |
3907 | * @dev: The parent device for the platform | |
3908 | * @platform: The platform to add | |
3909 | * @platform_driver: The driver for the platform | |
3909 | 3910 | */ |
3910 | int snd_soc_register_platform(struct device *dev, | |
3911 | int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, | |
3911 | 3912 | const struct snd_soc_platform_driver *platform_drv) |
3912 | 3913 | { |
3913 | struct snd_soc_platform *platform; | |
3914 | ||
3915 | dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev)); | |
3916 | ||
3917 | platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL); | |
3918 | if (platform == NULL) | |
3919 | return -ENOMEM; | |
3920 | ||
3921 | 3914 | /* create platform component name */ |
3922 | 3915 | platform->name = fmt_single_name(dev, &platform->id); |
3923 | 3916 | if (platform->name == NULL) { |
... | ... | |
3940 | 3933 | |
3941 | 3934 | return 0; |
3942 | 3935 | } |
3943 | EXPORT_SYMBOL_GPL(snd_soc_register_platform); | |
3936 | EXPORT_SYMBOL_GPL(snd_soc_add_platform); | |
3944 | 3937 | |
3945 | 3938 | /** |
3946 | * snd_soc_unregister_platform - Unregister a platform from the ASoC core | |
3939 | * snd_soc_register_platform - Register a platform with the ASoC core | |
3947 | 3940 | * |
3948 | * @platform: platform to unregister | |
3941 | * @platform: platform to register | |
3949 | 3942 | */ |
3950 | void snd_soc_unregister_platform(struct device *dev) | |
3943 | int snd_soc_register_platform(struct device *dev, | |
3944 | const struct snd_soc_platform_driver *platform_drv) | |
3951 | 3945 | { |
3952 | 3946 | struct snd_soc_platform *platform; |
3947 | int ret; | |
3953 | 3948 | |
3954 | list_for_each_entry(platform, &platform_list, list) { | |
3955 | if (dev == platform->dev) | |
3956 | goto found; | |
3957 | } | |
3958 | return; | |
3949 | dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev)); | |
3959 | 3950 | |
3960 | found: | |
3951 | platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL); | |
3952 | if (platform == NULL) | |
3953 | return -ENOMEM; | |
3954 | ||
3955 | ret = snd_soc_add_platform(dev, platform, platform_drv); | |
3956 | if (ret) | |
3957 | kfree(platform); | |
3958 | ||
3959 | return ret; | |
3960 | } | |
3961 | EXPORT_SYMBOL_GPL(snd_soc_register_platform); | |
3962 | ||
3963 | /** | |
3964 | * snd_soc_remove_platform - Remove a platform from the ASoC core | |
3965 | * @platform: the platform to remove | |
3966 | */ | |
3967 | void snd_soc_remove_platform(struct snd_soc_platform *platform) | |
3968 | { | |
3961 | 3969 | mutex_lock(&client_mutex); |
3962 | 3970 | list_del(&platform->list); |
3963 | 3971 | mutex_unlock(&client_mutex); |
3964 | 3972 | |
3965 | dev_dbg(dev, "ASoC: Unregistered platform '%s'\n", platform->name); | |
3973 | dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n", | |
3974 | platform->name); | |
3966 | 3975 | kfree(platform->name); |
3976 | } | |
3977 | EXPORT_SYMBOL_GPL(snd_soc_remove_platform); | |
3978 | ||
3979 | struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev) | |
3980 | { | |
3981 | struct snd_soc_platform *platform; | |
3982 | ||
3983 | list_for_each_entry(platform, &platform_list, list) { | |
3984 | if (dev == platform->dev) | |
3985 | return platform; | |
3986 | } | |
3987 | ||
3988 | return NULL; | |
3989 | } | |
3990 | EXPORT_SYMBOL_GPL(snd_soc_lookup_platform); | |
3991 | ||
3992 | /** | |
3993 | * snd_soc_unregister_platform - Unregister a platform from the ASoC core | |
3994 | * | |
3995 | * @platform: platform to unregister | |
3996 | */ | |
3997 | void snd_soc_unregister_platform(struct device *dev) | |
3998 | { | |
3999 | struct snd_soc_platform *platform; | |
4000 | ||
4001 | platform = snd_soc_lookup_platform(dev); | |
4002 | if (!platform) | |
4003 | return; | |
4004 | ||
4005 | snd_soc_remove_platform(platform); | |
3967 | 4006 | kfree(platform); |
3968 | 4007 | } |
3969 | 4008 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); |
Branches:
ben-wpan
ben-wpan-stefan
5396a9238205f20f811ea57898980d3ca82df0b6
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9