From patchwork Thu Apr 10 12:20:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 28166 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A861720671 for ; Thu, 10 Apr 2014 12:21:17 +0000 (UTC) Received: by mail-yk0-f197.google.com with SMTP id 19sf7599918ykq.4 for ; Thu, 10 Apr 2014 05:21:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=D6/Ypg1xXWyw7MlolxUMVjYKgHFmVS4ngLH9SCXC2J4=; b=WuECbRQFyr6Q+GzWWSjMO75Dr1T+JWeRWkwHTpy0OgUhuMow5iYTFmSWdyWmgGgiwX ko/3SX8T+5gQPQNIYgxmYag+zEARBmw9lJJwTdqMFBBIQulNkiKeTwWvyle0WEU8Nivm agyBe3vghoEof8RJeRTLRtyF7muJWN+wgCEHpRRMZjC0Z25w57J2KbOmmsOK+t19I1cS 2YwyY2EmRR2zh14G4P1Wena9YBtOxHVb5xRTfwQEBI7TVYVo1GeWn9eERV5g5GlG1Akp 2PxzZDPPWoSc3ydv4JVbQCB4MRh77R2aPhOtX5GPFVmp2RyMafd1DdchDQzjX9dXLfZ4 WjbQ== X-Gm-Message-State: ALoCoQmF4HaOC74jxI8SkOEPZ3jBvTCv6y1q/mGJFxKruwuT+BGSVtSgEpxELWyncA80dJIpJRBe X-Received: by 10.236.48.103 with SMTP id u67mr6954054yhb.38.1397132477409; Thu, 10 Apr 2014 05:21:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.201 with SMTP id f67ls1062345qgd.91.gmail; Thu, 10 Apr 2014 05:21:17 -0700 (PDT) X-Received: by 10.221.34.7 with SMTP id sq7mr14281865vcb.5.1397132477255; Thu, 10 Apr 2014 05:21:17 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id tv3si660189vdc.36.2014.04.10.05.21.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 05:21:17 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so3253685veb.26 for ; Thu, 10 Apr 2014 05:21:17 -0700 (PDT) X-Received: by 10.220.250.203 with SMTP id mp11mr14191384vcb.2.1397132477132; Thu, 10 Apr 2014 05:21:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp54547vcb; Thu, 10 Apr 2014 05:21:16 -0700 (PDT) X-Received: by 10.180.84.129 with SMTP id z1mr1297034wiy.8.1397132476053; Thu, 10 Apr 2014 05:21:16 -0700 (PDT) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id vo1si1465181wjc.237.2014.04.10.05.21.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 05:21:16 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=74.125.82.178; Received: by mail-we0-f178.google.com with SMTP id u56so3796136wes.23 for ; Thu, 10 Apr 2014 05:21:15 -0700 (PDT) X-Received: by 10.180.83.196 with SMTP id s4mr42651880wiy.24.1397132475454; Thu, 10 Apr 2014 05:21:15 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id ej7sm16437292wib.9.2014.04.10.05.21.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 05:21:14 -0700 (PDT) From: Ulf Hansson To: linux-arm-kernel@lists.infradead.org, Russell King , Linus Walleij Cc: devicetree@vger.kernel.org, Rob Herring , Ulf Hansson Subject: [PATCH V3 02/19] mmc: mmci: Convert to devm functions Date: Thu, 10 Apr 2014 14:20:45 +0200 Message-Id: <1397132462-8005-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397132462-8005-1-git-send-email-ulf.hansson@linaro.org> References: <1397132462-8005-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Converting to devm functions to simplify error handling in ->probe() and to cleanup ->remove(). Signed-off-by: Ulf Hansson --- Changes in v3: Convert to use devm_ioremap_resource(), suggested by Michal Simek. --- drivers/mmc/host/mmci.c | 52 ++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index b0b81ac..93b1b10 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -1456,15 +1457,9 @@ static int mmci_probe(struct amba_device *dev, if (np) mmci_dt_populate_generic_pdata(np, plat); - ret = amba_request_regions(dev, DRIVER_NAME); - if (ret) - goto out; - mmc = mmc_alloc_host(sizeof(struct mmci_host), &dev->dev); - if (!mmc) { - ret = -ENOMEM; - goto rel_regions; - } + if (!mmc) + return -ENOMEM; host = mmc_priv(mmc); host->mmc = mmc; @@ -1500,10 +1495,11 @@ static int mmci_probe(struct amba_device *dev, dev_dbg(mmc_dev(mmc), "eventual mclk rate: %u Hz\n", host->mclk); } + host->phybase = dev->res.start; - host->base = ioremap(dev->res.start, resource_size(&dev->res)); - if (!host->base) { - ret = -ENOMEM; + host->base = devm_ioremap_resource(&dev->dev, &dev->res); + if (IS_ERR(host->base)) { + ret = PTR_ERR(host->base); goto clk_disable; } @@ -1592,34 +1588,35 @@ static int mmci_probe(struct amba_device *dev, if (plat->gpio_cd == -EPROBE_DEFER) { ret = -EPROBE_DEFER; - goto err_gpio_cd; + goto clk_disable; } if (gpio_is_valid(plat->gpio_cd)) { ret = mmc_gpio_request_cd(mmc, plat->gpio_cd, 0); if (ret) - goto err_gpio_cd; + goto clk_disable; } if (plat->gpio_wp == -EPROBE_DEFER) { ret = -EPROBE_DEFER; - goto err_gpio_cd; + goto clk_disable; } if (gpio_is_valid(plat->gpio_wp)) { ret = mmc_gpio_request_ro(mmc, plat->gpio_wp); if (ret) - goto err_gpio_cd; + goto clk_disable; } - ret = request_irq(dev->irq[0], mmci_irq, IRQF_SHARED, DRIVER_NAME " (cmd)", host); + ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED, + DRIVER_NAME " (cmd)", host); if (ret) - goto err_gpio_cd; + goto clk_disable; if (!dev->irq[1]) host->singleirq = true; else { - ret = request_irq(dev->irq[1], mmci_pio_irq, IRQF_SHARED, - DRIVER_NAME " (pio)", host); + ret = devm_request_irq(&dev->dev, dev->irq[1], mmci_pio_irq, + IRQF_SHARED, DRIVER_NAME " (pio)", host); if (ret) - goto irq0_free; + goto clk_disable; } writel(MCI_IRQENABLE, host->base + MMCIMASK0); @@ -1641,17 +1638,10 @@ static int mmci_probe(struct amba_device *dev, return 0; - irq0_free: - free_irq(dev->irq[0], host); - err_gpio_cd: - iounmap(host->base); clk_disable: clk_disable_unprepare(host->clk); host_free: mmc_free_host(mmc); - rel_regions: - amba_release_regions(dev); - out: return ret; } @@ -1677,16 +1667,8 @@ static int mmci_remove(struct amba_device *dev) writel(0, host->base + MMCIDATACTRL); mmci_dma_release(host); - free_irq(dev->irq[0], host); - if (!host->singleirq) - free_irq(dev->irq[1], host); - - iounmap(host->base); clk_disable_unprepare(host->clk); - mmc_free_host(mmc); - - amba_release_regions(dev); } return 0;