diff options
author | Richard Zhao <richard.zhao@freescale.com> | 2012-04-27 03:02:56 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-27 13:44:06 -0400 |
commit | 717071dc273bb0acff3b95d39764d4f20adc6e1d (patch) | |
tree | c4fa9311aea0d3e59a187a9a500300ddf05fd231 /sound/soc/fsl | |
parent | 04de57c15354252ac816154ad66666240883fc52 (diff) |
ASoC: imx-sgtl5000: add of_node_put when probe fail.
Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r-- | sound/soc/fsl/imx-sgtl5000.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c index e1a7441ec133..73b935e25f9b 100644 --- a/sound/soc/fsl/imx-sgtl5000.c +++ b/sound/soc/fsl/imx-sgtl5000.c | |||
@@ -103,24 +103,28 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev) | |||
103 | codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0); | 103 | codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0); |
104 | if (!ssi_np || !codec_np) { | 104 | if (!ssi_np || !codec_np) { |
105 | dev_err(&pdev->dev, "phandle missing or invalid\n"); | 105 | dev_err(&pdev->dev, "phandle missing or invalid\n"); |
106 | return -EINVAL; | 106 | ret = -EINVAL; |
107 | goto fail; | ||
107 | } | 108 | } |
108 | 109 | ||
109 | ssi_pdev = of_find_device_by_node(ssi_np); | 110 | ssi_pdev = of_find_device_by_node(ssi_np); |
110 | if (!ssi_pdev) { | 111 | if (!ssi_pdev) { |
111 | dev_err(&pdev->dev, "failed to find SSI platform device\n"); | 112 | dev_err(&pdev->dev, "failed to find SSI platform device\n"); |
112 | return -EINVAL; | 113 | ret = -EINVAL; |
114 | goto fail; | ||
113 | } | 115 | } |
114 | 116 | ||
115 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | 117 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); |
116 | if (!data) | 118 | if (!data) { |
117 | return -ENOMEM; | 119 | ret = -ENOMEM; |
120 | goto fail; | ||
121 | } | ||
118 | 122 | ||
119 | ret = of_property_read_u32(codec_np, "clock-frequency", | 123 | ret = of_property_read_u32(codec_np, "clock-frequency", |
120 | &data->clk_frequency); | 124 | &data->clk_frequency); |
121 | if (ret) { | 125 | if (ret) { |
122 | dev_err(&pdev->dev, "clock-frequency missing or invalid\n"); | 126 | dev_err(&pdev->dev, "clock-frequency missing or invalid\n"); |
123 | return ret; | 127 | goto fail; |
124 | } | 128 | } |
125 | 129 | ||
126 | data->dai.name = "HiFi"; | 130 | data->dai.name = "HiFi"; |
@@ -136,10 +140,10 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev) | |||
136 | data->card.dev = &pdev->dev; | 140 | data->card.dev = &pdev->dev; |
137 | ret = snd_soc_of_parse_card_name(&data->card, "model"); | 141 | ret = snd_soc_of_parse_card_name(&data->card, "model"); |
138 | if (ret) | 142 | if (ret) |
139 | return ret; | 143 | goto fail; |
140 | ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); | 144 | ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); |
141 | if (ret) | 145 | if (ret) |
142 | return ret; | 146 | goto fail; |
143 | data->card.num_links = 1; | 147 | data->card.num_links = 1; |
144 | data->card.dai_link = &data->dai; | 148 | data->card.dai_link = &data->dai; |
145 | data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; | 149 | data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; |
@@ -148,14 +152,17 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev) | |||
148 | ret = snd_soc_register_card(&data->card); | 152 | ret = snd_soc_register_card(&data->card); |
149 | if (ret) { | 153 | if (ret) { |
150 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); | 154 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); |
151 | return ret; | 155 | goto fail; |
152 | } | 156 | } |
153 | 157 | ||
154 | platform_set_drvdata(pdev, data); | 158 | platform_set_drvdata(pdev, data); |
155 | of_node_put(ssi_np); | 159 | fail: |
156 | of_node_put(codec_np); | 160 | if (ssi_np) |
161 | of_node_put(ssi_np); | ||
162 | if (codec_np) | ||
163 | of_node_put(codec_np); | ||
157 | 164 | ||
158 | return 0; | 165 | return ret; |
159 | } | 166 | } |
160 | 167 | ||
161 | static int __devexit imx_sgtl5000_remove(struct platform_device *pdev) | 168 | static int __devexit imx_sgtl5000_remove(struct platform_device *pdev) |