Skip to content

Commit 0840116

Browse files
Eric Millbrandtbroonie
authored andcommitted
ASoC: fsl: pcm030-audio-fabric use snd_soc_register_card
Convert pcm030-audio-fabric to use the new snd_soc_register_card api instead of the older method of registering a separate platform device. Create the dai_link to the mpc5200_psc_ac97 platform using the device tree. Convert the pcm030-audio-fabric driver to a platform-driver and add a remove function. Signed-off-by: Eric Millbrandt <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent f99ddef commit 0840116

File tree

1 file changed

+47
-18
lines changed

1 file changed

+47
-18
lines changed

sound/soc/fsl/pcm030-audio-fabric.c

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,52 +28,81 @@ static struct snd_soc_dai_link pcm030_fabric_dai[] = {
2828
.stream_name = "AC97 Analog",
2929
.codec_dai_name = "wm9712-hifi",
3030
.cpu_dai_name = "mpc5200-psc-ac97.0",
31-
.platform_name = "mpc5200-pcm-audio",
3231
.codec_name = "wm9712-codec",
3332
},
3433
{
3534
.name = "AC97",
3635
.stream_name = "AC97 IEC958",
3736
.codec_dai_name = "wm9712-aux",
3837
.cpu_dai_name = "mpc5200-psc-ac97.1",
39-
.platform_name = "mpc5200-pcm-audio",
4038
.codec_name = "wm9712-codec",
4139
},
4240
};
4341

44-
static struct snd_soc_card card = {
42+
static struct snd_soc_card pcm030_card = {
4543
.name = "pcm030",
4644
.owner = THIS_MODULE,
4745
.dai_link = pcm030_fabric_dai,
4846
.num_links = ARRAY_SIZE(pcm030_fabric_dai),
4947
};
5048

51-
static __init int pcm030_fabric_init(void)
49+
static int __init pcm030_fabric_probe(struct platform_device *op)
5250
{
53-
struct platform_device *pdev;
54-
int rc;
51+
struct device_node *np = op->dev.of_node;
52+
struct device_node *platform_np;
53+
struct snd_soc_card *card = &pcm030_card;
54+
int ret;
55+
int i;
5556

5657
if (!of_machine_is_compatible("phytec,pcm030"))
5758
return -ENODEV;
5859

59-
pdev = platform_device_alloc("soc-audio", 1);
60-
if (!pdev) {
61-
pr_err("pcm030_fabric_init: platform_device_alloc() failed\n");
60+
card->dev = &op->dev;
61+
platform_set_drvdata(op, card);
62+
63+
platform_np = of_parse_phandle(np, "asoc-platform", 0);
64+
if (!platform_np) {
65+
dev_err(&op->dev, "ac97 not registered\n");
6266
return -ENODEV;
6367
}
6468

65-
platform_set_drvdata(pdev, &card);
69+
for (i = 0; i < card->num_links; i++)
70+
card->dai_link[i].platform_of_node = platform_np;
6671

67-
rc = platform_device_add(pdev);
68-
if (rc) {
69-
pr_err("pcm030_fabric_init: platform_device_add() failed\n");
70-
platform_device_put(pdev);
71-
return -ENODEV;
72-
}
73-
return 0;
72+
ret = snd_soc_register_card(card);
73+
if (ret)
74+
dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret);
75+
76+
return ret;
7477
}
7578

76-
module_init(pcm030_fabric_init);
79+
static int __devexit pcm030_fabric_remove(struct platform_device *op)
80+
{
81+
struct snd_soc_card *card = platform_get_drvdata(op);
82+
int ret;
83+
84+
ret = snd_soc_unregister_card(card);
85+
86+
return ret;
87+
}
88+
89+
static struct of_device_id pcm030_audio_match[] = {
90+
{ .compatible = "phytec,pcm030-audio-fabric", },
91+
{}
92+
};
93+
MODULE_DEVICE_TABLE(of, pcm030_audio_match);
94+
95+
static struct platform_driver pcm030_fabric_driver = {
96+
.probe = pcm030_fabric_probe,
97+
.remove = __devexit_p(pcm030_fabric_remove),
98+
.driver = {
99+
.name = DRV_NAME,
100+
.owner = THIS_MODULE,
101+
.of_match_table = pcm030_audio_match,
102+
},
103+
};
104+
105+
module_platform_driver(pcm030_fabric_driver);
77106

78107

79108
MODULE_AUTHOR("Jon Smirl <[email protected]>");

0 commit comments

Comments
 (0)