Date:2012-01-06 04:30:10 (10 years 8 months ago)
Author:Axel Lin
Commit:d6871a8333af99bfe7505fc3b1222c340530c850
Message:ASoC: jz4740: Convert qi_lb60 to use snd_soc_register_card()

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

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Files: arch/mips/jz4740/board-qi_lb60.c (2 diffs)
sound/soc/jz4740/qi_lb60.c (1 diff)

Change Details

arch/mips/jz4740/board-qi_lb60.c
417417    },
418418};
419419
420/* audio */
421static struct platform_device qi_lb60_audio_device = {
422    .name = "qi-lb60-audio",
423    .id = -1,
424};
420425
421426static struct platform_device *jz_platform_devices[] __initdata = {
422427    &jz4740_udc_device,
...... 
433438    &qi_lb60_gpio_keys,
434439    &qi_lb60_pwm_beeper,
435440    &qi_lb60_charger_device,
441    &qi_lb60_audio_device,
436442};
437443
438444static void __init board_gpio_setup(void)
sound/soc/jz4740/qi_lb60.c
9191    .num_dapm_routes = ARRAY_SIZE(qi_lb60_routes),
9292};
9393
94static struct platform_device *qi_lb60_snd_device;
95
9694static const struct gpio qi_lb60_gpios[] = {
9795    { QI_LB60_SND_GPIO, GPIOF_OUT_INIT_LOW, "SND" },
9896    { QI_LB60_AMP_GPIO, GPIOF_OUT_INIT_LOW, "AMP" },
9997};
10098
101static int __init qi_lb60_init(void)
99static int __devinit qi_lb60_probe(struct platform_device *pdev)
102100{
101    struct snd_soc_card *card = &qi_lb60;
103102    int ret;
104103
105    qi_lb60_snd_device = platform_device_alloc("soc-audio", -1);
106
107    if (!qi_lb60_snd_device)
108        return -ENOMEM;
109
110104    ret = gpio_request_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
111    if (ret) {
112        pr_err("qi_lb60 snd: Failed to request gpios: %d\n", ret);
113        goto err_device_put;
114    }
105    if (ret)
106        return ret;
115107
116    platform_set_drvdata(qi_lb60_snd_device, &qi_lb60);
108    card->dev = &pdev->dev;
117109
118    ret = platform_device_add(qi_lb60_snd_device);
110    ret = snd_soc_register_card(card);
119111    if (ret) {
120        pr_err("qi_lb60 snd: Failed to add snd soc device: %d\n", ret);
121        goto err_unset_pdata;
112        dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
113            ret);
114        gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
122115    }
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
133116    return ret;
134117}
135module_init(qi_lb60_init);
136118
137static void __exit qi_lb60_exit(void)
119static int __devexit qi_lb60_remove(struct platform_device *pdev)
138120{
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);
140124    gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
125    return 0;
141126}
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);
143138
144139MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
145140MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support");
146141MODULE_LICENSE("GPL v2");
142MODULE_ALIAS("platform:qi-lb60-audio");

Archive Download the corresponding diff file



interactive