diff options
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 85 |
1 files changed, 62 insertions, 23 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 7bf21a1035ea..d56bbea6e75e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -3900,21 +3900,14 @@ static void snd_soc_unregister_dais(struct device *dev, size_t count) | |||
3900 | } | 3900 | } |
3901 | 3901 | ||
3902 | /** | 3902 | /** |
3903 | * snd_soc_register_platform - Register a platform with the ASoC core | 3903 | * snd_soc_add_platform - Add a platform to the ASoC core |
3904 | * | 3904 | * @dev: The parent device for the platform |
3905 | * @platform: platform to register | 3905 | * @platform: The platform to add |
3906 | * @platform_driver: The driver for the platform | ||
3906 | */ | 3907 | */ |
3907 | int snd_soc_register_platform(struct device *dev, | 3908 | int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, |
3908 | const struct snd_soc_platform_driver *platform_drv) | 3909 | const struct snd_soc_platform_driver *platform_drv) |
3909 | { | 3910 | { |
3910 | struct snd_soc_platform *platform; | ||
3911 | |||
3912 | dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev)); | ||
3913 | |||
3914 | platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL); | ||
3915 | if (platform == NULL) | ||
3916 | return -ENOMEM; | ||
3917 | |||
3918 | /* create platform component name */ | 3911 | /* create platform component name */ |
3919 | platform->name = fmt_single_name(dev, &platform->id); | 3912 | platform->name = fmt_single_name(dev, &platform->id); |
3920 | if (platform->name == NULL) { | 3913 | if (platform->name == NULL) { |
@@ -3937,30 +3930,76 @@ int snd_soc_register_platform(struct device *dev, | |||
3937 | 3930 | ||
3938 | return 0; | 3931 | return 0; |
3939 | } | 3932 | } |
3940 | EXPORT_SYMBOL_GPL(snd_soc_register_platform); | 3933 | EXPORT_SYMBOL_GPL(snd_soc_add_platform); |
3941 | 3934 | ||
3942 | /** | 3935 | /** |
3943 | * snd_soc_unregister_platform - Unregister a platform from the ASoC core | 3936 | * snd_soc_register_platform - Register a platform with the ASoC core |
3944 | * | 3937 | * |
3945 | * @platform: platform to unregister | 3938 | * @platform: platform to register |
3946 | */ | 3939 | */ |
3947 | void snd_soc_unregister_platform(struct device *dev) | 3940 | int snd_soc_register_platform(struct device *dev, |
3941 | const struct snd_soc_platform_driver *platform_drv) | ||
3948 | { | 3942 | { |
3949 | struct snd_soc_platform *platform; | 3943 | struct snd_soc_platform *platform; |
3944 | int ret; | ||
3950 | 3945 | ||
3951 | list_for_each_entry(platform, &platform_list, list) { | 3946 | dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev)); |
3952 | if (dev == platform->dev) | ||
3953 | goto found; | ||
3954 | } | ||
3955 | return; | ||
3956 | 3947 | ||
3957 | found: | 3948 | platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL); |
3949 | if (platform == NULL) | ||
3950 | return -ENOMEM; | ||
3951 | |||
3952 | ret = snd_soc_add_platform(dev, platform, platform_drv); | ||
3953 | if (ret) | ||
3954 | kfree(platform); | ||
3955 | |||
3956 | return ret; | ||
3957 | } | ||
3958 | EXPORT_SYMBOL_GPL(snd_soc_register_platform); | ||
3959 | |||
3960 | /** | ||
3961 | * snd_soc_remove_platform - Remove a platform from the ASoC core | ||
3962 | * @platform: the platform to remove | ||
3963 | */ | ||
3964 | void snd_soc_remove_platform(struct snd_soc_platform *platform) | ||
3965 | { | ||
3958 | mutex_lock(&client_mutex); | 3966 | mutex_lock(&client_mutex); |
3959 | list_del(&platform->list); | 3967 | list_del(&platform->list); |
3960 | mutex_unlock(&client_mutex); | 3968 | mutex_unlock(&client_mutex); |
3961 | 3969 | ||
3962 | dev_dbg(dev, "ASoC: Unregistered platform '%s'\n", platform->name); | 3970 | dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n", |
3971 | platform->name); | ||
3963 | kfree(platform->name); | 3972 | kfree(platform->name); |
3973 | } | ||
3974 | EXPORT_SYMBOL_GPL(snd_soc_remove_platform); | ||
3975 | |||
3976 | struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev) | ||
3977 | { | ||
3978 | struct snd_soc_platform *platform; | ||
3979 | |||
3980 | list_for_each_entry(platform, &platform_list, list) { | ||
3981 | if (dev == platform->dev) | ||
3982 | return platform; | ||
3983 | } | ||
3984 | |||
3985 | return NULL; | ||
3986 | } | ||
3987 | EXPORT_SYMBOL_GPL(snd_soc_lookup_platform); | ||
3988 | |||
3989 | /** | ||
3990 | * snd_soc_unregister_platform - Unregister a platform from the ASoC core | ||
3991 | * | ||
3992 | * @platform: platform to unregister | ||
3993 | */ | ||
3994 | void snd_soc_unregister_platform(struct device *dev) | ||
3995 | { | ||
3996 | struct snd_soc_platform *platform; | ||
3997 | |||
3998 | platform = snd_soc_lookup_platform(dev); | ||
3999 | if (!platform) | ||
4000 | return; | ||
4001 | |||
4002 | snd_soc_remove_platform(platform); | ||
3964 | kfree(platform); | 4003 | kfree(platform); |
3965 | } | 4004 | } |
3966 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); | 4005 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); |