From patchwork Thu Aug 19 14:40:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 120367 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7JEehjl030356 for ; Thu, 19 Aug 2010 14:40:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753487Ab0HSOkV (ORCPT ); Thu, 19 Aug 2010 10:40:21 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:41871 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with SMTP id S1753812Ab0HSOkT (ORCPT ); Thu, 19 Aug 2010 10:40:19 -0400 Received: (qmail invoked by alias); 19 Aug 2010 14:40:17 -0000 Received: from p508982A3.dip0.t-ipconnect.de (EHLO axis700.grange) [80.137.130.163] by mail.gmx.net (mp059) with SMTP; 19 Aug 2010 16:40:17 +0200 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX1+ETg8GJIeEzsB4QVOMj4jzzyorOkxpEmDZcKSKQV Dl3tZaqvIE8m1y Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1Om6IA-0007dH-IF; Thu, 19 Aug 2010 16:40:30 +0200 Date: Thu, 19 Aug 2010 16:40:30 +0200 (CEST) From: Guennadi Liakhovetski To: Russell King - ARM Linux cc: linux-sh@vger.kernel.org, Marin Mitov , =?ISO-8859-15?Q?Uwe_Kleine-K=F6nig?= , =?ISO-8859-15?Q?Philippe_R=E9tornaz?= , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, Janusz Krzysztofik Subject: [PATCH 5/5] SH: use dma_preallocate_coherent_memory() for platform device memory In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 19 Aug 2010 14:40:44 +0000 (UTC) diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c index c86a085..c617b99 100644 --- a/arch/sh/mm/consistent.c +++ b/arch/sh/mm/consistent.c @@ -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; } diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index bfddad8..325671e 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c @@ -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);