提交 717071dc 编写于 作者: R Richard Zhao 提交者: Mark Brown

ASoC: imx-sgtl5000: add of_node_put when probe fail.

Signed-off-by: NRichard Zhao <richard.zhao@freescale.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 04de57c1
...@@ -103,24 +103,28 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev) ...@@ -103,24 +103,28 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev)
codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0); codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0);
if (!ssi_np || !codec_np) { if (!ssi_np || !codec_np) {
dev_err(&pdev->dev, "phandle missing or invalid\n"); dev_err(&pdev->dev, "phandle missing or invalid\n");
return -EINVAL; ret = -EINVAL;
goto fail;
} }
ssi_pdev = of_find_device_by_node(ssi_np); ssi_pdev = of_find_device_by_node(ssi_np);
if (!ssi_pdev) { if (!ssi_pdev) {
dev_err(&pdev->dev, "failed to find SSI platform device\n"); dev_err(&pdev->dev, "failed to find SSI platform device\n");
return -EINVAL; ret = -EINVAL;
goto fail;
} }
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) if (!data) {
return -ENOMEM; ret = -ENOMEM;
goto fail;
}
ret = of_property_read_u32(codec_np, "clock-frequency", ret = of_property_read_u32(codec_np, "clock-frequency",
&data->clk_frequency); &data->clk_frequency);
if (ret) { if (ret) {
dev_err(&pdev->dev, "clock-frequency missing or invalid\n"); dev_err(&pdev->dev, "clock-frequency missing or invalid\n");
return ret; goto fail;
} }
data->dai.name = "HiFi"; data->dai.name = "HiFi";
...@@ -136,10 +140,10 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev) ...@@ -136,10 +140,10 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev)
data->card.dev = &pdev->dev; data->card.dev = &pdev->dev;
ret = snd_soc_of_parse_card_name(&data->card, "model"); ret = snd_soc_of_parse_card_name(&data->card, "model");
if (ret) if (ret)
return ret; goto fail;
ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing");
if (ret) if (ret)
return ret; goto fail;
data->card.num_links = 1; data->card.num_links = 1;
data->card.dai_link = &data->dai; data->card.dai_link = &data->dai;
data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; data->card.dapm_widgets = imx_sgtl5000_dapm_widgets;
...@@ -148,14 +152,17 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev) ...@@ -148,14 +152,17 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev)
ret = snd_soc_register_card(&data->card); ret = snd_soc_register_card(&data->card);
if (ret) { if (ret) {
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
return ret; goto fail;
} }
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
of_node_put(ssi_np); fail:
of_node_put(codec_np); if (ssi_np)
of_node_put(ssi_np);
if (codec_np)
of_node_put(codec_np);
return 0; return ret;
} }
static int __devexit imx_sgtl5000_remove(struct platform_device *pdev) static int __devexit imx_sgtl5000_remove(struct platform_device *pdev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册