Skip to content

Commit

Permalink
ASoC: pxa: Convert e800_wm9712 to use snd_soc_register_card()
Browse files Browse the repository at this point in the history
Use snd_soc_register_card() instead of creating a "soc-audio" platform device.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Dec 17, 2011
1 parent f285b8c commit 1eb0202
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
6 changes: 6 additions & 0 deletions arch/arm/mach-pxa/eseries.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,12 +936,18 @@ static struct platform_device e800_tc6393xb_device = {
.resource = eseries_tmio_resources,
};

static struct platform_device e800_audio_device = {
.name = "e800-audio",
.id = -1,
};

/* ----------------------------------------------------------------------- */

static struct platform_device *e800_devices[] __initdata = {
&e800_fb_device,
&e800_tc6393xb_device,
&e800_gpio_vbus,
&e800_audio_device,
};

static void __init e800_init(void)
Expand Down
66 changes: 31 additions & 35 deletions sound/soc/pxa/e800_wm9712.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,58 +110,54 @@ static struct snd_soc_card e800 = {
.num_links = ARRAY_SIZE(e800_dai),
};

static struct platform_device *e800_snd_device;
static struct gpio e800_audio_gpios[] = {
{ GPIO_E800_SPK_AMP_ON, GPIOF_OUT_INIT_HIGH, "Headphone amp" },
{ GPIO_E800_HP_AMP_OFF, GPIOF_OUT_INIT_HIGH, "Speaker amp" },
};

static int __init e800_init(void)
static int __devinit e800_probe(struct platform_device *pdev)
{
struct snd_soc_card *card = &e800;
int ret;

if (!machine_is_e800())
return -ENODEV;

ret = gpio_request_one(GPIO_E800_HP_AMP_OFF, GPIOF_OUT_INIT_HIGH,
"Headphone amp");
ret = gpio_request_array(e800_audio_gpios,
ARRAY_SIZE(e800_audio_gpios));
if (ret)
return ret;

ret = gpio_request_one(GPIO_E800_SPK_AMP_ON, GPIOF_OUT_INIT_HIGH,
"Speaker amp");
if (ret)
goto free_hp_amp_gpio;
card->dev = &pdev->dev;

e800_snd_device = platform_device_alloc("soc-audio", -1);
if (!e800_snd_device) {
ret = -ENOMEM;
goto free_spk_amp_gpio;
ret = snd_soc_register_card(card);
if (ret) {
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
ret);
gpio_free_array(e800_audio_gpios, ARRAY_SIZE(e800_audio_gpios));
}

platform_set_drvdata(e800_snd_device, &e800);
ret = platform_device_add(e800_snd_device);

if (!ret)
return 0;

/* Fail gracefully */
platform_device_put(e800_snd_device);
free_spk_amp_gpio:
gpio_free(GPIO_E800_SPK_AMP_ON);
free_hp_amp_gpio:
gpio_free(GPIO_E800_HP_AMP_OFF);

return ret;
}

static void __exit e800_exit(void)
static int __devexit e800_remove(struct platform_device *pdev)
{
platform_device_unregister(e800_snd_device);
gpio_free(GPIO_E800_SPK_AMP_ON);
gpio_free(GPIO_E800_HP_AMP_OFF);
struct snd_soc_card *card = platform_get_drvdata(pdev);

gpio_free_array(e800_audio_gpios, ARRAY_SIZE(e800_audio_gpios));
snd_soc_unregister_card(card);
return 0;
}

module_init(e800_init);
module_exit(e800_exit);
static struct platform_driver e800_driver = {
.driver = {
.name = "e800-audio",
.owner = THIS_MODULE,
},
.probe = e800_probe,
.remove = __devexit_p(e800_remove),
};

module_platform_driver(e800_driver);

/* Module information */
MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
MODULE_DESCRIPTION("ALSA SoC driver for e800");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:e800-audio");

0 comments on commit 1eb0202

Please sign in to comment.