From patchwork Fri Nov 23 08:41:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 13129 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B73BA23FCD for ; Fri, 23 Nov 2012 08:48:31 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 53E2AA19042 for ; Fri, 23 Nov 2012 08:48:31 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so3632981iag.11 for ; Fri, 23 Nov 2012 00:48:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=WtLLTCreWdbnrrKl5BXYCy61IqCLDC5CoVYwSREtwIQ=; b=IYN+QS3we9erPodt0QurTqf+UZDkWDez+AYMWV8x0VFq6822e6/WoT/7IT6YgTAVH7 r77CbHvqPuMo5YL1Vp21gFSuqHG89PXaV8D4f+/fUaNnjWJ5SnHpIz3XhxK+XZNmtNHg 5wzSzIJTASSS+BK68221Rq9cGwYjpqx/Om7aWBGXJDr8T6dM4DVyqbYRNYtnvpx0n260 lWzQ4lm/LddaW05v7zwhrOemO10fWJ/QT8sTikeVs4QgtHz3BcQC3SAkDUF4LQS1M/tt k9IbtEdG6a00Ea3yLr93TxD06t+aa11ZHK68tpJolgDTlHt0TKx47bMls7vRvIJhT9ul PyTA== Received: by 10.50.173.34 with SMTP id bh2mr2835003igc.70.1353660510734; Fri, 23 Nov 2012 00:48:30 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp320662igt; Fri, 23 Nov 2012 00:48:30 -0800 (PST) Received: by 10.68.236.131 with SMTP id uu3mr12376000pbc.104.1353660510160; Fri, 23 Nov 2012 00:48:30 -0800 (PST) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by mx.google.com with ESMTPS id h9si7468364pax.97.2012.11.23.00.48.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Nov 2012 00:48:30 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.42 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) client-ip=209.85.220.42; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.42 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) smtp.mail=tushar.behera@linaro.org Received: by mail-pa0-f42.google.com with SMTP id rl6so3489137pac.1 for ; Fri, 23 Nov 2012 00:48:29 -0800 (PST) Received: by 10.68.189.138 with SMTP id gi10mr12155675pbc.165.1353660509921; Fri, 23 Nov 2012 00:48:29 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id jw10sm3495481pbb.20.2012.11.23.00.48.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Nov 2012 00:48:28 -0800 (PST) From: Tushar Behera To: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: w.sang@pengutronix.de, kgene.kim@samsung.com, patches@linaro.org Subject: [PATCH V2 2/4] i2c: s3c2410: Convert to use devm_* APIs Date: Fri, 23 Nov 2012 14:11:53 +0530 Message-Id: <1353660115-9710-3-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1353660115-9710-1-git-send-email-tushar.behera@linaro.org> References: <1353660115-9710-1-git-send-email-tushar.behera@linaro.org> X-Gm-Message-State: ALoCoQlLG1P9OilR13RRpuGqFQFGFlOYQxH0jgz1lKl7fME2goVYlRImsUxp5GBZ3s7pHTU1lChl i2c-s3c2410 driver is modified to use devm_clk_get(), devm_request_and_ioremap() (combining request_mem_region() and ioremap()) and devm_request_irq(). This also simplifies the return path in driver's probe. Signed-off-by: Tushar Behera --- Changes since V1: * devm_request_mem_region and devm_ioremap calls were replaced by devm_request_and_ioremap() call. * All devm_* related modifications (earlier patches 2-5) were merged to a single patch. drivers/i2c/busses/i2c-s3c2410.c | 51 +++++++++----------------------------- 1 files changed, 12 insertions(+), 39 deletions(-) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 7522f40..a203917 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -78,7 +78,6 @@ struct s3c24xx_i2c { void __iomem *regs; struct clk *clk; struct device *dev; - struct resource *ioarea; struct i2c_adapter adap; struct s3c2410_platform_i2c *pdata; @@ -968,7 +967,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) /* find the clock and enable it */ i2c->dev = &pdev->dev; - i2c->clk = clk_get(&pdev->dev, "i2c"); + i2c->clk = devm_clk_get(&pdev->dev, "i2c"); if (IS_ERR(i2c->clk)) { dev_err(&pdev->dev, "cannot get clock\n"); return -ENOENT; @@ -987,25 +986,16 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) goto err_clk; } - i2c->ioarea = request_mem_region(res->start, resource_size(res), - pdev->name); - - if (i2c->ioarea == NULL) { - dev_err(&pdev->dev, "cannot request IO\n"); - ret = -ENXIO; - goto err_clk; - } - - i2c->regs = ioremap(res->start, resource_size(res)); + i2c->regs = devm_request_and_ioremap(&pdev->dev, res); if (i2c->regs == NULL) { - dev_err(&pdev->dev, "cannot map IO\n"); + dev_err(&pdev->dev, "cannot request and map IO\n"); ret = -ENXIO; - goto err_ioarea; + goto err_clk; } - dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", - i2c->regs, i2c->ioarea, res); + dev_dbg(&pdev->dev, "registers %p (%p)\n", + i2c->regs, res); /* setup info block for the i2c core */ @@ -1016,7 +1006,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) ret = s3c24xx_i2c_init(i2c); if (ret != 0) - goto err_iomap; + goto err_clk; /* find the IRQ for this unit (note, this relies on the init call to * ensure no current IRQs pending @@ -1025,21 +1015,21 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) i2c->irq = ret = platform_get_irq(pdev, 0); if (ret <= 0) { dev_err(&pdev->dev, "cannot find IRQ\n"); - goto err_iomap; + goto err_clk; } - ret = request_irq(i2c->irq, s3c24xx_i2c_irq, 0, - dev_name(&pdev->dev), i2c); + ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0, + dev_name(&pdev->dev), i2c); if (ret != 0) { dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); - goto err_iomap; + goto err_clk; } ret = s3c24xx_i2c_register_cpufreq(i2c); if (ret < 0) { dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); - goto err_irq; + goto err_clk; } /* Note, previous versions of the driver used i2c_add_adapter() @@ -1070,19 +1060,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) err_cpufreq: s3c24xx_i2c_deregister_cpufreq(i2c); - err_irq: - free_irq(i2c->irq, i2c); - - err_iomap: - iounmap(i2c->regs); - - err_ioarea: - release_resource(i2c->ioarea); - kfree(i2c->ioarea); - err_clk: clk_disable_unprepare(i2c->clk); - clk_put(i2c->clk); return ret; } @@ -1101,16 +1080,10 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) s3c24xx_i2c_deregister_cpufreq(i2c); i2c_del_adapter(&i2c->adap); - free_irq(i2c->irq, i2c); clk_disable_unprepare(i2c->clk); - clk_put(i2c->clk); - - iounmap(i2c->regs); - release_resource(i2c->ioarea); s3c24xx_i2c_dt_gpio_free(i2c); - kfree(i2c->ioarea); return 0; }