Root/target/linux/xburst/patches-3.2/0019-ASoC-jz4740-Convert-qi_lb60-to-use-snd_soc_register_.patch

1From 7be17b01bffeccb75c1058eac949f99c3040a9f7 Mon Sep 17 00:00:00 2001
2From: Axel Lin <axel.lin@gmail.com>
3Date: Fri, 6 Jan 2012 11:30:10 +0800
4Subject: [PATCH 19/28] ASoC: jz4740: Convert qi_lb60 to use
5 snd_soc_register_card()
6
7Use snd_soc_register_card() instead of creating a "soc-audio" platform device.
8
9Signed-off-by: Axel Lin <axel.lin@gmail.com>
10---
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(-)
14
15diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
16index 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 = {
20     },
21 };
22 
23+/* audio */
24+static struct platform_device qi_lb60_audio_device = {
25+ .name = "qi-lb60-audio",
26+ .id = -1,
27+};
28 
29 static struct platform_device *jz_platform_devices[] __initdata = {
30     &jz4740_udc_device,
31@@ -434,6 +439,7 @@ static struct platform_device *jz_platform_devices[] __initdata = {
32     &qi_lb60_gpio_keys,
33     &qi_lb60_pwm_beeper,
34     &qi_lb60_charger_device,
35+ &qi_lb60_audio_device,
36 };
37 
38 static void __init board_gpio_setup(void)
39diff --git a/sound/soc/jz4740/qi_lb60.c b/sound/soc/jz4740/qi_lb60.c
40index 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),
45 };
46 
47-static struct platform_device *qi_lb60_snd_device;
48-
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" },
52 };
53 
54-static int __init qi_lb60_init(void)
55+static int __devinit qi_lb60_probe(struct platform_device *pdev)
56 {
57+ struct snd_soc_card *card = &qi_lb60;
58     int ret;
59 
60- qi_lb60_snd_device = platform_device_alloc("soc-audio", -1);
61-
62- if (!qi_lb60_snd_device)
63- return -ENOMEM;
64-
65     ret = gpio_request_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
66- if (ret) {
67- pr_err("qi_lb60 snd: Failed to request gpios: %d\n", ret);
68- goto err_device_put;
69- }
70+ if (ret)
71+ return ret;
72 
73- platform_set_drvdata(qi_lb60_snd_device, &qi_lb60);
74+ card->dev = &pdev->dev;
75 
76- ret = platform_device_add(qi_lb60_snd_device);
77+ ret = snd_soc_register_card(card);
78     if (ret) {
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",
82+ ret);
83+ gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
84     }
85-
86- return 0;
87-
88-err_unset_pdata:
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));
92-err_device_put:
93- platform_device_put(qi_lb60_snd_device);
94-
95     return ret;
96 }
97-module_init(qi_lb60_init);
98 
99-static void __exit qi_lb60_exit(void)
100+static int __devexit qi_lb60_remove(struct platform_device *pdev)
101 {
102- platform_device_unregister(qi_lb60_snd_device);
103+ struct snd_soc_card *card = platform_get_drvdata(pdev);
104+
105+ snd_soc_unregister_card(card);
106     gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
107+ return 0;
108 }
109-module_exit(qi_lb60_exit);
110+
111+static struct platform_driver qi_lb60_driver = {
112+ .driver = {
113+ .name = "qi-lb60-audio",
114+ .owner = THIS_MODULE,
115+ },
116+ .probe = qi_lb60_probe,
117+ .remove = __devexit_p(qi_lb60_remove),
118+};
119+
120+module_platform_driver(qi_lb60_driver);
121 
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");
126--
1271.7.5.4
128
129

Archive Download this file



interactive