diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2015-01-23 10:21:36 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-01-26 14:14:20 -0500 |
commit | 47e039413cacee70229ebbf6de5a8e3b27e6f057 (patch) | |
tree | f46ebce8e817474d3ff12139dcfc8f47cba4d00c /sound/soc/soc-ac97.c | |
parent | 97bf6af1f928216fd6c5a66e8a57bfa95a659672 (diff) |
ASoC: Add support for allocating AC'97 device before registering it
In some cases it is necessary to before additional operations after the
device has been initialized and before the device is registered. This can
for example be resetting the device.
This patch introduces a new function snd_soc_alloc_ac97_codec() which is
similar to snd_soc_new_ac97_codec() except that it does not register the
device. Any users of snd_soc_alloc_ac97_codec() are responsible for calling
device_add() manually.
Fixes: 6794f709b712 ("ASoC: ac97: Drop delayed device registration")
Reported-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Diffstat (limited to 'sound/soc/soc-ac97.c')
-rw-r--r-- | sound/soc/soc-ac97.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c index 2e10e9a38376..08d7259bbaab 100644 --- a/sound/soc/soc-ac97.c +++ b/sound/soc/soc-ac97.c | |||
@@ -48,15 +48,18 @@ static void soc_ac97_device_release(struct device *dev) | |||
48 | } | 48 | } |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * snd_soc_new_ac97_codec - initailise AC97 device | 51 | * snd_soc_alloc_ac97_codec() - Allocate new a AC'97 device |
52 | * @codec: audio codec | 52 | * @codec: The CODEC for which to create the AC'97 device |
53 | * | 53 | * |
54 | * Initialises AC97 codec resources for use by ad-hoc devices only. | 54 | * Allocated a new snd_ac97 device and intializes it, but does not yet register |
55 | * it. The caller is responsible to either call device_add(&ac97->dev) to | ||
56 | * register the device, or to call put_device(&ac97->dev) to free the device. | ||
57 | * | ||
58 | * Returns: A snd_ac97 device or a PTR_ERR in case of an error. | ||
55 | */ | 59 | */ |
56 | struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec) | 60 | struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) |
57 | { | 61 | { |
58 | struct snd_ac97 *ac97; | 62 | struct snd_ac97 *ac97; |
59 | int ret; | ||
60 | 63 | ||
61 | ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); | 64 | ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); |
62 | if (ac97 == NULL) | 65 | if (ac97 == NULL) |
@@ -73,7 +76,28 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec) | |||
73 | codec->component.card->snd_card->number, 0, | 76 | codec->component.card->snd_card->number, 0, |
74 | codec->component.name); | 77 | codec->component.name); |
75 | 78 | ||
76 | ret = device_register(&ac97->dev); | 79 | device_initialize(&ac97->dev); |
80 | |||
81 | return ac97; | ||
82 | } | ||
83 | EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); | ||
84 | |||
85 | /** | ||
86 | * snd_soc_new_ac97_codec - initailise AC97 device | ||
87 | * @codec: audio codec | ||
88 | * | ||
89 | * Initialises AC97 codec resources for use by ad-hoc devices only. | ||
90 | */ | ||
91 | struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec) | ||
92 | { | ||
93 | struct snd_ac97 *ac97; | ||
94 | int ret; | ||
95 | |||
96 | ac97 = snd_soc_alloc_ac97_codec(codec); | ||
97 | if (IS_ERR(ac97)) | ||
98 | return ac97; | ||
99 | |||
100 | ret = device_add(&ac97->dev); | ||
77 | if (ret) { | 101 | if (ret) { |
78 | put_device(&ac97->dev); | 102 | put_device(&ac97->dev); |
79 | return ERR_PTR(ret); | 103 | return ERR_PTR(ret); |