From patchwork Tue Feb 4 15:58:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 24118 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0354F202FA for ; Tue, 4 Feb 2014 15:59:50 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf38618475oag.8 for ; Tue, 04 Feb 2014 07:59:50 -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: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=nVLvAvRViOYD6Ee9qPWVW6/zpyx4M0n3AAfUOawg+Cs=; b=Gl5+nMqVCcpm0Qq+WCwvcYXBDpk2BosLEZvriV3FDxD+AswaSvspcBj6I0tGUPVWDo I7rgDfp368na2dL+5bHJIp/aaL0eu5DueojEP+7HZOnfkDlUEGIjGYnUlza61FHhxi7G zq6SD+kxY4nRR9Cn+dFURmN7xryW63UPJ2GkNP7kAEnY9sWmOy6j7bu6WghWueJWcCha MbQ+t6oog7L12cd5v7cl/qy9+g1xvv9H6+KnR7KZxSu1/XiJz536rw6vS4e3GpmLjjTH ge3MA7OgRrhL+/X9LWt+rC9qBJTi2K7yf/fPgw6BMNzyJYpXwhE5lJnK5EoKSMTnWcOy ITsg== X-Gm-Message-State: ALoCoQmmbOnp6OjDQU8dEkUw1IGvTO8WNaxwFCHWgIKWFghayKvAIWp0O2PDI8zossRIU3v/iNYm X-Received: by 10.42.107.67 with SMTP id c3mr15047262icp.0.1391529590061; Tue, 04 Feb 2014 07:59:50 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.110 with SMTP id y101ls2369578qgd.0.gmail; Tue, 04 Feb 2014 07:59:49 -0800 (PST) X-Received: by 10.58.209.36 with SMTP id mj4mr373086vec.47.1391529589913; Tue, 04 Feb 2014 07:59:49 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id fb12si8311126veb.90.2014.02.04.07.59.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 07:59:49 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 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.170; Received: by mail-ve0-f170.google.com with SMTP id cz12so6282606veb.29 for ; Tue, 04 Feb 2014 07:59:49 -0800 (PST) X-Received: by 10.52.34.173 with SMTP id a13mr308229vdj.68.1391529589841; Tue, 04 Feb 2014 07:59:49 -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 u4csp245382vcz; Tue, 4 Feb 2014 07:59:49 -0800 (PST) X-Received: by 10.152.164.199 with SMTP id ys7mr3100989lab.31.1391529588372; Tue, 04 Feb 2014 07:59:48 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176]) by mx.google.com with ESMTPS id b8si12956593lah.98.2014.02.04.07.59.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 07:59:48 -0800 (PST) Received-SPF: neutral (google.com: 209.85.217.176 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id w7so6589398lbi.35 for ; Tue, 04 Feb 2014 07:59:47 -0800 (PST) X-Received: by 10.112.56.237 with SMTP id d13mr29059148lbq.2.1391529587674; Tue, 04 Feb 2014 07:59:47 -0800 (PST) Received: from localhost.localdomain (host-95-199-220-119.mobileonline.telia.com. [95.199.220.119]) by mx.google.com with ESMTPSA id dm8sm35906603lad.7.2014.02.04.07.59.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 07:59:47 -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 11/17] i2c: nomadik: Convert to devm functions Date: Tue, 4 Feb 2014 16:58:52 +0100 Message-Id: <1391529538-21685-12-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391529538-21685-1-git-send-email-ulf.hansson@linaro.org> References: <1391529538-21685-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.170 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 Acked-by: Linus Walleij --- 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 4443613..840bcf9 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -1015,7 +1015,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) pdata->rft = max_fifo_threshold; } - 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; @@ -1031,27 +1031,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; @@ -1079,21 +1080,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; @@ -1110,13 +1103,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; }