aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2011-12-14 21:54:25 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-17 04:31:31 -0500
commit1eb0202dc7e45be5996416bc41489ae5a75485e5 (patch)
tree1527825a28772e184d2b57d9b7dd8f3a78b66ac6
parentf285b8c83a8dccc70f168bb1eb6f04c8e36450a6 (diff)
ASoC: pxa: Convert e800_wm9712 to use snd_soc_register_card()
Use snd_soc_register_card() instead of creating a "soc-audio" platform device. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--arch/arm/mach-pxa/eseries.c6
-rw-r--r--sound/soc/pxa/e800_wm9712.c66
2 files changed, 37 insertions, 35 deletions
diff --git a/arch/arm/mach-pxa/eseries.c b/arch/arm/mach-pxa/eseries.c
index 3abfdb908d4c..4bbc3facde69 100644
--- a/arch/arm/mach-pxa/eseries.c
+++ b/arch/arm/mach-pxa/eseries.c
@@ -936,12 +936,18 @@ static struct platform_device e800_tc6393xb_device = {
936 .resource = eseries_tmio_resources, 936 .resource = eseries_tmio_resources,
937}; 937};
938 938
939static struct platform_device e800_audio_device = {
940 .name = "e800-audio",
941 .id = -1,
942};
943
939/* ----------------------------------------------------------------------- */ 944/* ----------------------------------------------------------------------- */
940 945
941static struct platform_device *e800_devices[] __initdata = { 946static struct platform_device *e800_devices[] __initdata = {
942 &e800_fb_device, 947 &e800_fb_device,
943 &e800_tc6393xb_device, 948 &e800_tc6393xb_device,
944 &e800_gpio_vbus, 949 &e800_gpio_vbus,
950 &e800_audio_device,
945}; 951};
946 952
947static void __init e800_init(void) 953static void __init e800_init(void)
diff --git a/sound/soc/pxa/e800_wm9712.c b/sound/soc/pxa/e800_wm9712.c
index 478ff191ffb4..858bf94160c5 100644
--- a/sound/soc/pxa/e800_wm9712.c
+++ b/sound/soc/pxa/e800_wm9712.c
@@ -110,58 +110,54 @@ static struct snd_soc_card e800 = {
110 .num_links = ARRAY_SIZE(e800_dai), 110 .num_links = ARRAY_SIZE(e800_dai),
111}; 111};
112 112
113static struct platform_device *e800_snd_device; 113static struct gpio e800_audio_gpios[] = {
114 { GPIO_E800_SPK_AMP_ON, GPIOF_OUT_INIT_HIGH, "Headphone amp" },
115 { GPIO_E800_HP_AMP_OFF, GPIOF_OUT_INIT_HIGH, "Speaker amp" },
116};
114 117
115static int __init e800_init(void) 118static int __devinit e800_probe(struct platform_device *pdev)
116{ 119{
120 struct snd_soc_card *card = &e800;
117 int ret; 121 int ret;
118 122
119 if (!machine_is_e800()) 123 ret = gpio_request_array(e800_audio_gpios,
120 return -ENODEV; 124 ARRAY_SIZE(e800_audio_gpios));
121
122 ret = gpio_request_one(GPIO_E800_HP_AMP_OFF, GPIOF_OUT_INIT_HIGH,
123 "Headphone amp");
124 if (ret) 125 if (ret)
125 return ret; 126 return ret;
126 127
127 ret = gpio_request_one(GPIO_E800_SPK_AMP_ON, GPIOF_OUT_INIT_HIGH, 128 card->dev = &pdev->dev;
128 "Speaker amp");
129 if (ret)
130 goto free_hp_amp_gpio;
131 129
132 e800_snd_device = platform_device_alloc("soc-audio", -1); 130 ret = snd_soc_register_card(card);
133 if (!e800_snd_device) { 131 if (ret) {
134 ret = -ENOMEM; 132 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
135 goto free_spk_amp_gpio; 133 ret);
134 gpio_free_array(e800_audio_gpios, ARRAY_SIZE(e800_audio_gpios));
136 } 135 }
137
138 platform_set_drvdata(e800_snd_device, &e800);
139 ret = platform_device_add(e800_snd_device);
140
141 if (!ret)
142 return 0;
143
144/* Fail gracefully */
145 platform_device_put(e800_snd_device);
146free_spk_amp_gpio:
147 gpio_free(GPIO_E800_SPK_AMP_ON);
148free_hp_amp_gpio:
149 gpio_free(GPIO_E800_HP_AMP_OFF);
150
151 return ret; 136 return ret;
152} 137}
153 138
154static void __exit e800_exit(void) 139static int __devexit e800_remove(struct platform_device *pdev)
155{ 140{
156 platform_device_unregister(e800_snd_device); 141 struct snd_soc_card *card = platform_get_drvdata(pdev);
157 gpio_free(GPIO_E800_SPK_AMP_ON); 142
158 gpio_free(GPIO_E800_HP_AMP_OFF); 143 gpio_free_array(e800_audio_gpios, ARRAY_SIZE(e800_audio_gpios));
144 snd_soc_unregister_card(card);
145 return 0;
159} 146}
160 147
161module_init(e800_init); 148static struct platform_driver e800_driver = {
162module_exit(e800_exit); 149 .driver = {
150 .name = "e800-audio",
151 .owner = THIS_MODULE,
152 },
153 .probe = e800_probe,
154 .remove = __devexit_p(e800_remove),
155};
156
157module_platform_driver(e800_driver);
163 158
164/* Module information */ 159/* Module information */
165MODULE_AUTHOR("Ian Molton <spyro@f2s.com>"); 160MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
166MODULE_DESCRIPTION("ALSA SoC driver for e800"); 161MODULE_DESCRIPTION("ALSA SoC driver for e800");
167MODULE_LICENSE("GPL v2"); 162MODULE_LICENSE("GPL v2");
163MODULE_ALIAS("platform:e800-audio");