aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorXiubo Li <Li.Xiubo@freescale.com>2014-01-13 23:35:32 -0500
committerMark Brown <broonie@linaro.org>2014-01-14 16:25:48 -0500
commitca919fe4b972b9428ab42bead11b04a4ebf0f632 (patch)
treec0b6c1b2bc65282ee0e7ab2794f2c656ec928fe2 /sound
parentba194a4de5c81ee200b6af88743b26f7b69aa659 (diff)
ASoC: simple-card: fix one bug to writing to the platform data
It's a bug that writing to the platform data directly, for it should be constant. So just copy it before writing. Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/generic/simple-card.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 5528dd6a4e4e..53395f54849a 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -9,9 +9,10 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11#include <linux/clk.h> 11#include <linux/clk.h>
12#include <linux/module.h>
12#include <linux/of.h> 13#include <linux/of.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
14#include <linux/module.h> 15#include <linux/string.h>
15#include <sound/simple_card.h> 16#include <sound/simple_card.h>
16 17
17static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, 18static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
@@ -190,36 +191,37 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
190 struct device_node *np = pdev->dev.of_node; 191 struct device_node *np = pdev->dev.of_node;
191 struct device_node *of_cpu, *of_codec, *of_platform; 192 struct device_node *of_cpu, *of_codec, *of_platform;
192 struct device *dev = &pdev->dev; 193 struct device *dev = &pdev->dev;
194 int ret;
193 195
194 cinfo = NULL; 196 cinfo = NULL;
195 of_cpu = NULL; 197 of_cpu = NULL;
196 of_codec = NULL; 198 of_codec = NULL;
197 of_platform = NULL; 199 of_platform = NULL;
200
201 cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
202 if (!cinfo)
203 return -ENOMEM;
204
198 if (np && of_device_is_available(np)) { 205 if (np && of_device_is_available(np)) {
199 cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL); 206 cinfo->snd_card.dev = dev;
200 if (cinfo) { 207
201 int ret; 208 ret = asoc_simple_card_parse_of(np, cinfo, dev,
202 cinfo->snd_card.dev = &pdev->dev; 209 &of_cpu,
203 ret = asoc_simple_card_parse_of(np, cinfo, dev, 210 &of_codec,
204 &of_cpu, 211 &of_platform);
205 &of_codec, 212 if (ret < 0) {
206 &of_platform); 213 if (ret != -EPROBE_DEFER)
207 if (ret < 0) { 214 dev_err(dev, "parse error %d\n", ret);
208 if (ret != -EPROBE_DEFER) 215 return ret;
209 dev_err(dev, "parse error %d\n", ret);
210 return ret;
211 }
212 } else {
213 return -ENOMEM;
214 } 216 }
215 } else { 217 } else {
216 cinfo = pdev->dev.platform_data; 218 if (!dev->platform_data) {
217 if (!cinfo) {
218 dev_err(dev, "no info for asoc-simple-card\n"); 219 dev_err(dev, "no info for asoc-simple-card\n");
219 return -EINVAL; 220 return -EINVAL;
220 } 221 }
221 222
222 cinfo->snd_card.dev = &pdev->dev; 223 memcpy(cinfo, dev->platform_data, sizeof(*cinfo));
224 cinfo->snd_card.dev = dev;
223 } 225 }
224 226
225 if (!cinfo->name || 227 if (!cinfo->name ||