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: 3964131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A52D69F336 for ; Thu, 10 Apr 2014 18:37:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BCBD42081D for ; Thu, 10 Apr 2014 18:37:25 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 87C482082E for ; Thu, 10 Apr 2014 18:37:24 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYJpO-0004wF-Ij; Thu, 10 Apr 2014 18:35:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYJpB-0002Eb-K4; Thu, 10 Apr 2014 18:35:45 +0000 Received: from bombadil.infradead.org ([2001:1868:205::9]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYJjR-0001pF-5O for linux-arm-kernel@merlin.infradead.org; Thu, 10 Apr 2014 18:29:49 +0000 Received: from mail-we0-f170.google.com ([74.125.82.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYHrH-0003vJ-9h for linux-arm-kernel@lists.infradead.org; Thu, 10 Apr 2014 16:29:47 +0000 Received: by mail-we0-f170.google.com with SMTP id w61so4208847wes.29 for ; Thu, 10 Apr 2014 09:29:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D6/Ypg1xXWyw7MlolxUMVjYKgHFmVS4ngLH9SCXC2J4=; b=CBHPnmngrXEuUiGxEZpDuA//LBjoheudLGXhaV4/3OCwP7w1W5NBfOio5mEr+WTDA2 tGZhWjSTgL8AE9hg6tYUhTqY4cXWl/d/P3KXJ0q6BqtB8r2w5/gQdnfnzfHaccLUG7di TiN8h+5zLSdqN7XW2nfPjjoqGupMEWY3BR1h8sCu/snE1UV/hMER1V4OJmEwyWhSV58S oQKntkLEXU84I3T6IZ573jsdiQGLi2S+YKz8WYsPvmrZaf3Yg148V82y31y10XdxI5fz 0RrGST7E0Lz+7uTsQTI42CCbGg8UKbcjqSPx/PP91Sw4jGDyedZbg2a52B1qZAvPsmBY kZrg== X-Gm-Message-State: ALoCoQkJeKRD6jdMMwVx+ad5KXQNgnDYYSzi+4C+kxuJDZHMjMYotC6WQD6Q1XBmaL8Pn6gZosjF 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140410_092947_482217_34EA7EE6 X-CRM114-Status: GOOD ( 14.58 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, Ulf Hansson , Rob Herring X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;