diff options
| author | Mark Brown <broonie@linaro.org> | 2013-09-16 19:50:44 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@linaro.org> | 2013-09-16 19:50:44 -0400 |
| commit | e3c51ca8fa4a0f3f13ba9be80bee2708cd723934 (patch) | |
| tree | 2fb9e21dd07ef066be1ce7291312c65c967a7710 | |
| parent | b3a6006e1d106fddcfc121d0ccfa9b7faeeb8f3e (diff) | |
| parent | 0e4ff5c806263bf40ee5409ac283b776f0c11e41 (diff) | |
Merge remote-tracking branch 'asoc/topic/devm' into asoc-samsung
| -rw-r--r-- | include/sound/soc.h | 4 | ||||
| -rw-r--r-- | sound/soc/Makefile | 2 | ||||
| -rw-r--r-- | sound/soc/soc-devres.c | 86 |
3 files changed, 91 insertions, 1 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index d22cb0a06feb..d44728ab2be0 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
| @@ -369,6 +369,7 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, | |||
| 369 | 369 | ||
| 370 | int snd_soc_register_card(struct snd_soc_card *card); | 370 | int snd_soc_register_card(struct snd_soc_card *card); |
| 371 | int snd_soc_unregister_card(struct snd_soc_card *card); | 371 | int snd_soc_unregister_card(struct snd_soc_card *card); |
| 372 | int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card); | ||
| 372 | int snd_soc_suspend(struct device *dev); | 373 | int snd_soc_suspend(struct device *dev); |
| 373 | int snd_soc_resume(struct device *dev); | 374 | int snd_soc_resume(struct device *dev); |
| 374 | int snd_soc_poweroff(struct device *dev); | 375 | int snd_soc_poweroff(struct device *dev); |
| @@ -386,6 +387,9 @@ void snd_soc_unregister_codec(struct device *dev); | |||
| 386 | int snd_soc_register_component(struct device *dev, | 387 | int snd_soc_register_component(struct device *dev, |
| 387 | const struct snd_soc_component_driver *cmpnt_drv, | 388 | const struct snd_soc_component_driver *cmpnt_drv, |
| 388 | struct snd_soc_dai_driver *dai_drv, int num_dai); | 389 | struct snd_soc_dai_driver *dai_drv, int num_dai); |
| 390 | int devm_snd_soc_register_component(struct device *dev, | ||
| 391 | const struct snd_soc_component_driver *cmpnt_drv, | ||
| 392 | struct snd_soc_dai_driver *dai_drv, int num_dai); | ||
| 389 | void snd_soc_unregister_component(struct device *dev); | 393 | void snd_soc_unregister_component(struct device *dev); |
| 390 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, | 394 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, |
| 391 | unsigned int reg); | 395 | unsigned int reg); |
diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 61a64d281905..8b9e70105dd2 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o | 1 | snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o |
| 2 | snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o | 2 | snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o |
| 3 | 3 | ||
| 4 | ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) | 4 | ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) |
| 5 | snd-soc-core-objs += soc-generic-dmaengine-pcm.o | 5 | snd-soc-core-objs += soc-generic-dmaengine-pcm.o |
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c new file mode 100644 index 000000000000..b1d732255c02 --- /dev/null +++ b/sound/soc/soc-devres.c | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | /* | ||
| 2 | * soc-devres.c -- ALSA SoC Audio Layer devres functions | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 Linaro Ltd | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License as published by the | ||
| 8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 9 | * option) any later version. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/module.h> | ||
| 13 | #include <linux/moduleparam.h> | ||
| 14 | #include <sound/soc.h> | ||
| 15 | |||
| 16 | static void devm_component_release(struct device *dev, void *res) | ||
| 17 | { | ||
| 18 | snd_soc_unregister_component(*(struct device **)res); | ||
| 19 | } | ||
| 20 | |||
| 21 | /** | ||
| 22 | * devm_snd_soc_register_component - resource managed component registration | ||
| 23 | * @dev: Device used to manage component | ||
| 24 | * @cmpnt_drv: Component driver | ||
| 25 | * @dai_drv: DAI driver | ||
| 26 | * @num_dai: Number of DAIs to register | ||
| 27 | * | ||
| 28 | * Register a component with automatic unregistration when the device is | ||
| 29 | * unregistered. | ||
| 30 | */ | ||
| 31 | int devm_snd_soc_register_component(struct device *dev, | ||
| 32 | const struct snd_soc_component_driver *cmpnt_drv, | ||
| 33 | struct snd_soc_dai_driver *dai_drv, int num_dai) | ||
| 34 | { | ||
| 35 | struct device **ptr; | ||
| 36 | int ret; | ||
| 37 | |||
| 38 | ptr = devres_alloc(devm_component_release, sizeof(*ptr), GFP_KERNEL); | ||
| 39 | if (!ptr) | ||
| 40 | return -ENOMEM; | ||
| 41 | |||
| 42 | ret = snd_soc_register_component(dev, cmpnt_drv, dai_drv, num_dai); | ||
| 43 | if (ret == 0) { | ||
| 44 | *ptr = dev; | ||
| 45 | devres_add(dev, ptr); | ||
| 46 | } else { | ||
| 47 | devres_free(ptr); | ||
| 48 | } | ||
| 49 | |||
| 50 | return ret; | ||
| 51 | } | ||
| 52 | EXPORT_SYMBOL_GPL(devm_snd_soc_register_component); | ||
| 53 | |||
| 54 | static void devm_card_release(struct device *dev, void *res) | ||
| 55 | { | ||
| 56 | snd_soc_unregister_card(*(struct snd_soc_card **)res); | ||
| 57 | } | ||
| 58 | |||
| 59 | /** | ||
| 60 | * devm_snd_soc_register_card - resource managed card registration | ||
| 61 | * @dev: Device used to manage card | ||
| 62 | * @card: Card to register | ||
| 63 | * | ||
| 64 | * Register a card with automatic unregistration when the device is | ||
| 65 | * unregistered. | ||
| 66 | */ | ||
| 67 | int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card) | ||
| 68 | { | ||
| 69 | struct device **ptr; | ||
| 70 | int ret; | ||
| 71 | |||
| 72 | ptr = devres_alloc(devm_card_release, sizeof(*ptr), GFP_KERNEL); | ||
| 73 | if (!ptr) | ||
| 74 | return -ENOMEM; | ||
| 75 | |||
| 76 | ret = snd_soc_register_card(card); | ||
| 77 | if (ret == 0) { | ||
| 78 | *ptr = dev; | ||
| 79 | devres_add(dev, ptr); | ||
| 80 | } else { | ||
| 81 | devres_free(ptr); | ||
| 82 | } | ||
| 83 | |||
| 84 | return ret; | ||
| 85 | } | ||
| 86 | EXPORT_SYMBOL_GPL(devm_snd_soc_register_card); | ||
