aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-devres.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-devres.c')
-rw-r--r--sound/soc/soc-devres.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
index 7ac745df1412..057e5ef7dcce 100644
--- a/sound/soc/soc-devres.c
+++ b/sound/soc/soc-devres.c
@@ -52,6 +52,41 @@ int devm_snd_soc_register_component(struct device *dev,
52} 52}
53EXPORT_SYMBOL_GPL(devm_snd_soc_register_component); 53EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
54 54
55static void devm_platform_release(struct device *dev, void *res)
56{
57 snd_soc_unregister_platform(*(struct device **)res);
58}
59
60/**
61 * devm_snd_soc_register_platform - resource managed platform registration
62 * @dev: Device used to manage platform
63 * @platform: platform to register
64 *
65 * Register a platform driver with automatic unregistration when the device is
66 * unregistered.
67 */
68int devm_snd_soc_register_platform(struct device *dev,
69 const struct snd_soc_platform_driver *platform_drv)
70{
71 struct device **ptr;
72 int ret;
73
74 ptr = devres_alloc(devm_platform_release, sizeof(*ptr), GFP_KERNEL);
75 if (!ptr)
76 return -ENOMEM;
77
78 ret = snd_soc_register_platform(dev, platform_drv);
79 if (ret == 0) {
80 *ptr = dev;
81 devres_add(dev, ptr);
82 } else {
83 devres_free(ptr);
84 }
85
86 return ret;
87}
88EXPORT_SYMBOL_GPL(devm_snd_soc_register_platform);
89
55static void devm_card_release(struct device *dev, void *res) 90static void devm_card_release(struct device *dev, void *res)
56{ 91{
57 snd_soc_unregister_card(*(struct snd_soc_card **)res); 92 snd_soc_unregister_card(*(struct snd_soc_card **)res);