aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/pxa/e750_wm9705.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2011-12-14 21:53:29 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-17 04:31:29 -0500
commit5eb2c3d9273ae63d6b347cde38fe15bda8be1361 (patch)
treea0095ff505c3b3072260e79931c16aca808c173c /sound/soc/pxa/e750_wm9705.c
parent62133829fa12a55902ac400b74e424c1ecd161b3 (diff)
ASoC: pxa: Convert e750_wm9705 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>
Diffstat (limited to 'sound/soc/pxa/e750_wm9705.c')
-rw-r--r--sound/soc/pxa/e750_wm9705.c66
1 files changed, 31 insertions, 35 deletions
diff --git a/sound/soc/pxa/e750_wm9705.c b/sound/soc/pxa/e750_wm9705.c
index 55c53d13bea6..27f90cc44234 100644
--- a/sound/soc/pxa/e750_wm9705.c
+++ b/sound/soc/pxa/e750_wm9705.c
@@ -120,58 +120,54 @@ static struct snd_soc_card e750 = {
120 .num_links = ARRAY_SIZE(e750_dai), 120 .num_links = ARRAY_SIZE(e750_dai),
121}; 121};
122 122
123static struct platform_device *e750_snd_device; 123static struct gpio e750_audio_gpios[] = {
124 { GPIO_E750_HP_AMP_OFF, GPIOF_OUT_INIT_HIGH, "Headphone amp" },
125 { GPIO_E750_SPK_AMP_OFF, GPIOF_OUT_INIT_HIGH, "Speaker amp" },
126};
124 127
125static int __init e750_init(void) 128static int __devinit e750_probe(struct platform_device *pdev)
126{ 129{
130 struct snd_soc_card *card = &e750;
127 int ret; 131 int ret;
128 132
129 if (!machine_is_e750()) 133 ret = gpio_request_array(e750_audio_gpios,
130 return -ENODEV; 134 ARRAY_SIZE(e750_audio_gpios));
131
132 ret = gpio_request_one(GPIO_E750_HP_AMP_OFF, GPIOF_OUT_INIT_HIGH,
133 "Headphone amp");
134 if (ret) 135 if (ret)
135 return ret; 136 return ret;
136 137
137 ret = gpio_request_one(GPIO_E750_SPK_AMP_OFF, GPIOF_OUT_INIT_HIGH, 138 card->dev = &pdev->dev;
138 "Speaker amp");
139 if (ret)
140 goto free_hp_amp_gpio;
141 139
142 e750_snd_device = platform_device_alloc("soc-audio", -1); 140 ret = snd_soc_register_card(card);
143 if (!e750_snd_device) { 141 if (ret) {
144 ret = -ENOMEM; 142 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
145 goto free_spk_amp_gpio; 143 ret);
144 gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios));
146 } 145 }
147
148 platform_set_drvdata(e750_snd_device, &e750);
149 ret = platform_device_add(e750_snd_device);
150
151 if (!ret)
152 return 0;
153
154/* Fail gracefully */
155 platform_device_put(e750_snd_device);
156free_spk_amp_gpio:
157 gpio_free(GPIO_E750_SPK_AMP_OFF);
158free_hp_amp_gpio:
159 gpio_free(GPIO_E750_HP_AMP_OFF);
160
161 return ret; 146 return ret;
162} 147}
163 148
164static void __exit e750_exit(void) 149static int __devexit e750_remove(struct platform_device *pdev)
165{ 150{
166 platform_device_unregister(e750_snd_device); 151 struct snd_soc_card *card = platform_get_drvdata(pdev);
167 gpio_free(GPIO_E750_SPK_AMP_OFF); 152
168 gpio_free(GPIO_E750_HP_AMP_OFF); 153 gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios));
154 snd_soc_unregister_card(card);
155 return 0;
169} 156}
170 157
171module_init(e750_init); 158static struct platform_driver e750_driver = {
172module_exit(e750_exit); 159 .driver = {
160 .name = "e750-audio",
161 .owner = THIS_MODULE,
162 },
163 .probe = e750_probe,
164 .remove = __devexit_p(e750_remove),
165};
166
167module_platform_driver(e750_driver);
173 168
174/* Module information */ 169/* Module information */
175MODULE_AUTHOR("Ian Molton <spyro@f2s.com>"); 170MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
176MODULE_DESCRIPTION("ALSA SoC driver for e750"); 171MODULE_DESCRIPTION("ALSA SoC driver for e750");
177MODULE_LICENSE("GPL v2"); 172MODULE_LICENSE("GPL v2");
173MODULE_ALIAS("platform:e750-audio");