Date:2012-05-21 14:35:16 (10 years 4 months ago)
Author:Maarten ter Huurne
Commit:fbb88c547b69af5f058a6959d0f33a1398287afe
Message:ASoC: JZ4740: Convert a320 to use snd_soc_register_card().

Use snd_soc_register_card() instead of creating a "soc-audio" platform device.

This commit is the a320 adaptation of the qi_lb60 changes from Axel Lin's
commit d6871a8333af99bfe7505fc3b1222c340530c850.
Files: arch/mips/jz4740/board-a320.c (2 diffs)
sound/soc/jz4740/a320.c (1 diff)

Change Details

arch/mips/jz4740/board-a320.c
354354    },
355355};
356356
357/* Audio */
358static struct platform_device a320_audio_device = {
359    .name = "a320-audio",
360    .id = -1,
361};
362
357363static struct platform_device *jz_platform_devices[] __initdata = {
358364#ifdef CONFIG_I2C_JZ47XX
359365    &jz4740_i2c_device,
...... 
377383    &a320_charger_device,
378384    &a320_backlight_device,
379385    &a320_gpio_keys_device,
386    &a320_audio_device,
380387};
381388
382389static void __init board_gpio_setup(void)
sound/soc/jz4740/a320.c
104104    .num_links = 1,
105105};
106106
107static struct platform_device *a320_snd_device;
108
109static int __init a320_init(void)
107static int __devinit a320_probe(struct platform_device *pdev)
110108{
109    struct snd_soc_card *card = &a320;
111110    int ret;
112111
113    a320_snd_device = platform_device_alloc("soc-audio", -1);
114
115    if (!a320_snd_device)
116        return -ENOMEM;
117
118112    ret = gpio_request(A320_SPK_GPIO, "SPK");
119113    if (ret) {
120        pr_err("a320 snd: Failed to request SPK GPIO(%d): %d\n",
121                A320_SPK_GPIO, ret);
122        goto err_device_put;
114        dev_err(&pdev->dev, "Failed to request SPK GPIO(%d): %d\n",
115            A320_SPK_GPIO, ret);
116        return ret;
123117    }
124118
125119    ret = gpio_request(A320_HPTV_GPIO, "HPTV");
126120    if (ret) {
127        pr_err("a320 snd: Failed to request HPTV GPIO(%d): %d\n",
128                A320_HPTV_GPIO, ret);
121        dev_err(&pdev->dev, "Failed to request HPTV GPIO(%d): %d\n",
122            A320_HPTV_GPIO, ret);
129123        goto err_gpio_free_spk;
130124    }
131125
132126    gpio_direction_output(A320_SPK_GPIO, 0);
133127    gpio_direction_output(A320_HPTV_GPIO, 0);
134128
135    platform_set_drvdata(a320_snd_device, &a320);
129    card->dev = &pdev->dev;
136130
137    ret = platform_device_add(a320_snd_device);
131    ret = snd_soc_register_card(card);
138132    if (ret) {
139        pr_err("a320 snd: Failed to add snd soc device: %d\n", ret);
140        goto err_unset_pdata;
133        dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
134            ret);
135        goto err_gpio_free_hptv;
141136    }
142137
143     return 0;
138    return 0;
144139
145err_unset_pdata:
146    platform_set_drvdata(a320_snd_device, NULL);
147/*err_gpio_free_hptv:*/
140err_gpio_free_hptv:
148141    gpio_free(A320_HPTV_GPIO);
149142err_gpio_free_spk:
150143    gpio_free(A320_SPK_GPIO);
151err_device_put:
152    platform_device_put(a320_snd_device);
153144
154145    return ret;
155146}
156module_init(a320_init);
157147
158static void __exit a320_exit(void)
148static int __devexit a320_remove(struct platform_device *pdev)
159149{
150    struct snd_soc_card *card = platform_get_drvdata(pdev);
151
152    snd_soc_unregister_card(card);
160153    gpio_free(A320_HPTV_GPIO);
161154    gpio_free(A320_SPK_GPIO);
162    platform_device_unregister(a320_snd_device);
155    return 0;
163156}
164module_exit(a320_exit);
157
158static struct platform_driver a320_driver = {
159    .driver = {
160        .name = "a320-audio",
161        .owner = THIS_MODULE,
162    },
163    .probe = a320_probe,
164    .remove = __devexit_p(a320_remove),
165};
166
167module_platform_driver(a320_driver);
165168
166169MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>, Maarten ter Huurne <maarten@treewalker.org>, Paul Cercueil <paul@crapouillou.net>");
167170MODULE_DESCRIPTION("ALSA SoC Dingoo A320 Audio support");
168171MODULE_LICENSE("GPL v2");
172MODULE_ALIAS("platform:a320-audio");

Archive Download the corresponding diff file



interactive