ASoC: omap: rx51: Use devm_snd_soc_register_card

This patch converts the rx51 ASoC module to use
devm_snd_soc_register_card.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
Sebastian Reichel 2014-04-28 16:07:21 +02:00 committed by Mark Brown
parent beab3da155
commit a7d5202855

View file

@ -363,10 +363,9 @@ static struct snd_soc_card rx51_sound_card = {
.num_dapm_routes = ARRAY_SIZE(audio_map), .num_dapm_routes = ARRAY_SIZE(audio_map),
}; };
static struct platform_device *rx51_snd_device; static int rx51_soc_probe(struct platform_device *pdev)
static int __init rx51_soc_init(void)
{ {
struct snd_soc_card *card = &rx51_sound_card;
int err; int err;
if (!machine_is_nokia_rx51() && !of_machine_is_compatible("nokia,omap3-n900")) if (!machine_is_nokia_rx51() && !of_machine_is_compatible("nokia,omap3-n900"))
@ -381,22 +380,16 @@ static int __init rx51_soc_init(void)
if (err) if (err)
goto err_gpio_eci_sw; goto err_gpio_eci_sw;
rx51_snd_device = platform_device_alloc("soc-audio", -1); card->dev = &pdev->dev;
if (!rx51_snd_device) {
err = -ENOMEM; err = devm_snd_soc_register_card(card->dev, card);
goto err1; if (err) {
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", err);
goto err_snd;
} }
platform_set_drvdata(rx51_snd_device, &rx51_sound_card);
err = platform_device_add(rx51_snd_device);
if (err)
goto err2;
return 0; return 0;
err2: err_snd:
platform_device_put(rx51_snd_device);
err1:
gpio_free(RX51_ECI_SW_GPIO); gpio_free(RX51_ECI_SW_GPIO);
err_gpio_eci_sw: err_gpio_eci_sw:
gpio_free(RX51_TVOUT_SEL_GPIO); gpio_free(RX51_TVOUT_SEL_GPIO);
@ -405,18 +398,27 @@ err_gpio_tvout_sel:
return err; return err;
} }
static void __exit rx51_soc_exit(void) static int rx51_soc_remove(struct platform_device *pdev)
{ {
snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios), snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios),
rx51_av_jack_gpios); rx51_av_jack_gpios);
platform_device_unregister(rx51_snd_device);
gpio_free(RX51_ECI_SW_GPIO); gpio_free(RX51_ECI_SW_GPIO);
gpio_free(RX51_TVOUT_SEL_GPIO); gpio_free(RX51_TVOUT_SEL_GPIO);
return 0;
} }
module_init(rx51_soc_init); static struct platform_driver rx51_soc_driver = {
module_exit(rx51_soc_exit); .driver = {
.name = "rx51-audio",
.owner = THIS_MODULE,
},
.probe = rx51_soc_probe,
.remove = rx51_soc_remove,
};
module_platform_driver(rx51_soc_driver);
MODULE_AUTHOR("Nokia Corporation"); MODULE_AUTHOR("Nokia Corporation");
MODULE_DESCRIPTION("ALSA SoC Nokia RX-51"); MODULE_DESCRIPTION("ALSA SoC Nokia RX-51");