diff options
author | Takashi Iwai <tiwai@suse.de> | 2020-06-22 13:49:14 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2020-06-22 13:49:14 +0200 |
commit | 91ef3d9f9fef08e3f42b78ec0ae8187be1070fce (patch) | |
tree | 3bcf664e2d42a7f22d905d739dd24ab0df40f706 /sound/soc/soc-devres.c | |
parent | d50313a5a0d803bcf55121a2b82086633060d05e (diff) | |
parent | f141a422159a199f4c8dedb7e0df55b3b2cf16cd (diff) | |
download | linux-91ef3d9f9fef08e3f42b78ec0ae8187be1070fce.tar.bz2 |
Merge tag 'asoc-fix-v5.8-rc2' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v5.8
This is a collection of mostly small fixes, mostly fixing fallout from
some of the DPCM changes that went in last time around which shook out
some issues on i.MX and Qualcomm platforms. The addition of a managed
version of snd_soc_register_dai() is to fix resource leaks.
There's also a few new device IDs for x86 systems.
Diffstat (limited to 'sound/soc/soc-devres.c')
-rw-r--r-- | sound/soc/soc-devres.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c index a9ea172a66a7..11e5d7962370 100644 --- a/sound/soc/soc-devres.c +++ b/sound/soc/soc-devres.c @@ -9,6 +9,43 @@ #include <sound/soc.h> #include <sound/dmaengine_pcm.h> +static void devm_dai_release(struct device *dev, void *res) +{ + snd_soc_unregister_dai(*(struct snd_soc_dai **)res); +} + +/** + * devm_snd_soc_register_dai - resource-managed dai registration + * @dev: Device used to manage component + * @component: The component the DAIs are registered for + * @dai_drv: DAI driver to use for the DAI + * @legacy_dai_naming: if %true, use legacy single-name format; + * if %false, use multiple-name format; + */ +struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev, + struct snd_soc_component *component, + struct snd_soc_dai_driver *dai_drv, + bool legacy_dai_naming) +{ + struct snd_soc_dai **ptr; + struct snd_soc_dai *dai; + + ptr = devres_alloc(devm_dai_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return NULL; + + dai = snd_soc_register_dai(component, dai_drv, legacy_dai_naming); + if (dai) { + *ptr = dai; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return dai; +} +EXPORT_SYMBOL_GPL(devm_snd_soc_register_dai); + static void devm_component_release(struct device *dev, void *res) { snd_soc_unregister_component(*(struct device **)res); |