diff options
author | Stephen Warren <swarren@nvidia.com> | 2011-01-28 16:26:36 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-01-31 08:15:48 -0500 |
commit | 72de2b1a9a5b869c1eaea098dd2a75e6bbbf0488 (patch) | |
tree | d63788b2d865c79285ea7dea3764d026d1dc97e9 /sound | |
parent | 111c6419ffeef0ef225dfdd2c8b7b03cc6bb228e (diff) |
ASoC: Tegra: Harmony: Don't use soc-audio platform device
Previously, snd-soc-tegra-harmony internally instantiated a platform device
object whenever the module was loaded. Instead, switch to a more typical model
where arch/arm/mach-tegra defines a platform device, and snd-soc-tegra-harmony
acts as a driver for such a platform device.
Define a new struct tegra_harmony to store driver data in the future.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/tegra/harmony.c | 94 |
1 files changed, 66 insertions, 28 deletions
diff --git a/sound/soc/tegra/harmony.c b/sound/soc/tegra/harmony.c index b160b7113f45..2d6a15c6bdfe 100644 --- a/sound/soc/tegra/harmony.c +++ b/sound/soc/tegra/harmony.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * harmony.c - Harmony machine ASoC driver | 2 | * harmony.c - Harmony machine ASoC driver |
3 | * | 3 | * |
4 | * Author: Stephen Warren <swarren@nvidia.com> | 4 | * Author: Stephen Warren <swarren@nvidia.com> |
5 | * Copyright (C) 2010 - NVIDIA, Inc. | 5 | * Copyright (C) 2010-2011 - NVIDIA, Inc. |
6 | * | 6 | * |
7 | * Based on code copyright/by: | 7 | * Based on code copyright/by: |
8 | * | 8 | * |
@@ -29,7 +29,11 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <asm/mach-types.h> | 31 | #include <asm/mach-types.h> |
32 | |||
32 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/platform_device.h> | ||
35 | #include <linux/slab.h> | ||
36 | |||
33 | #include <sound/core.h> | 37 | #include <sound/core.h> |
34 | #include <sound/pcm.h> | 38 | #include <sound/pcm.h> |
35 | #include <sound/pcm_params.h> | 39 | #include <sound/pcm_params.h> |
@@ -40,9 +44,11 @@ | |||
40 | #include "tegra_pcm.h" | 44 | #include "tegra_pcm.h" |
41 | #include "tegra_asoc_utils.h" | 45 | #include "tegra_asoc_utils.h" |
42 | 46 | ||
43 | #define PREFIX "ASoC Harmony: " | 47 | #define DRV_NAME "tegra-snd-harmony" |
48 | #define PREFIX DRV_NAME ": " | ||
44 | 49 | ||
45 | static struct platform_device *harmony_snd_device; | 50 | struct tegra_harmony { |
51 | }; | ||
46 | 52 | ||
47 | static int harmony_asoc_hw_params(struct snd_pcm_substream *substream, | 53 | static int harmony_asoc_hw_params(struct snd_pcm_substream *substream, |
48 | struct snd_pcm_hw_params *params) | 54 | struct snd_pcm_hw_params *params) |
@@ -154,56 +160,88 @@ static struct snd_soc_card snd_soc_harmony = { | |||
154 | .num_links = 1, | 160 | .num_links = 1, |
155 | }; | 161 | }; |
156 | 162 | ||
157 | static int __init harmony_soc_modinit(void) | 163 | static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev) |
158 | { | 164 | { |
165 | struct snd_soc_card *card = &snd_soc_harmony; | ||
166 | struct tegra_harmony *harmony; | ||
159 | int ret; | 167 | int ret; |
160 | 168 | ||
161 | if (!machine_is_harmony()) { | 169 | if (!machine_is_harmony()) { |
162 | pr_err(PREFIX "Not running on Tegra Harmony!\n"); | 170 | dev_err(&pdev->dev, "Not running on Tegra Harmony!\n"); |
163 | return -ENODEV; | 171 | return -ENODEV; |
164 | } | 172 | } |
165 | 173 | ||
166 | ret = tegra_asoc_utils_init(); | 174 | harmony = kzalloc(sizeof(struct tegra_harmony), GFP_KERNEL); |
167 | if (ret) { | 175 | if (!harmony) { |
168 | return ret; | 176 | dev_err(&pdev->dev, "Can't allocate tegra_harmony\n"); |
177 | return -ENOMEM; | ||
169 | } | 178 | } |
170 | 179 | ||
171 | /* | 180 | ret = tegra_asoc_utils_init(); |
172 | * Create and register platform device | 181 | if (ret) |
173 | */ | 182 | goto err_free_harmony; |
174 | harmony_snd_device = platform_device_alloc("soc-audio", -1); | ||
175 | if (harmony_snd_device == NULL) { | ||
176 | pr_err(PREFIX "platform_device_alloc failed\n"); | ||
177 | ret = -ENOMEM; | ||
178 | goto err_clock_utils; | ||
179 | } | ||
180 | 183 | ||
181 | platform_set_drvdata(harmony_snd_device, &snd_soc_harmony); | 184 | card->dev = &pdev->dev; |
185 | platform_set_drvdata(pdev, card); | ||
186 | snd_soc_card_set_drvdata(card, harmony); | ||
182 | 187 | ||
183 | ret = platform_device_add(harmony_snd_device); | 188 | ret = snd_soc_register_card(card); |
184 | if (ret) { | 189 | if (ret) { |
185 | pr_err(PREFIX "platform_device_add failed (%d)\n", | 190 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", |
186 | ret); | 191 | ret); |
187 | goto err_device_put; | 192 | goto err_clear_drvdata; |
188 | } | 193 | } |
189 | 194 | ||
190 | return 0; | 195 | return 0; |
191 | 196 | ||
192 | err_device_put: | 197 | err_clear_drvdata: |
193 | platform_device_put(harmony_snd_device); | 198 | snd_soc_card_set_drvdata(card, NULL); |
194 | err_clock_utils: | 199 | platform_set_drvdata(pdev, NULL); |
200 | card->dev = NULL; | ||
195 | tegra_asoc_utils_fini(); | 201 | tegra_asoc_utils_fini(); |
202 | err_free_harmony: | ||
203 | kfree(harmony); | ||
196 | return ret; | 204 | return ret; |
197 | } | 205 | } |
198 | module_init(harmony_soc_modinit); | ||
199 | 206 | ||
200 | static void __exit harmony_soc_modexit(void) | 207 | static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev) |
201 | { | 208 | { |
202 | platform_device_unregister(harmony_snd_device); | 209 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
210 | struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card); | ||
211 | |||
212 | snd_soc_unregister_card(card); | ||
213 | |||
214 | snd_soc_card_set_drvdata(card, NULL); | ||
215 | platform_set_drvdata(pdev, NULL); | ||
216 | card->dev = NULL; | ||
203 | 217 | ||
204 | tegra_asoc_utils_fini(); | 218 | tegra_asoc_utils_fini(); |
219 | |||
220 | kfree(harmony); | ||
221 | |||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | static struct platform_driver tegra_snd_harmony_driver = { | ||
226 | .driver = { | ||
227 | .name = DRV_NAME, | ||
228 | .owner = THIS_MODULE, | ||
229 | }, | ||
230 | .probe = tegra_snd_harmony_probe, | ||
231 | .remove = __devexit_p(tegra_snd_harmony_remove), | ||
232 | }; | ||
233 | |||
234 | static int __init snd_tegra_harmony_init(void) | ||
235 | { | ||
236 | return platform_driver_register(&tegra_snd_harmony_driver); | ||
237 | } | ||
238 | module_init(snd_tegra_harmony_init); | ||
239 | |||
240 | static void __exit snd_tegra_harmony_exit(void) | ||
241 | { | ||
242 | platform_driver_unregister(&tegra_snd_harmony_driver); | ||
205 | } | 243 | } |
206 | module_exit(harmony_soc_modexit); | 244 | module_exit(snd_tegra_harmony_exit); |
207 | 245 | ||
208 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); | 246 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); |
209 | MODULE_DESCRIPTION("Harmony machine ASoC driver"); | 247 | MODULE_DESCRIPTION("Harmony machine ASoC driver"); |