aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolin Chen <b42378@freescale.com>2013-09-05 07:53:40 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:05:30 -0400
commit615af81ade2fafd2670b41afa8f82c797ab2ed56 (patch)
tree8ed5a77572537bd1c4a16e829ec8c8b72b5f36fc
parentb1a3c35179c60ce582e8f773f55fafc67c0c5223 (diff)
ENGR00278382 ASoC: fsl: Fix hdmi audio loadable module failure
Use platform_device_add() which can pass drvdata correctly: previously we register the dma_dev first and pass its drvdata, but this would fail to pass its drvdata correctly when using loadable module, because the probe() hdmi dma driver would be executed right after the register() and before set_drvdata(). Then the drvdata actually failed to be set to the hdmi dma driver. While platform_device_add() has no such issue because it would finish the set_drvdata() before its execution. This patch also move codec driver registering into CPU DAI driver. When using autoload module, the codec driver would alwasy fail to be detected due to its registering located in manchine driver. Thus move this to CPU DAI driver. Signed-off-by: Nicolin Chen <b42378@freescale.com>
-rw-r--r--sound/soc/fsl/fsl_hdmi.c22
-rw-r--r--sound/soc/fsl/imx-hdmi.c18
-rw-r--r--sound/soc/fsl/imx-hdmi.h1
3 files changed, 21 insertions, 20 deletions
diff --git a/sound/soc/fsl/fsl_hdmi.c b/sound/soc/fsl/fsl_hdmi.c
index 6d0143e34a0b..fb9e8526b81c 100644
--- a/sound/soc/fsl/fsl_hdmi.c
+++ b/sound/soc/fsl/fsl_hdmi.c
@@ -544,17 +544,32 @@ static int fsl_hdmi_dai_probe(struct platform_device *pdev)
544 return ret; 544 return ret;
545 } 545 }
546 546
547 hdmi_data->dma_dev = platform_device_register_simple("imx-hdmi-audio", -1, NULL, 0); 547 hdmi_data->codec_dev = platform_device_register_simple(
548 if (IS_ERR(hdmi_data->dma_dev)) { 548 "hdmi-audio-codec", -1, NULL, 0);
549 if (IS_ERR(hdmi_data->codec_dev)) {
549 dev_err(&pdev->dev, "failed to register HDMI audio codec\n"); 550 dev_err(&pdev->dev, "failed to register HDMI audio codec\n");
550 ret = PTR_ERR(hdmi_data->dma_dev); 551 ret = PTR_ERR(hdmi_data->codec_dev);
551 goto fail; 552 goto fail;
552 } 553 }
553 554
555 hdmi_data->dma_dev = platform_device_alloc("imx-hdmi-audio", -1);
556 if (IS_ERR(hdmi_data->dma_dev)) {
557 ret = PTR_ERR(hdmi_data->dma_dev);
558 goto fail_dma;
559 }
560
554 platform_set_drvdata(hdmi_data->dma_dev, hdmi_data); 561 platform_set_drvdata(hdmi_data->dma_dev, hdmi_data);
555 562
563 ret = platform_device_add(hdmi_data->dma_dev);
564 if (ret) {
565 platform_device_put(hdmi_data->dma_dev);
566 goto fail_dma;
567 }
568
556 return 0; 569 return 0;
557 570
571fail_dma:
572 platform_device_unregister(hdmi_data->codec_dev);
558fail: 573fail:
559 snd_soc_unregister_component(&pdev->dev); 574 snd_soc_unregister_component(&pdev->dev);
560 575
@@ -566,6 +581,7 @@ static int fsl_hdmi_dai_remove(struct platform_device *pdev)
566 struct imx_hdmi *hdmi_data = platform_get_drvdata(pdev); 581 struct imx_hdmi *hdmi_data = platform_get_drvdata(pdev);
567 582
568 platform_device_unregister(hdmi_data->dma_dev); 583 platform_device_unregister(hdmi_data->dma_dev);
584 platform_device_unregister(hdmi_data->codec_dev);
569 snd_soc_unregister_component(&pdev->dev); 585 snd_soc_unregister_component(&pdev->dev);
570 586
571 return 0; 587 return 0;
diff --git a/sound/soc/fsl/imx-hdmi.c b/sound/soc/fsl/imx-hdmi.c
index 04fcff8cca6e..c6b33b942fe9 100644
--- a/sound/soc/fsl/imx-hdmi.c
+++ b/sound/soc/fsl/imx-hdmi.c
@@ -37,8 +37,6 @@ static struct snd_soc_card snd_soc_card_imx_hdmi = {
37 .num_links = 1, 37 .num_links = 1,
38}; 38};
39 39
40static struct platform_device *codec_dev;
41
42static int imx_hdmi_audio_probe(struct platform_device *pdev) 40static int imx_hdmi_audio_probe(struct platform_device *pdev)
43{ 41{
44 struct device_node *hdmi_np, *np = pdev->dev.of_node; 42 struct device_node *hdmi_np, *np = pdev->dev.of_node;
@@ -65,26 +63,13 @@ static int imx_hdmi_audio_probe(struct platform_device *pdev)
65 goto end; 63 goto end;
66 } 64 }
67 65
68 codec_dev = platform_device_register_simple("hdmi-audio-codec", -1, NULL, 0);
69 if (IS_ERR(codec_dev)) {
70 dev_err(&pdev->dev, "failed to register HDMI audio codec\n");
71 ret = PTR_ERR(codec_dev);
72 goto end;
73 }
74
75 card->dev = &pdev->dev; 66 card->dev = &pdev->dev;
76 card->dai_link->cpu_dai_name = dev_name(&hdmi_pdev->dev); 67 card->dai_link->cpu_dai_name = dev_name(&hdmi_pdev->dev);
77 68
78 ret = snd_soc_register_card(card); 69 ret = snd_soc_register_card(card);
79 if (ret) { 70 if (ret)
80 dev_err(&pdev->dev, "failed to register card: %d\n", ret); 71 dev_err(&pdev->dev, "failed to register card: %d\n", ret);
81 goto err_card;
82 }
83
84 goto end;
85 72
86err_card:
87 platform_device_unregister(codec_dev);
88end: 73end:
89 if (hdmi_np) 74 if (hdmi_np)
90 of_node_put(hdmi_np); 75 of_node_put(hdmi_np);
@@ -96,7 +81,6 @@ static int imx_hdmi_audio_remove(struct platform_device *pdev)
96{ 81{
97 struct snd_soc_card *card = &snd_soc_card_imx_hdmi; 82 struct snd_soc_card *card = &snd_soc_card_imx_hdmi;
98 83
99 platform_device_unregister(codec_dev);
100 snd_soc_unregister_card(card); 84 snd_soc_unregister_card(card);
101 85
102 return 0; 86 return 0;
diff --git a/sound/soc/fsl/imx-hdmi.h b/sound/soc/fsl/imx-hdmi.h
index e3288404cb1a..22b3dc5a6669 100644
--- a/sound/soc/fsl/imx-hdmi.h
+++ b/sound/soc/fsl/imx-hdmi.h
@@ -27,6 +27,7 @@ struct imx_hdmi_sdma_params {
27 27
28struct imx_hdmi { 28struct imx_hdmi {
29 struct snd_soc_dai_driver cpu_dai_drv; 29 struct snd_soc_dai_driver cpu_dai_drv;
30 struct platform_device *codec_dev;
30 struct platform_device *dma_dev; 31 struct platform_device *dma_dev;
31 struct platform_device *pdev; 32 struct platform_device *pdev;
32 struct clk *isfr_clk; 33 struct clk *isfr_clk;