From patchwork Mon Mar 31 15:18:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 27456 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3A57B202E0 for ; Mon, 31 Mar 2014 15:18:34 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id dc16sf8588721qab.11 for ; Mon, 31 Mar 2014 08:18:33 -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=OOuCbeD3aqeOQwEc3pM0yj9FnLAOllhD4IeJmOK5AEnVLJdhOEjkf5R1n4tnajwU7V HEVLSTtpurHLIWhUMObF7/1kRkWWnUn+bkHR1wYXobistgAwIn9752H3RUJuF1t646eA 0GdiTQ1L8H5xj+UQLj/nTTyEx9LgpDPuscdO7lOEYm09EtX5JI2dllnIIlX5z732OoLo 2IG/D3vNTeAcfIEuvK+TcCQEtEQ11udkMWjMm/E1zsagnzwRaDmBvX4Bj15MX+2uJAXs /fe8uoWKZFvpiOijYgiv/3QJO6haEEYYVZ+YqFe93ZSBGOQiLpKEty3Ov7tMWcKXTwtB p9/Q== X-Gm-Message-State: ALoCoQmoZpLkB8SLoYnVAiktaIjAuAeyAF598Kefjeh3E3VUOnXNaEK3Sh+mdaPLSggj/1bUp8Mq X-Received: by 10.236.137.50 with SMTP id x38mr9744739yhi.9.1396279113918; Mon, 31 Mar 2014 08:18:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.81 with SMTP id 75ls2584748qgg.75.gmail; Mon, 31 Mar 2014 08:18:33 -0700 (PDT) X-Received: by 10.220.225.5 with SMTP id iq5mr165313vcb.42.1396279113750; Mon, 31 Mar 2014 08:18:33 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id fi2si3027166vcb.69.2014.03.31.08.18.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 31 Mar 2014 08:18:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.173 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.173; Received: by mail-ve0-f173.google.com with SMTP id oy12so8194292veb.18 for ; Mon, 31 Mar 2014 08:18:33 -0700 (PDT) X-Received: by 10.220.162.6 with SMTP id t6mr24348173vcx.12.1396279113689; Mon, 31 Mar 2014 08:18:33 -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.12.8 with SMTP id v8csp150761vcv; Mon, 31 Mar 2014 08:18:33 -0700 (PDT) X-Received: by 10.180.109.231 with SMTP id hv7mr13203527wib.38.1396279111990; Mon, 31 Mar 2014 08:18:31 -0700 (PDT) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by mx.google.com with ESMTPS id uu8si3432243wjc.211.2014.03.31.08.18.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 31 Mar 2014 08:18:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.177 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.212.177; Received: by mail-wi0-f177.google.com with SMTP id cc10so3511130wib.16 for ; Mon, 31 Mar 2014 08:18:31 -0700 (PDT) X-Received: by 10.194.20.229 with SMTP id q5mr4305101wje.86.1396279111471; Mon, 31 Mar 2014 08:18:31 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id wl6sm13547488wjb.3.2014.03.31.08.18.30 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 31 Mar 2014 08:18:30 -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 V2 02/19] mmc: mmci: Convert to devm functions Date: Mon, 31 Mar 2014 17:18:03 +0200 Message-Id: <1396279100-2920-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1396279100-2920-1-git-send-email-ulf.hansson@linaro.org> References: <1396279100-2920-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.173 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;