1 From 94f2b91d2a42854a8869d54a758bc88757d7f6d9 Mon Sep 17 00:00:00 2001
2 From: Axel Lin <axel.lin@gmail.com>
3 Date: Fri, 6 Jan 2012 11:30:10 +0800
4 Subject: [PATCH 18/21] ASoC: jz4740: Convert qi_lb60 to use
5 snd_soc_register_card()
7 Use snd_soc_register_card() instead of creating a "soc-audio" platform device.
9 Signed-off-by: Axel Lin <axel.lin@gmail.com>
11 arch/mips/jz4740/board-qi_lb60.c | 6 ++++
12 sound/soc/jz4740/qi_lb60.c | 56 +++++++++++++++++--------------------
13 2 files changed, 32 insertions(+), 30 deletions(-)
15 diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
16 index f2d94c1..be14dfb 100644
17 --- a/arch/mips/jz4740/board-qi_lb60.c
18 +++ b/arch/mips/jz4740/board-qi_lb60.c
19 @@ -418,6 +418,11 @@ static struct platform_device qi_lb60_charger_device = {
24 +static struct platform_device qi_lb60_audio_device = {
25 + .name = "qi-lb60-audio",
29 static struct platform_device *jz_platform_devices[] __initdata = {
31 @@ -434,6 +439,7 @@ static struct platform_device *jz_platform_devices[] __initdata = {
34 &qi_lb60_charger_device,
35 + &qi_lb60_audio_device,
38 static void __init board_gpio_setup(void)
39 diff --git a/sound/soc/jz4740/qi_lb60.c b/sound/soc/jz4740/qi_lb60.c
40 index c5fc339..67ddbdd 100644
41 --- a/sound/soc/jz4740/qi_lb60.c
42 +++ b/sound/soc/jz4740/qi_lb60.c
43 @@ -90,56 +90,52 @@ static struct snd_soc_card qi_lb60 = {
44 .num_dapm_routes = ARRAY_SIZE(qi_lb60_routes),
47 -static struct platform_device *qi_lb60_snd_device;
49 static const struct gpio qi_lb60_gpios[] = {
50 { QI_LB60_SND_GPIO, GPIOF_OUT_INIT_LOW, "SND" },
51 { QI_LB60_AMP_GPIO, GPIOF_OUT_INIT_LOW, "AMP" },
54 -static int __init qi_lb60_init(void)
55 +static int __devinit qi_lb60_probe(struct platform_device *pdev)
57 + struct snd_soc_card *card = &qi_lb60;
60 - qi_lb60_snd_device = platform_device_alloc("soc-audio", -1);
62 - if (!qi_lb60_snd_device)
65 ret = gpio_request_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
67 - pr_err("qi_lb60 snd: Failed to request gpios: %d\n", ret);
68 - goto err_device_put;
73 - platform_set_drvdata(qi_lb60_snd_device, &qi_lb60);
74 + card->dev = &pdev->dev;
76 - ret = platform_device_add(qi_lb60_snd_device);
77 + ret = snd_soc_register_card(card);
79 - pr_err("qi_lb60 snd: Failed to add snd soc device: %d\n", ret);
80 - goto err_unset_pdata;
81 + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
83 + gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
89 - platform_set_drvdata(qi_lb60_snd_device, NULL);
90 -/*err_gpio_free_array:*/
91 - gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
93 - platform_device_put(qi_lb60_snd_device);
97 -module_init(qi_lb60_init);
99 -static void __exit qi_lb60_exit(void)
100 +static int __devexit qi_lb60_remove(struct platform_device *pdev)
102 - platform_device_unregister(qi_lb60_snd_device);
103 + struct snd_soc_card *card = platform_get_drvdata(pdev);
105 + snd_soc_unregister_card(card);
106 gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
109 -module_exit(qi_lb60_exit);
111 +static struct platform_driver qi_lb60_driver = {
113 + .name = "qi-lb60-audio",
114 + .owner = THIS_MODULE,
116 + .probe = qi_lb60_probe,
117 + .remove = __devexit_p(qi_lb60_remove),
120 +module_platform_driver(qi_lb60_driver);
122 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
123 MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support");
124 MODULE_LICENSE("GPL v2");
125 +MODULE_ALIAS("platform:qi-lb60-audio");