soc-devres.c (75ab73bc5d0e625e9d886653ec98d0e9d6ad4c68) | soc-devres.c (ebff65473f56e6c30de928fd6a4f1ce5ae36e8c5) |
---|---|
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> | 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#include <sound/dmaengine_pcm.h> | |
16 17static void devm_component_release(struct device *dev, void *res) 18{ 19 snd_soc_unregister_component(*(struct device **)res); 20} 21 22/** 23 * devm_snd_soc_register_component - resource managed component registration --- 38 unchanged lines hidden (view full) --- 62 * @dev: Device used to manage card 63 * @card: Card to register 64 * 65 * Register a card with automatic unregistration when the device is 66 * unregistered. 67 */ 68int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card) 69{ | 15 16static 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 --- 38 unchanged lines hidden (view full) --- 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 */ 67int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card) 68{ |
70 struct device **ptr; | 69 struct snd_soc_card **ptr; |
71 int ret; 72 73 ptr = devres_alloc(devm_card_release, sizeof(*ptr), GFP_KERNEL); 74 if (!ptr) 75 return -ENOMEM; 76 77 ret = snd_soc_register_card(card); 78 if (ret == 0) { | 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) { |
79 *ptr = dev; | 78 *ptr = card; |
80 devres_add(dev, ptr); 81 } else { 82 devres_free(ptr); 83 } 84 85 return ret; 86} 87EXPORT_SYMBOL_GPL(devm_snd_soc_register_card); | 79 devres_add(dev, ptr); 80 } else { 81 devres_free(ptr); 82 } 83 84 return ret; 85} 86EXPORT_SYMBOL_GPL(devm_snd_soc_register_card); |
88 89#ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM 90 91static void devm_dmaengine_pcm_release(struct device *dev, void *res) 92{ 93 snd_dmaengine_pcm_unregister(*(struct device **)res); 94} 95 96/** 97 * devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration 98 * @dev: The parent device for the PCM device 99 * @config: Platform specific PCM configuration 100 * @flags: Platform specific quirks 101 * 102 * Register a dmaengine based PCM device with automatic unregistration when the 103 * device is unregistered. 104 */ 105int devm_snd_dmaengine_pcm_register(struct device *dev, 106 const struct snd_dmaengine_pcm_config *config, unsigned int flags) 107{ 108 struct device **ptr; 109 int ret; 110 111 ptr = devres_alloc(devm_dmaengine_pcm_release, sizeof(*ptr), GFP_KERNEL); 112 if (!ptr) 113 return -ENOMEM; 114 115 ret = snd_dmaengine_pcm_register(dev, config, flags); 116 if (ret == 0) { 117 *ptr = dev; 118 devres_add(dev, ptr); 119 } else { 120 devres_free(ptr); 121 } 122 123 return ret; 124} 125EXPORT_SYMBOL_GPL(devm_snd_dmaengine_pcm_register); 126 127#endif | |