aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/jz4740/qi_lb60.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/jz4740/qi_lb60.c')
-rw-r--r--sound/soc/jz4740/qi_lb60.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/sound/soc/jz4740/qi_lb60.c b/sound/soc/jz4740/qi_lb60.c
index 0097c3b13a1a..e8aaff18d7cc 100644
--- a/sound/soc/jz4740/qi_lb60.c
+++ b/sound/soc/jz4740/qi_lb60.c
@@ -91,56 +91,52 @@ static struct snd_soc_card qi_lb60 = {
91 .num_dapm_routes = ARRAY_SIZE(qi_lb60_routes), 91 .num_dapm_routes = ARRAY_SIZE(qi_lb60_routes),
92}; 92};
93 93
94static struct platform_device *qi_lb60_snd_device;
95
96static const struct gpio qi_lb60_gpios[] = { 94static const struct gpio qi_lb60_gpios[] = {
97 { QI_LB60_SND_GPIO, GPIOF_OUT_INIT_LOW, "SND" }, 95 { QI_LB60_SND_GPIO, GPIOF_OUT_INIT_LOW, "SND" },
98 { QI_LB60_AMP_GPIO, GPIOF_OUT_INIT_LOW, "AMP" }, 96 { QI_LB60_AMP_GPIO, GPIOF_OUT_INIT_LOW, "AMP" },
99}; 97};
100 98
101static int __init qi_lb60_init(void) 99static int __devinit qi_lb60_probe(struct platform_device *pdev)
102{ 100{
101 struct snd_soc_card *card = &qi_lb60;
103 int ret; 102 int ret;
104 103
105 qi_lb60_snd_device = platform_device_alloc("soc-audio", -1);
106
107 if (!qi_lb60_snd_device)
108 return -ENOMEM;
109
110 ret = gpio_request_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios)); 104 ret = gpio_request_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
111 if (ret) { 105 if (ret)
112 pr_err("qi_lb60 snd: Failed to request gpios: %d\n", ret); 106 return ret;
113 goto err_device_put;
114 }
115 107
116 platform_set_drvdata(qi_lb60_snd_device, &qi_lb60); 108 card->dev = &pdev->dev;
117 109
118 ret = platform_device_add(qi_lb60_snd_device); 110 ret = snd_soc_register_card(card);
119 if (ret) { 111 if (ret) {
120 pr_err("qi_lb60 snd: Failed to add snd soc device: %d\n", ret); 112 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
121 goto err_unset_pdata; 113 ret);
114 gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
122 } 115 }
123
124 return 0;
125
126err_unset_pdata:
127 platform_set_drvdata(qi_lb60_snd_device, NULL);
128/*err_gpio_free_array:*/
129 gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
130err_device_put:
131 platform_device_put(qi_lb60_snd_device);
132
133 return ret; 116 return ret;
134} 117}
135module_init(qi_lb60_init);
136 118
137static void __exit qi_lb60_exit(void) 119static int __devexit qi_lb60_remove(struct platform_device *pdev)
138{ 120{
139 platform_device_unregister(qi_lb60_snd_device); 121 struct snd_soc_card *card = platform_get_drvdata(pdev);
122
123 snd_soc_unregister_card(card);
140 gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios)); 124 gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
125 return 0;
141} 126}
142module_exit(qi_lb60_exit); 127
128static struct platform_driver qi_lb60_driver = {
129 .driver = {
130 .name = "qi-lb60-audio",
131 .owner = THIS_MODULE,
132 },
133 .probe = qi_lb60_probe,
134 .remove = __devexit_p(qi_lb60_remove),
135};
136
137module_platform_driver(qi_lb60_driver);
143 138
144MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); 139MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
145MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support"); 140MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support");
146MODULE_LICENSE("GPL v2"); 141MODULE_LICENSE("GPL v2");
142MODULE_ALIAS("platform:qi-lb60-audio");