aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/dwc
diff options
context:
space:
mode:
authorAndrew Jackson <Andrew.Jackson@arm.com>2014-12-03 11:38:46 -0500
committerMark Brown <broonie@kernel.org>2014-12-03 13:26:51 -0500
commitb163be4cf4a3bb673038a21e368954f7f88347b7 (patch)
tree32bc5c0d91adfffb760c68352160d6eb58874d12 /sound/soc/dwc
parentf114040e3ea6e07372334ade75d1ee0775c355e1 (diff)
ASoC: dwc: Allocate resources with devm_ioremap_resource
Prepare for the introduction of device-tree support by re-ordering some of the allocations and using devm_iomap_resource to simplify IO mapping. Signed-off-by: Andrew Jackson <Andrew.Jackson@arm.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/dwc')
-rw-r--r--sound/soc/dwc/designware_i2s.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
index e961388e6e9c..08f0229f8d68 100644
--- a/sound/soc/dwc/designware_i2s.c
+++ b/sound/soc/dwc/designware_i2s.c
@@ -338,31 +338,34 @@ static int dw_i2s_probe(struct platform_device *pdev)
338 return -EINVAL; 338 return -EINVAL;
339 } 339 }
340 340
341 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
342 if (!res) {
343 dev_err(&pdev->dev, "no i2s resource defined\n");
344 return -ENODEV;
345 }
346
347 if (!devm_request_mem_region(&pdev->dev, res->start,
348 resource_size(res), pdev->name)) {
349 dev_err(&pdev->dev, "i2s region already claimed\n");
350 return -EBUSY;
351 }
352
353 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); 341 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
354 if (!dev) { 342 if (!dev) {
355 dev_warn(&pdev->dev, "kzalloc fail\n"); 343 dev_warn(&pdev->dev, "kzalloc fail\n");
356 return -ENOMEM; 344 return -ENOMEM;
357 } 345 }
358 346
359 dev->i2s_base = devm_ioremap(&pdev->dev, res->start, 347 dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL);
360 resource_size(res)); 348 if (!dw_i2s_dai) {
361 if (!dev->i2s_base) { 349 dev_err(&pdev->dev, "mem allocation failed for dai driver\n");
362 dev_err(&pdev->dev, "ioremap fail for i2s_region\n");
363 return -ENOMEM; 350 return -ENOMEM;
364 } 351 }
365 352
353 dw_i2s_dai->ops = &dw_i2s_dai_ops;
354 dw_i2s_dai->suspend = dw_i2s_suspend;
355 dw_i2s_dai->resume = dw_i2s_resume;
356
357 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
358 if (!res) {
359 dev_err(&pdev->dev, "no i2s resource defined\n");
360 return -ENODEV;
361 }
362
363 dev->i2s_base = devm_ioremap_resource(&pdev->dev, res);
364 if (IS_ERR(dev->i2s_base)) {
365 dev_err(&pdev->dev, "ioremap fail for i2s_region\n");
366 return PTR_ERR(dev->i2s_base);
367 }
368
366 cap = pdata->cap; 369 cap = pdata->cap;
367 dev->capability = cap; 370 dev->capability = cap;
368 dev->i2s_clk_cfg = pdata->i2s_clk_cfg; 371 dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
@@ -388,13 +391,6 @@ static int dw_i2s_probe(struct platform_device *pdev)
388 if (ret < 0) 391 if (ret < 0)
389 goto err_clk_put; 392 goto err_clk_put;
390 393
391 dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL);
392 if (!dw_i2s_dai) {
393 dev_err(&pdev->dev, "mem allocation failed for dai driver\n");
394 ret = -ENOMEM;
395 goto err_clk_disable;
396 }
397
398 if (cap & DWC_I2S_PLAY) { 394 if (cap & DWC_I2S_PLAY) {
399 dev_dbg(&pdev->dev, " designware: play supported\n"); 395 dev_dbg(&pdev->dev, " designware: play supported\n");
400 dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM; 396 dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM;
@@ -411,10 +407,6 @@ static int dw_i2s_probe(struct platform_device *pdev)
411 dw_i2s_dai->capture.rates = pdata->snd_rates; 407 dw_i2s_dai->capture.rates = pdata->snd_rates;
412 } 408 }
413 409
414 dw_i2s_dai->ops = &dw_i2s_dai_ops;
415 dw_i2s_dai->suspend = dw_i2s_suspend;
416 dw_i2s_dai->resume = dw_i2s_resume;
417
418 dev->dev = &pdev->dev; 410 dev->dev = &pdev->dev;
419 dev_set_drvdata(&pdev->dev, dev); 411 dev_set_drvdata(&pdev->dev, dev);
420 ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component, 412 ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component,