Date:2012-01-06 04:30:10 (8 years 8 months ago)
Author:Axel Lin
Commit:c80c63ae314c7afe22dfc74ac55b2c4879c064b9
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
418418    },
419419};
420420
421/* audio */
422static struct platform_device qi_lb60_audio_device = {
423    .name = "qi-lb60-audio",
424    .id = -1,
425};
421426
422427static struct platform_device *jz_platform_devices[] __initdata = {
423428    &jz4740_udc_device,
...... 
434439    &qi_lb60_gpio_keys,
435440    &qi_lb60_pwm_beeper,
436441    &qi_lb60_charger_device,
442    &qi_lb60_audio_device,
437443};
438444
439445static void __init board_gpio_setup(void)
sound/soc/jz4740/qi_lb60.c
9090    .num_dapm_routes = ARRAY_SIZE(qi_lb60_routes),
9191};
9292
93static struct platform_device *qi_lb60_snd_device;
94
9593static const struct gpio qi_lb60_gpios[] = {
9694    { QI_LB60_SND_GPIO, GPIOF_OUT_INIT_LOW, "SND" },
9795    { QI_LB60_AMP_GPIO, GPIOF_OUT_INIT_LOW, "AMP" },
9896};
9997
100static int __init qi_lb60_init(void)
98static int __devinit qi_lb60_probe(struct platform_device *pdev)
10199{
100    struct snd_soc_card *card = &qi_lb60;
102101    int ret;
103102
104    qi_lb60_snd_device = platform_device_alloc("soc-audio", -1);
105
106    if (!qi_lb60_snd_device)
107        return -ENOMEM;
108
109103    ret = gpio_request_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
110    if (ret) {
111        pr_err("qi_lb60 snd: Failed to request gpios: %d\n", ret);
112        goto err_device_put;
113    }
104    if (ret)
105        return ret;
114106
115    platform_set_drvdata(qi_lb60_snd_device, &qi_lb60);
107    card->dev = &pdev->dev;
116108
117    ret = platform_device_add(qi_lb60_snd_device);
109    ret = snd_soc_register_card(card);
118110    if (ret) {
119        pr_err("qi_lb60 snd: Failed to add snd soc device: %d\n", ret);
120        goto err_unset_pdata;
111        dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
112            ret);
113        gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
121114    }
122
123     return 0;
124
125err_unset_pdata:
126    platform_set_drvdata(qi_lb60_snd_device, NULL);
127/*err_gpio_free_array:*/
128    gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
129err_device_put:
130    platform_device_put(qi_lb60_snd_device);
131
132115    return ret;
133116}
134module_init(qi_lb60_init);
135117
136static void __exit qi_lb60_exit(void)
118static int __devexit qi_lb60_remove(struct platform_device *pdev)
137119{
138    platform_device_unregister(qi_lb60_snd_device);
120    struct snd_soc_card *card = platform_get_drvdata(pdev);
121
122    snd_soc_unregister_card(card);
139123    gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios));
124    return 0;
140125}
141module_exit(qi_lb60_exit);
126
127static struct platform_driver qi_lb60_driver = {
128    .driver = {
129        .name = "qi-lb60-audio",
130        .owner = THIS_MODULE,
131    },
132    .probe = qi_lb60_probe,
133    .remove = __devexit_p(qi_lb60_remove),
134};
135
136module_platform_driver(qi_lb60_driver);
142137
143138MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
144139MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support");
145140MODULE_LICENSE("GPL v2");
141MODULE_ALIAS("platform:qi-lb60-audio");

Archive Download the corresponding diff file



interactive