ASoC: sam9g20-wm8731: convert to use snd_soc_register_card()

Signed-off-by: Bo Shen <voice.shen@atmel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Bo Shen 2012-10-11 10:38:15 +08:00 committed by Mark Brown
parent 5c86ac695c
commit 242b9bb83e

View file

@ -195,22 +195,15 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = {
.set_bias_level = at91sam9g20ek_set_bias_level, .set_bias_level = at91sam9g20ek_set_bias_level,
}; };
static struct platform_device *at91sam9g20ek_snd_device; static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev)
static int __init at91sam9g20ek_init(void)
{ {
struct clk *pllb; struct clk *pllb;
struct snd_soc_card *card = &snd_soc_at91sam9g20ek;
int ret; int ret;
if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc()))
return -ENODEV; return -ENODEV;
ret = atmel_ssc_set_audio(0);
if (ret != 0) {
pr_err("Failed to set SSC 0 for audio: %d\n", ret);
return ret;
}
/* /*
* Codec MCLK is supplied by PCK0 - set it up. * Codec MCLK is supplied by PCK0 - set it up.
*/ */
@ -236,26 +229,14 @@ static int __init at91sam9g20ek_init(void)
clk_set_rate(mclk, MCLK_RATE); clk_set_rate(mclk, MCLK_RATE);
at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); card->dev = &pdev->dev;
if (!at91sam9g20ek_snd_device) { ret = snd_soc_register_card(card);
printk(KERN_ERR "ASoC: Platform device allocation failed\n");
ret = -ENOMEM;
goto err_mclk;
}
platform_set_drvdata(at91sam9g20ek_snd_device,
&snd_soc_at91sam9g20ek);
ret = platform_device_add(at91sam9g20ek_snd_device);
if (ret) { if (ret) {
printk(KERN_ERR "ASoC: Platform device allocation failed\n"); printk(KERN_ERR "ASoC: snd_soc_register_card() failed\n");
goto err_device_add;
} }
return ret; return ret;
err_device_add:
platform_device_put(at91sam9g20ek_snd_device);
err_mclk: err_mclk:
clk_put(mclk); clk_put(mclk);
mclk = NULL; mclk = NULL;
@ -263,18 +244,30 @@ err:
return ret; return ret;
} }
static void __exit at91sam9g20ek_exit(void) static int __devexit at91sam9g20ek_audio_remove(struct platform_device *pdev)
{ {
platform_device_unregister(at91sam9g20ek_snd_device); struct snd_soc_card *card = platform_get_drvdata(pdev);
at91sam9g20ek_snd_device = NULL;
snd_soc_unregister_card(card);
clk_put(mclk); clk_put(mclk);
mclk = NULL; mclk = NULL;
return 0;
} }
module_init(at91sam9g20ek_init); static struct platform_driver at91sam9g20ek_audio_driver = {
module_exit(at91sam9g20ek_exit); .driver = {
.name = "at91sam9g20ek-audio",
.owner = THIS_MODULE,
},
.probe = at91sam9g20ek_audio_probe,
.remove = __devexit_p(at91sam9g20ek_audio_remove),
};
module_platform_driver(at91sam9g20ek_audio_driver);
/* Module information */ /* Module information */
MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>"); MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>");
MODULE_DESCRIPTION("ALSA SoC AT91SAM9G20EK_WM8731"); MODULE_DESCRIPTION("ALSA SoC AT91SAM9G20EK_WM8731");
MODULE_ALIAS("platform:at91sam9g20ek-audio");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");