1 // SPDX-License-Identifier: GPL-2.0+
3 // soc-devres.c -- ALSA SoC Audio Layer devres functions
5 // Copyright (C) 2013 Linaro Ltd
7 #include <linux/module.h>
8 #include <linux/moduleparam.h>
10 #include <sound/dmaengine_pcm.h>
12 static void devm_component_release(struct device
*dev
, void *res
)
14 const struct snd_soc_component_driver
**cmpnt_drv
= res
;
16 snd_soc_unregister_component_by_driver(dev
, *cmpnt_drv
);
20 * devm_snd_soc_register_component - resource managed component registration
21 * @dev: Device used to manage component
22 * @cmpnt_drv: Component driver
23 * @dai_drv: DAI driver
24 * @num_dai: Number of DAIs to register
26 * Register a component with automatic unregistration when the device is
29 int devm_snd_soc_register_component(struct device
*dev
,
30 const struct snd_soc_component_driver
*cmpnt_drv
,
31 struct snd_soc_dai_driver
*dai_drv
, int num_dai
)
33 const struct snd_soc_component_driver
**ptr
;
36 ptr
= devres_alloc(devm_component_release
, sizeof(*ptr
), GFP_KERNEL
);
40 ret
= snd_soc_register_component(dev
, cmpnt_drv
, dai_drv
, num_dai
);
50 EXPORT_SYMBOL_GPL(devm_snd_soc_register_component
);
52 static void devm_card_release(struct device
*dev
, void *res
)
54 snd_soc_unregister_card(*(struct snd_soc_card
**)res
);
58 * devm_snd_soc_register_card - resource managed card registration
59 * @dev: Device used to manage card
60 * @card: Card to register
62 * Register a card with automatic unregistration when the device is
65 int devm_snd_soc_register_card(struct device
*dev
, struct snd_soc_card
*card
)
67 struct snd_soc_card
**ptr
;
70 ptr
= devres_alloc(devm_card_release
, sizeof(*ptr
), GFP_KERNEL
);
74 ret
= snd_soc_register_card(card
);
84 EXPORT_SYMBOL_GPL(devm_snd_soc_register_card
);
86 #ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM
88 static void devm_dmaengine_pcm_release(struct device
*dev
, void *res
)
90 snd_dmaengine_pcm_unregister(*(struct device
**)res
);
94 * devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration
95 * @dev: The parent device for the PCM device
96 * @config: Platform specific PCM configuration
97 * @flags: Platform specific quirks
99 * Register a dmaengine based PCM device with automatic unregistration when the
100 * device is unregistered.
102 int devm_snd_dmaengine_pcm_register(struct device
*dev
,
103 const struct snd_dmaengine_pcm_config
*config
, unsigned int flags
)
108 ptr
= devres_alloc(devm_dmaengine_pcm_release
, sizeof(*ptr
), GFP_KERNEL
);
112 ret
= snd_dmaengine_pcm_register(dev
, config
, flags
);
115 devres_add(dev
, ptr
);
122 EXPORT_SYMBOL_GPL(devm_snd_dmaengine_pcm_register
);