summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorNicolin Chen <b42378@freescale.com>2013-09-05 19:53:40 +0800
committerJason Liu <r64343@freescale.com>2013-10-30 09:55:29 +0800
commit27aa2c474f580dd2a3a216738eeed911a57f9af1 (patch)
treede44aa26ef37c5241caff0d61e78277c1ad63dc8 /sound
parent9d655a4630a77f6a816fdc884a1f389101b740c1 (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>
Diffstat (limited to 'sound')
-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)
return ret;
}
- hdmi_data->dma_dev = platform_device_register_simple("imx-hdmi-audio", -1, NULL, 0);
- if (IS_ERR(hdmi_data->dma_dev)) {
+ hdmi_data->codec_dev = platform_device_register_simple(
+ "hdmi-audio-codec", -1, NULL, 0);
+ if (IS_ERR(hdmi_data->codec_dev)) {
dev_err(&pdev->dev, "failed to register HDMI audio codec\n");
- ret = PTR_ERR(hdmi_data->dma_dev);
+ ret = PTR_ERR(hdmi_data->codec_dev);
goto fail;
}
+ hdmi_data->dma_dev = platform_device_alloc("imx-hdmi-audio", -1);
+ if (IS_ERR(hdmi_data->dma_dev)) {
+ ret = PTR_ERR(hdmi_data->dma_dev);
+ goto fail_dma;
+ }
+
platform_set_drvdata(hdmi_data->dma_dev, hdmi_data);
+ ret = platform_device_add(hdmi_data->dma_dev);
+ if (ret) {
+ platform_device_put(hdmi_data->dma_dev);
+ goto fail_dma;
+ }
+
return 0;
+fail_dma:
+ platform_device_unregister(hdmi_data->codec_dev);
fail:
snd_soc_unregister_component(&pdev->dev);
@@ -566,6 +581,7 @@ static int fsl_hdmi_dai_remove(struct platform_device *pdev)
struct imx_hdmi *hdmi_data = platform_get_drvdata(pdev);
platform_device_unregister(hdmi_data->dma_dev);
+ platform_device_unregister(hdmi_data->codec_dev);
snd_soc_unregister_component(&pdev->dev);
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 = {
.num_links = 1,
};
-static struct platform_device *codec_dev;
-
static int imx_hdmi_audio_probe(struct platform_device *pdev)
{
struct device_node *hdmi_np, *np = pdev->dev.of_node;
@@ -65,26 +63,13 @@ static int imx_hdmi_audio_probe(struct platform_device *pdev)
goto end;
}
- codec_dev = platform_device_register_simple("hdmi-audio-codec", -1, NULL, 0);
- if (IS_ERR(codec_dev)) {
- dev_err(&pdev->dev, "failed to register HDMI audio codec\n");
- ret = PTR_ERR(codec_dev);
- goto end;
- }
-
card->dev = &pdev->dev;
card->dai_link->cpu_dai_name = dev_name(&hdmi_pdev->dev);
ret = snd_soc_register_card(card);
- if (ret) {
+ if (ret)
dev_err(&pdev->dev, "failed to register card: %d\n", ret);
- goto err_card;
- }
-
- goto end;
-err_card:
- platform_device_unregister(codec_dev);
end:
if (hdmi_np)
of_node_put(hdmi_np);
@@ -96,7 +81,6 @@ static int imx_hdmi_audio_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = &snd_soc_card_imx_hdmi;
- platform_device_unregister(codec_dev);
snd_soc_unregister_card(card);
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 {
struct imx_hdmi {
struct snd_soc_dai_driver cpu_dai_drv;
+ struct platform_device *codec_dev;
struct platform_device *dma_dev;
struct platform_device *pdev;
struct clk *isfr_clk;