@@ -127,8 +127,7 @@ int __init platform_resource_setup_memory(struct platform_device *pdev,
char *name, unsigned long memsize)
{
struct resource *r;
- dma_addr_t dma_handle;
- void *buf;
+ int ret;
r = pdev->resource + pdev->num_resources - 1;
if (r->flags) {
@@ -141,17 +140,17 @@ int __init platform_resource_setup_memory(struct platform_device *pdev,
if (!memsize)
return 0;
- buf = dma_alloc_coherent(NULL, memsize, &dma_handle, GFP_KERNEL);
- if (!buf) {
- pr_warning("%s: unable to allocate memory\n", name);
- return -ENOMEM;
+ ret = dma_preallocate_coherent_memory(&pdev->dev, memsize, GFP_KERNEL,
+ DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
+ if (ret < 0) {
+ pr_warning("%s: unable to allocate memory: %d\n", name, ret);
+ return ret;
}
- memset(buf, 0, memsize);
-
r->flags = IORESOURCE_MEM;
- r->start = dma_handle;
- r->end = r->start + memsize - 1;
+ /* Only the size is needed */
+ r->start = 0;
+ r->end = memsize - 1;
r->name = name;
return 0;
}
@@ -1951,20 +1951,8 @@ static int __devinit sh_mobile_ceu_probe(struct platform_device *pdev)
pcdev->video_limit = 0; /* only enabled if second resource exists */
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (res) {
- err = dma_declare_coherent_memory(&pdev->dev, res->start,
- res->start,
- resource_size(res),
- DMA_MEMORY_MAP |
- DMA_MEMORY_EXCLUSIVE);
- if (!err) {
- dev_err(&pdev->dev, "Unable to declare CEU memory.\n");
- err = -ENXIO;
- goto exit_iounmap;
- }
-
+ if (res)
pcdev->video_limit = resource_size(res);
- }
/* request irq */
err = request_irq(pcdev->irq, sh_mobile_ceu_irq, IRQF_DISABLED,
@@ -2036,9 +2024,6 @@ exit_free_clk:
pm_runtime_disable(&pdev->dev);
free_irq(pcdev->irq, pcdev);
exit_release_mem:
- if (platform_get_resource(pdev, IORESOURCE_MEM, 1))
- dma_release_declared_memory(&pdev->dev);
-exit_iounmap:
iounmap(base);
exit_kfree:
kfree(pcdev);
@@ -2056,8 +2041,6 @@ static int __devexit sh_mobile_ceu_remove(struct platform_device *pdev)
soc_camera_host_unregister(soc_host);
pm_runtime_disable(&pdev->dev);
free_irq(pcdev->irq, pcdev);
- if (platform_get_resource(pdev, IORESOURCE_MEM, 1))
- dma_release_declared_memory(&pdev->dev);
iounmap(pcdev->base);
if (csi2 && csi2->driver)
module_put(csi2->driver->owner);