From patchwork Thu Nov 15 06:27:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 12854 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8F5AF4C177F for ; Thu, 15 Nov 2012 06:33:49 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1D514A18302 for ; Thu, 15 Nov 2012 06:33:49 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so1769917iej.11 for ; Wed, 14 Nov 2012 22:33:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=4+1pJKwLZQN4w/Gam2cTRU6sxoKMO3gpXqCBdopbeC4=; b=CDpsjgmtg+6mNYp+USxGJbR4kKeKVFCuEiAwNIYG0PeN0HA+cQ19EYs1vCztCi0CUn +sOXWJJJ3BYSsQOIsJMCvczBPLfDlo7gIwJB/akMs9lEyiIYNnc4K6AuMu2SERemGKrE ogJDZtvgJmsHoYhck24wlTYhfdLz/S69iw40umpYYwl4pBavcXZD9Tda7Wv+eXiMRhJ1 fcUwojalmDBjenKZSrqIm9csar7RfNDvhdmhz1L69+oxMGLUw871DdApMxXIGcUZzaKK 9hx9BiphyhPvM+b4NNhg5lOLP+rXyD45oSpg3aYEXgYGkEiYDGTu4o76ihVEM12Ju1Ig 9+4A== Received: by 10.50.161.169 with SMTP id xt9mr1593281igb.62.1352961228526; Wed, 14 Nov 2012 22:33:48 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp780036igt; Wed, 14 Nov 2012 22:33:48 -0800 (PST) Received: by 10.68.132.202 with SMTP id ow10mr1539953pbb.139.1352961227797; Wed, 14 Nov 2012 22:33:47 -0800 (PST) Received: from mail-da0-f50.google.com (mail-da0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id k9si21275766pay.120.2012.11.14.22.33.47 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 22:33:47 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-da0-f50.google.com with SMTP id z20so568147dae.37 for ; Wed, 14 Nov 2012 22:33:47 -0800 (PST) Received: by 10.66.85.69 with SMTP id f5mr387272paz.50.1352961227265; Wed, 14 Nov 2012 22:33:47 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id v9sm9224641paz.6.2012.11.14.22.33.44 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 22:33:46 -0800 (PST) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: vinod.koul@intel.com, sachin.kamat@linaro.org, patches@linaro.org, Jassi Brar Subject: [PATCH 1/1] DMA: PL330: Use devm_* functions Date: Thu, 15 Nov 2012 11:57:50 +0530 Message-Id: <1352960870-6023-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQkUmSYnbrOMTeZ0BKq8+kf5U1QQG9myKZ5sUszTOYltwaL6VI1tRw9lagTLvbJb2ROOvWCt devm_* functions are device managed and make the code and error handling a bit simpler. Cc: Jassi Brar Signed-off-by: Sachin Kamat --- drivers/dma/pl330.c | 37 ++++++++++--------------------------- 1 files changed, 10 insertions(+), 27 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 665668b..68aa24c 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2866,7 +2866,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) pdat = adev->dev.platform_data; /* Allocate a new DMAC and its Channels */ - pdmac = kzalloc(sizeof(*pdmac), GFP_KERNEL); + pdmac = devm_kzalloc(&adev->dev, sizeof(*pdmac), GFP_KERNEL); if (!pdmac) { dev_err(&adev->dev, "unable to allocate mem\n"); return -ENOMEM; @@ -2878,13 +2878,9 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) pi->mcbufsz = pdat ? pdat->mcbuf_sz : 0; res = &adev->res; - request_mem_region(res->start, resource_size(res), "dma-pl330"); - - pi->base = ioremap(res->start, resource_size(res)); - if (!pi->base) { - ret = -ENXIO; - goto probe_err1; - } + pi->base = devm_request_and_ioremap(&adev->dev, res); + if (!pi->base) + return -ENXIO; amba_set_drvdata(adev, pdmac); @@ -2892,11 +2888,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ret = request_irq(irq, pl330_irq_handler, 0, dev_name(&adev->dev), pi); if (ret) - goto probe_err2; + return ret; ret = pl330_add(pi); if (ret) - goto probe_err3; + goto probe_err1; INIT_LIST_HEAD(&pdmac->desc_pool); spin_lock_init(&pdmac->pool_lock); @@ -2918,7 +2914,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) if (!pdmac->peripherals) { ret = -ENOMEM; dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n"); - goto probe_err4; + goto probe_err2; } for (i = 0; i < num_chan; i++) { @@ -2962,7 +2958,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ret = dma_async_device_register(pd); if (ret) { dev_err(&adev->dev, "unable to register DMAC\n"); - goto probe_err4; + goto probe_err2; } dev_info(&adev->dev, @@ -2975,15 +2971,10 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) return 0; -probe_err4: - pl330_del(pi); -probe_err3: - free_irq(irq, pi); probe_err2: - iounmap(pi->base); + pl330_del(pi); probe_err1: - release_mem_region(res->start, resource_size(res)); - kfree(pdmac); + free_irq(irq, pi); return ret; } @@ -2993,7 +2984,6 @@ static int __devexit pl330_remove(struct amba_device *adev) struct dma_pl330_dmac *pdmac = amba_get_drvdata(adev); struct dma_pl330_chan *pch, *_p; struct pl330_info *pi; - struct resource *res; int irq; if (!pdmac) @@ -3020,13 +3010,6 @@ static int __devexit pl330_remove(struct amba_device *adev) irq = adev->irq[0]; free_irq(irq, pi); - iounmap(pi->base); - - res = &adev->res; - release_mem_region(res->start, resource_size(res)); - - kfree(pdmac); - return 0; }