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: 3645431 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E551DBF13A for ; Thu, 13 Feb 2014 14:09:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2B9C201EC for ; Thu, 13 Feb 2014 14:09:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A12BB201B4 for ; Thu, 13 Feb 2014 14:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751366AbaBMOJP (ORCPT ); Thu, 13 Feb 2014 09:09:15 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:48874 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751053AbaBMOJN (ORCPT ); Thu, 13 Feb 2014 09:09:13 -0500 Received: by mail-wi0-f169.google.com with SMTP id e4so3312384wiv.4 for ; Thu, 13 Feb 2014 06:09:12 -0800 (PST) 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; bh=hiVSoKZmNhhRP5jDZrbWZODwLJ4Ptdsz52FWOfEOqUo=; b=O55b0X0X3r2D4mkRvxChFq1ZQNbIPn0r8hrKpMmK9X2FC4AAEsoOHkgbGwUNA5PCLD MYVG83owpwhXn7pGbRou5xyV7EYQrjkKb9e8yqrgp64HP2Djkl9ZyloLZ11AjJw5LxYd 29Pb6Agioc1WuO7l3L31+IrquET6wngEM3NUTC9sBsuR20Xtv0qAwtOp08mTqofJNJoT TFIHTXV47Hh40QRji2uAbGsDwrm3P0RKYx8VNvsrxY8Fo27R/6dhQafyd1725iKBZuFF oPUPXcDQGZE0/pWAqnpNg1nA1ycGbxN8N1+pnNECnxw6Qtbo253j/q4IQP57o7623GgE OThA== X-Gm-Message-State: ALoCoQkIrPUMPXg2/2X5PSa9tYnKNJS/SekXs4GI1Ngh2XPMCyZ4zZrxXOVDduCw4V1Pmyrf3QMr 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 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 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; }