From patchwork Fri Nov 23 05:59:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 13121 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 03F7B24252 for ; Fri, 23 Nov 2012 06:05:58 +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 ABB30A18B90 for ; Fri, 23 Nov 2012 06:05:57 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so3578243iag.11 for ; Thu, 22 Nov 2012 22:05:57 -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=rVIKPt67UeSFuw665amFi3ZSibOy17mLL1Sz77xzspY=; b=Oky6vDRVu1qWraJsX6/Z7wxixMQfmI15fkxf7bOFtr1G/qlEnAc7YIqObhWxl7MUh0 ZEanpABH5s8amHWXeJGFKuFEgFazF1IWTbYlU6JbHjaatpheFgfBlwP1xdmEnkWimWie V0IPeCpHFTAE8OxIc2DnM8bgRf0HvZkXot6VSK+cUP2Xy5/FGf9w1Y2pZngETTCLjcdK uern+EynQwSct9nDIPJyFY+/akkl3PlOe089tDzX1x+QbWbJK8wRRELOCLMOProP/5jr TZjsxfVbOGJ0rrSxVaGOx4EFDMkXTvjLKZZgRJ9WIT7HZbFfGpnsCzVAix5b7AcA2Fek ZN8g== Received: by 10.50.187.197 with SMTP id fu5mr2533752igc.70.1353650757177; Thu, 22 Nov 2012 22:05:57 -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 n20csp307447igt; Thu, 22 Nov 2012 22:05:56 -0800 (PST) Received: by 10.68.251.197 with SMTP id zm5mr11449622pbc.30.1353650756564; Thu, 22 Nov 2012 22:05:56 -0800 (PST) Received: from mail-da0-f42.google.com (mail-da0-f42.google.com [209.85.210.42]) by mx.google.com with ESMTPS id w3si7628051pbz.18.2012.11.22.22.05.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Nov 2012 22:05:56 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.42 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) client-ip=209.85.210.42; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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-da0-f42.google.com with SMTP id z17so5840635dal.1 for ; Thu, 22 Nov 2012 22:05:56 -0800 (PST) Received: by 10.66.81.42 with SMTP id w10mr7606936pax.66.1353650756324; Thu, 22 Nov 2012 22:05:56 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id oi3sm3271920pbb.1.2012.11.22.22.05.52 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Nov 2012 22:05:55 -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 6/7] i2c: s3c2410: Move location of clk_prepare_enable() call in probe function Date: Fri, 23 Nov 2012 11:29:12 +0530 Message-Id: <1353650353-17576-7-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1353650353-17576-1-git-send-email-tushar.behera@linaro.org> References: <1353650353-17576-1-git-send-email-tushar.behera@linaro.org> X-Gm-Message-State: ALoCoQkmQoplbWsqq8IA89JBEWDu5wXOHAIf3tcLRzeM5ZuCUPFwdqiP1u9+vidvscvNML5UHb+o In probe call, only s3c24xx_i2c_init() needs the I2C clock to be enabled. Moving clk_prepare_enable() and clk_disable_unprepare() calls to around this function simplifies the return path of probe call. Signed-off-by: Tushar Behera --- drivers/i2c/busses/i2c-s3c2410.c | 29 ++++++++++++----------------- 1 files changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 3e4143c..707efaf 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -976,15 +976,13 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); - clk_prepare_enable(i2c->clk); /* map the registers */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "cannot find IO resource\n"); - ret = -ENOENT; - goto err_clk; + return -ENOENT; } i2c->ioarea = devm_request_mem_region(&pdev->dev, res->start, @@ -992,16 +990,14 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) if (i2c->ioarea == NULL) { dev_err(&pdev->dev, "cannot request IO\n"); - ret = -ENXIO; - goto err_clk; + return -ENXIO; } i2c->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (i2c->regs == NULL) { dev_err(&pdev->dev, "cannot map IO\n"); - ret = -ENXIO; - goto err_clk; + return -ENXIO; } dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", @@ -1014,10 +1010,13 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) /* initialise the i2c controller */ + clk_prepare_enable(i2c->clk); ret = s3c24xx_i2c_init(i2c); - if (ret != 0) - goto err_clk; - + clk_disable_unprepare(i2c->clk); + if (ret != 0) { + dev_err(&pdev->dev, "I2C controller init failed\n"); + return ret; + } /* find the IRQ for this unit (note, this relies on the init call to * ensure no current IRQs pending */ @@ -1025,7 +1024,7 @@ 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_clk; + return ret; } ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0, @@ -1033,13 +1032,13 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); - goto err_clk; + return ret; } ret = s3c24xx_i2c_register_cpufreq(i2c); if (ret < 0) { dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); - goto err_clk; + return ret; } /* Note, previous versions of the driver used i2c_add_adapter() @@ -1064,14 +1063,10 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) pm_runtime_enable(&i2c->adap.dev); dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev)); - clk_disable_unprepare(i2c->clk); return 0; err_cpufreq: s3c24xx_i2c_deregister_cpufreq(i2c); - - err_clk: - clk_disable_unprepare(i2c->clk); return ret; }