2 * soc-devres.c -- ALSA SoC Audio Layer devres functions
4 * Copyright (C) 2013 Linaro Ltd
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.
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <sound/soc.h>
15 #include <sound/dmaengine_pcm.h>
17 static void devm_component_release(struct device
*dev
, void *res
)
19 snd_soc_unregister_component(*(struct device
**)res
);
23 * devm_snd_soc_register_component - resource managed component registration
24 * @dev: Device used to manage component
25 * @cmpnt_drv: Component driver
26 * @dai_drv: DAI driver
27 * @num_dai: Number of DAIs to register
29 * Register a component with automatic unregistration when the device is
32 int devm_snd_soc_register_component(struct device
*dev
,
33 const struct snd_soc_component_driver
*cmpnt_drv
,
34 struct snd_soc_dai_driver
*dai_drv
, int num_dai
)
39 ptr
= devres_alloc(devm_component_release
, sizeof(*ptr
), GFP_KERNEL
);
43 ret
= snd_soc_register_component(dev
, cmpnt_drv
, dai_drv
, num_dai
);
53 EXPORT_SYMBOL_GPL(devm_snd_soc_register_component
);
55 static void devm_platform_release(struct device
*dev
, void *res
)
57 snd_soc_unregister_platform(*(struct device
**)res
);
61 * devm_snd_soc_register_platform - resource managed platform registration
62 * @dev: Device used to manage platform
63 * @platform_drv: platform to register
65 * Register a platform driver with automatic unregistration when the device is
68 int devm_snd_soc_register_platform(struct device
*dev
,
69 const struct snd_soc_platform_driver
*platform_drv
)
74 ptr
= devres_alloc(devm_platform_release
, sizeof(*ptr
), GFP_KERNEL
);
78 ret
= snd_soc_register_platform(dev
, platform_drv
);
88 EXPORT_SYMBOL_GPL(devm_snd_soc_register_platform
);
90 static void devm_card_release(struct device
*dev
, void *res
)
92 snd_soc_unregister_card(*(struct snd_soc_card
**)res
);
96 * devm_snd_soc_register_card - resource managed card registration
97 * @dev: Device used to manage card
98 * @card: Card to register
100 * Register a card with automatic unregistration when the device is
103 int devm_snd_soc_register_card(struct device
*dev
, struct snd_soc_card
*card
)
105 struct snd_soc_card
**ptr
;
108 ptr
= devres_alloc(devm_card_release
, sizeof(*ptr
), GFP_KERNEL
);
112 ret
= snd_soc_register_card(card
);
115 devres_add(dev
, ptr
);
122 EXPORT_SYMBOL_GPL(devm_snd_soc_register_card
);
124 #ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM
126 static void devm_dmaengine_pcm_release(struct device
*dev
, void *res
)
128 snd_dmaengine_pcm_unregister(*(struct device
**)res
);
132 * devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration
133 * @dev: The parent device for the PCM device
134 * @config: Platform specific PCM configuration
135 * @flags: Platform specific quirks
137 * Register a dmaengine based PCM device with automatic unregistration when the
138 * device is unregistered.
140 int devm_snd_dmaengine_pcm_register(struct device
*dev
,
141 const struct snd_dmaengine_pcm_config
*config
, unsigned int flags
)
146 ptr
= devres_alloc(devm_dmaengine_pcm_release
, sizeof(*ptr
), GFP_KERNEL
);
150 ret
= snd_dmaengine_pcm_register(dev
, config
, flags
);
153 devres_add(dev
, ptr
);
160 EXPORT_SYMBOL_GPL(devm_snd_dmaengine_pcm_register
);