From patchwork Mon Feb 17 15:20:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 24774 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 00F4C20143 for ; Mon, 17 Feb 2014 15:20:25 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id v10sf34474123pde.1 for ; Mon, 17 Feb 2014 07:20:25 -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=YtE5KKVmAwn+isTXfBhz0Aafg806gjm476FTpy82HuE=; b=Q4jIjH4hxKeTVOlVyaoLvnLuX1sYrifWKP2kKiFVoVzmlmPEM2B/7idcbd8iX7x6fo gmif9g4FJbsScEkTtfy9TduoGqLTYR+oIuvCGCiHbgDOxV44jEum8Tl2UylxsA4DYFkF HDDg3xxIaGkS+1f0858GE/eXl7Q3+bTUqx0vJPnXaRLW/Y88j0gUX32Rw+kYqeiyplm7 2WbIM5JoYOP05S9uw2pBarJe8hrsRvjgD+sqDnMq0AJIfCMrZaCUm90+F2ZftUxxcXUX oBTaILw7LfEdCXAzRyJXY+ROK1yGuhikoBikj4GGtrjLNJO7/YC5wtCV/3bDwflapv9v bw6A== X-Gm-Message-State: ALoCoQksobvmC6AueAekQdh2ck8X4tP5lK6wFz/eJ/W8SqZSbGLy1mNJFlri4fOfj6gbUtlui/rS X-Received: by 10.66.145.105 with SMTP id st9mr3807757pab.23.1392650425209; Mon, 17 Feb 2014 07:20:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.136 with SMTP id 8ls979387qgl.27.gmail; Mon, 17 Feb 2014 07:20:25 -0800 (PST) X-Received: by 10.52.230.105 with SMTP id sx9mr14827314vdc.10.1392650425105; Mon, 17 Feb 2014 07:20:25 -0800 (PST) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id fb12si4532747veb.90.2014.02.17.07.20.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 07:20:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.180 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.180; Received: by mail-ve0-f180.google.com with SMTP id db12so12424641veb.11 for ; Mon, 17 Feb 2014 07:20:25 -0800 (PST) X-Received: by 10.220.191.134 with SMTP id dm6mr17630845vcb.16.1392650425001; Mon, 17 Feb 2014 07:20:25 -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 u4csp146438vcz; Mon, 17 Feb 2014 07:20:24 -0800 (PST) X-Received: by 10.152.234.36 with SMTP id ub4mr18208259lac.13.1392650423431; Mon, 17 Feb 2014 07:20:23 -0800 (PST) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by mx.google.com with ESMTPS id pc5si25671655lbb.75.2014.02.17.07.20.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 07:20:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.217.172 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id c11so11359943lbj.17 for ; Mon, 17 Feb 2014 07:20:22 -0800 (PST) X-Received: by 10.152.234.202 with SMTP id ug10mr18114213lac.28.1392650422740; Mon, 17 Feb 2014 07:20:22 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id cu8sm19262710lbb.12.2014.02.17.07.20.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 07:20:21 -0800 (PST) From: Ulf Hansson To: Alessandro Rubini , Linus Walleij , Wolfram Sang , linux-i2c@vger.kernel.org Cc: Russell King , linux-arm-kernel@lists.infradead.org, Mark Brown , Ulf Hansson Subject: [PATCH V3 11/17] i2c: nomadik: Convert to devm functions Date: Mon, 17 Feb 2014 16:20:18 +0100 Message-Id: <1392650418-14820-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.180 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 --- drivers/i2c/busses/i2c-nomadik.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index bc8ba02..cd15c03 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)); - if (!dev->virtbase) { + dev->virtbase = devm_ioremap(&adev->dev, adev->res.start, + resource_size(&adev->res)); + if (IS_ERR(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; }