From patchwork Fri Mar 21 12:13:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 26807 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7DE5E203AB for ; Fri, 21 Mar 2014 12:14:46 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id if11sf5340813vcb.0 for ; Fri, 21 Mar 2014 05:14:46 -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=RH6S3/4hKuvFs1qkET3MZmeNEVhSD4hP1GXHmp/XaE0=; b=P1SdytxY3yVb7S06vPjSe+yekfMFgy7D1rPxvz1q+xqCi+iW/5PJjSWURc47D378x+ MHSZgZlJMuXj7TmhpG2KCK/zzeZf8nFoyKZJQyInGYq7fnVg/s32HFsX2Vq4LsKu9KT2 LSZImZVOvRR/g6zrK8GPedd2pLDZaqjJ/IIQxuHlfyMOapv0zniBKeetkgOfze/kB8/2 jQ8B12HqcS4SZDQEe7wj/Wh0pI+HCoocdoALhu++1hpj+P7rFEpe46UTB0sBCHQ5jeRp LT7li0mjcZg8dhzzXhhhoINGphr3jXSlYv1mcHHcMKB0gGnr8Wkx7p+32GfzgouHaUxJ D+5Q== X-Gm-Message-State: ALoCoQlQ+VVYbKDBftRH/tubxGMjpwwm2eBRHockF96YR5eqkjM0tpqhFowDfC2AVReso9WlG4oK X-Received: by 10.58.40.97 with SMTP id w1mr10429477vek.13.1395404086228; Fri, 21 Mar 2014 05:14:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.77 with SMTP id x71ls174834qge.31.gmail; Fri, 21 Mar 2014 05:14:46 -0700 (PDT) X-Received: by 10.52.123.97 with SMTP id lz1mr18824vdb.73.1395404086077; Fri, 21 Mar 2014 05:14:46 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id rq10si1071534vcb.132.2014.03.21.05.14.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Mar 2014 05:14:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id cz12so2432629veb.16 for ; Fri, 21 Mar 2014 05:14:46 -0700 (PDT) X-Received: by 10.58.31.136 with SMTP id a8mr24114168vei.20.1395404086005; Fri, 21 Mar 2014 05:14:46 -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.78.9 with SMTP id i9csp25956vck; Fri, 21 Mar 2014 05:14:45 -0700 (PDT) X-Received: by 10.112.171.67 with SMTP id as3mr31972441lbc.10.1395404084662; Fri, 21 Mar 2014 05:14:44 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx.google.com with ESMTPS id zv8si3901200lbb.104.2014.03.21.05.14.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Mar 2014 05:14:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.54 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id mc6so1565213lab.41 for ; Fri, 21 Mar 2014 05:14:44 -0700 (PDT) X-Received: by 10.152.246.43 with SMTP id xt11mr1753723lac.34.1395404083959; Fri, 21 Mar 2014 05:14:43 -0700 (PDT) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id tq9sm3255263lbb.10.2014.03.21.05.14.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Mar 2014 05:14:43 -0700 (PDT) From: Ulf Hansson To: linux-arm-kernel@lists.infradead.org, Russell King , Linus Walleij Cc: devicetree@vger.kernel.org, Ulf Hansson Subject: [PATCH 02/20] mmc: mmci: Convert to devm functions Date: Fri, 21 Mar 2014 13:13:59 +0100 Message-Id: <1395404057-27835-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1395404057-27835-1-git-send-email-ulf.hansson@linaro.org> References: <1395404057-27835-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.171 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 --- drivers/mmc/host/mmci.c | 51 ++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index b0b81ac..d6f20ba 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,13 @@ 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; + if (!devm_request_mem_region(&dev->dev, dev->res.start, + resource_size(&dev->res), DRIVER_NAME)) + return -ENOMEM; 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,8 +1499,10 @@ 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)); + host->base = devm_ioremap(&dev->dev, host->phybase, + resource_size(&dev->res)); if (!host->base) { ret = -ENOMEM; goto clk_disable; @@ -1592,34 +1593,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 +1643,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 +1672,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;