From patchwork Thu Feb 13 14:09:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 24595 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 78FB7202E2 for ; Thu, 13 Feb 2014 14:09:15 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id kq14sf24195000pab.9 for ; Thu, 13 Feb 2014 06:09:14 -0800 (PST) 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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=hiVSoKZmNhhRP5jDZrbWZODwLJ4Ptdsz52FWOfEOqUo=; b=DcIJ/aKpiIfhUx4MnDgoYExr5t1WXU2wW/o9bmeawNGlKtHHo6TXEDQVyrXdMpZ5z/ Y1t9tJfXHuUZuT8KD2CAHo/Bf80jRaxSZhfm7qexK4DkpIXKOmiFmUMc+lFNt9kzFs7n z7p5onYhNiY9YriFujMDyJUE53Q9B9luBBBNW/G0SaS1HS0z+a9i51j70CxR+wTb+Me6 kZIPz100UU4D8Nu6JR3V5nXdJllqUoEJOUNYXfj4ZNhEeqit+mDzWQVMvdHqCoPFsqFb fpE9+sBIvwoZQUx3WyO3nTvwGWf2a3tN4aKgsgTA0fFWcay8X9QVRg9goPEUdXqLMx+/ qrkg== X-Gm-Message-State: ALoCoQneeVAcYAHvu5Y1qg/E1eIhbBnGGEKc26t/g8lRDjy9kwxSulMLYDFmjxvIpIW1Xrjl+J0u X-Received: by 10.66.149.67 with SMTP id ty3mr531267pab.27.1392300554728; Thu, 13 Feb 2014 06:09:14 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.165 with SMTP id x34ls2455876qgx.53.gmail; Thu, 13 Feb 2014 06:09:14 -0800 (PST) X-Received: by 10.221.66.132 with SMTP id xq4mr17973vcb.57.1392300554594; Thu, 13 Feb 2014 06:09:14 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id qi7si679411veb.110.2014.02.13.06.09.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Feb 2014 06:09:14 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 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.176; Received: by mail-ve0-f176.google.com with SMTP id jx11so1330857veb.21 for ; Thu, 13 Feb 2014 06:09:14 -0800 (PST) X-Received: by 10.220.209.197 with SMTP id gh5mr7391vcb.65.1392300554482; Thu, 13 Feb 2014 06:09:14 -0800 (PST) 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.174.196 with SMTP id u4csp28402vcz; Thu, 13 Feb 2014 06:09:13 -0800 (PST) X-Received: by 10.180.105.65 with SMTP id gk1mr6757920wib.12.1392300553315; Thu, 13 Feb 2014 06:09:13 -0800 (PST) Received: from mail-we0-f173.google.com (mail-we0-f173.google.com [74.125.82.173]) by mx.google.com with ESMTPS id j7si968925wjy.45.2014.02.13.06.09.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Feb 2014 06:09:13 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.173 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=74.125.82.173; Received: by mail-we0-f173.google.com with SMTP id x48so1851868wes.32 for ; Thu, 13 Feb 2014 06:09:12 -0800 (PST) X-Received: by 10.180.106.40 with SMTP id gr8mr6556198wib.31.1392300552539; Thu, 13 Feb 2014 06:09:12 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id q15sm4823177wjw.18.2014.02.13.06.09.10 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Feb 2014 06:09:11 -0800 (PST) From: Ulf Hansson To: Russell King , linux-arm-kernel@lists.infradead.org Cc: Alessandro Rubini , Linus Walleij , Wolfram Sang , Chris Ball , Mark Brown , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, linux-mmc@vger.kernel.org, Ulf Hansson Subject: [PATCH V2 11/17] i2c: nomadik: Convert to devm functions Date: Thu, 13 Feb 2014 15:09:02 +0100 Message-Id: <1392300547-23365-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 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.176 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: , Use devm_* functions to simplify code and error handling. Cc: Alessandro Rubini Cc: Linus Walleij Cc: Wolfram Sang Signed-off-by: Ulf Hansson --- Changes in v2: Rebased on top of latest i2c-nomadik branch. --- drivers/i2c/busses/i2c-nomadik.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index bc8ba02..5faf9e2 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -981,7 +981,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) return -ENODEV; } - dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL); + dev = devm_kzalloc(&adev->dev, sizeof(struct nmk_i2c_dev), GFP_KERNEL); if (!dev) { dev_err(&adev->dev, "cannot allocate memory\n"); ret = -ENOMEM; @@ -1011,27 +1011,28 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) /* If possible, let's go to idle until the first transfer */ pinctrl_pm_select_idle_state(&adev->dev); - dev->virtbase = ioremap(adev->res.start, resource_size(&adev->res)); + dev->virtbase = devm_ioremap(&adev->dev, adev->res.start, + resource_size(&adev->res)); if (!dev->virtbase) { ret = -ENOMEM; - goto err_no_ioremap; + goto err_no_mem; } dev->irq = adev->irq[0]; - ret = request_irq(dev->irq, i2c_irq_handler, 0, + ret = devm_request_irq(&adev->dev, dev->irq, i2c_irq_handler, 0, DRIVER_NAME, dev); if (ret) { dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq); - goto err_irq; + goto err_no_mem; } pm_suspend_ignore_children(&adev->dev, true); - dev->clk = clk_get(&adev->dev, NULL); + dev->clk = devm_clk_get(&adev->dev, NULL); if (IS_ERR(dev->clk)) { dev_err(&adev->dev, "could not get i2c clock\n"); ret = PTR_ERR(dev->clk); - goto err_no_clk; + goto err_no_mem; } adap = &dev->adap; @@ -1053,21 +1054,13 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) ret = i2c_add_adapter(adap); if (ret) { dev_err(&adev->dev, "failed to add adapter\n"); - goto err_add_adap; + goto err_no_mem; } pm_runtime_put(&adev->dev); return 0; - err_add_adap: - clk_put(dev->clk); - err_no_clk: - free_irq(dev->irq, dev); - err_irq: - iounmap(dev->virtbase); - err_no_ioremap: - kfree(dev); err_no_mem: return ret; @@ -1084,13 +1077,9 @@ static int nmk_i2c_remove(struct amba_device *adev) clear_all_interrupts(dev); /* disable the controller */ i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE); - free_irq(dev->irq, dev); - iounmap(dev->virtbase); if (res) release_mem_region(res->start, resource_size(res)); - clk_put(dev->clk); pm_runtime_disable(&adev->dev); - kfree(dev); return 0; }