| 1 | From 94f2b91d2a42854a8869d54a758bc88757d7f6d9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Axel Lin <axel.lin@gmail.com> |
| 3 | Date: Fri, 6 Jan 2012 11:30:10 +0800 |
| 4 | Subject: [PATCH 18/21] ASoC: jz4740: Convert qi_lb60 to use |
| 5 | snd_soc_register_card() |
| 6 | |
| 7 | Use snd_soc_register_card() instead of creating a "soc-audio" platform device. |
| 8 | |
| 9 | Signed-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 | |
| 15 | --- a/arch/mips/jz4740/board-qi_lb60.c |
| 16 | +++ b/arch/mips/jz4740/board-qi_lb60.c |
| 17 | @@ -418,6 +418,11 @@ static struct platform_device qi_lb60_ch |
| 18 | }, |
| 19 | }; |
| 20 | |
| 21 | +/* audio */ |
| 22 | +static struct platform_device qi_lb60_audio_device = { |
| 23 | + .name = "qi-lb60-audio", |
| 24 | + .id = -1, |
| 25 | +}; |
| 26 | |
| 27 | static struct platform_device *jz_platform_devices[] __initdata = { |
| 28 | &jz4740_udc_device, |
| 29 | @@ -434,6 +439,7 @@ static struct platform_device *jz_platfo |
| 30 | &qi_lb60_gpio_keys, |
| 31 | &qi_lb60_pwm_beeper, |
| 32 | &qi_lb60_charger_device, |
| 33 | + &qi_lb60_audio_device, |
| 34 | }; |
| 35 | |
| 36 | static void __init board_gpio_setup(void) |
| 37 | --- a/sound/soc/jz4740/qi_lb60.c |
| 38 | +++ b/sound/soc/jz4740/qi_lb60.c |
| 39 | @@ -91,56 +91,52 @@ static struct snd_soc_card qi_lb60 = { |
| 40 | .num_dapm_routes = ARRAY_SIZE(qi_lb60_routes), |
| 41 | }; |
| 42 | |
| 43 | -static struct platform_device *qi_lb60_snd_device; |
| 44 | - |
| 45 | static const struct gpio qi_lb60_gpios[] = { |
| 46 | { QI_LB60_SND_GPIO, GPIOF_OUT_INIT_LOW, "SND" }, |
| 47 | { QI_LB60_AMP_GPIO, GPIOF_OUT_INIT_LOW, "AMP" }, |
| 48 | }; |
| 49 | |
| 50 | -static int __init qi_lb60_init(void) |
| 51 | +static int __devinit qi_lb60_probe(struct platform_device *pdev) |
| 52 | { |
| 53 | + struct snd_soc_card *card = &qi_lb60; |
| 54 | int ret; |
| 55 | |
| 56 | - qi_lb60_snd_device = platform_device_alloc("soc-audio", -1); |
| 57 | - |
| 58 | - if (!qi_lb60_snd_device) |
| 59 | - return -ENOMEM; |
| 60 | - |
| 61 | ret = gpio_request_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios)); |
| 62 | - if (ret) { |
| 63 | - pr_err("qi_lb60 snd: Failed to request gpios: %d\n", ret); |
| 64 | - goto err_device_put; |
| 65 | - } |
| 66 | + if (ret) |
| 67 | + return ret; |
| 68 | |
| 69 | - platform_set_drvdata(qi_lb60_snd_device, &qi_lb60); |
| 70 | + card->dev = &pdev->dev; |
| 71 | |
| 72 | - ret = platform_device_add(qi_lb60_snd_device); |
| 73 | + ret = snd_soc_register_card(card); |
| 74 | if (ret) { |
| 75 | - pr_err("qi_lb60 snd: Failed to add snd soc device: %d\n", ret); |
| 76 | - goto err_unset_pdata; |
| 77 | + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", |
| 78 | + ret); |
| 79 | + gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios)); |
| 80 | } |
| 81 | - |
| 82 | - return 0; |
| 83 | - |
| 84 | -err_unset_pdata: |
| 85 | - platform_set_drvdata(qi_lb60_snd_device, NULL); |
| 86 | -/*err_gpio_free_array:*/ |
| 87 | - gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios)); |
| 88 | -err_device_put: |
| 89 | - platform_device_put(qi_lb60_snd_device); |
| 90 | - |
| 91 | return ret; |
| 92 | } |
| 93 | -module_init(qi_lb60_init); |
| 94 | |
| 95 | -static void __exit qi_lb60_exit(void) |
| 96 | +static int __devexit qi_lb60_remove(struct platform_device *pdev) |
| 97 | { |
| 98 | - platform_device_unregister(qi_lb60_snd_device); |
| 99 | + struct snd_soc_card *card = platform_get_drvdata(pdev); |
| 100 | + |
| 101 | + snd_soc_unregister_card(card); |
| 102 | gpio_free_array(qi_lb60_gpios, ARRAY_SIZE(qi_lb60_gpios)); |
| 103 | + return 0; |
| 104 | } |
| 105 | -module_exit(qi_lb60_exit); |
| 106 | + |
| 107 | +static struct platform_driver qi_lb60_driver = { |
| 108 | + .driver = { |
| 109 | + .name = "qi-lb60-audio", |
| 110 | + .owner = THIS_MODULE, |
| 111 | + }, |
| 112 | + .probe = qi_lb60_probe, |
| 113 | + .remove = __devexit_p(qi_lb60_remove), |
| 114 | +}; |
| 115 | + |
| 116 | +module_platform_driver(qi_lb60_driver); |
| 117 | |
| 118 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); |
| 119 | MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support"); |
| 120 | MODULE_LICENSE("GPL v2"); |
| 121 | +MODULE_ALIAS("platform:qi-lb60-audio"); |
| 122 | |