From patchwork Thu Jan 24 10:11:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 14263 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 DC59123F02 for ; Thu, 24 Jan 2013 10:20:20 +0000 (UTC) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by fiordland.canonical.com (Postfix) with ESMTP id 92066A188DB for ; Thu, 24 Jan 2013 10:20:20 +0000 (UTC) Received: by mail-vb0-f45.google.com with SMTP id p1so5213710vbi.4 for ; Thu, 24 Jan 2013 02:20:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=tOB7kETelHFmAuHLY1yOFbhRiiRuKshXlIdDlsjJaK4=; b=ZkqUQo+9Ne3Y6YPjXR/vXnkWItOXeShXK4gTr0ty+5MTCPCqZzToERqbp8M4FfTYyF gq8nDao1l+liwIfNpzh7iQYzuamwCkgWz6shhMoI+1NgXJZTRyGI5WZxL9uOvWBqiigk UwzePDa6j14Sm79Klb/J8ky1ymlSX4HQFw+MMxis77odIXv7cypUgXSbc1NucsOnn6Pg aO+gp6M3qnxy81TyK+ecGJzCc3OoIzdIawzxZJs1AxYXg7zbl3ctPfO6eKtEcVuj0N6J 6qGU94tYFFGEeQgVUQHV/tmNtrrSGnZQHs6p+fjrrQbrcBJDGfGmolJ/2u6yPjrTp3vJ wA8w== X-Received: by 10.52.97.7 with SMTP id dw7mr1164049vdb.38.1359022820069; Thu, 24 Jan 2013 02:20:20 -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.58.145.101 with SMTP id st5csp56445veb; Thu, 24 Jan 2013 02:20:19 -0800 (PST) X-Received: by 10.68.233.196 with SMTP id ty4mr3569267pbc.23.1359022819104; Thu, 24 Jan 2013 02:20:19 -0800 (PST) Received: from mail-da0-f52.google.com (mail-da0-f52.google.com [209.85.210.52]) by mx.google.com with ESMTPS id ax9si23436514pbd.334.2013.01.24.02.20.18 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Jan 2013 02:20:19 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.52 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) client-ip=209.85.210.52; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.52 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-f52.google.com with SMTP id f10so4162455dak.11 for ; Thu, 24 Jan 2013 02:20:18 -0800 (PST) X-Received: by 10.66.76.41 with SMTP id h9mr3472040paw.1.1359022818065; Thu, 24 Jan 2013 02:20:18 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id ho4sm14625980pbc.54.2013.01.24.02.20.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 24 Jan 2013 02:20:16 -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 V3 3/4] i2c: s3c2410: Move location of clk_prepare_enable() call in probe function Date: Thu, 24 Jan 2013 15:41:08 +0530 Message-Id: <1359022269-12593-4-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1359022269-12593-1-git-send-email-tushar.behera@linaro.org> References: <1359022269-12593-1-git-send-email-tushar.behera@linaro.org> X-Gm-Message-State: ALoCoQlb1lLua4f/fhXHQTjvqJf6RdPSavh4q8vl24i7LR0Xu1n6/sm6Z5zNbfrKt1KWbmD9pV5Z In i2c-s3c2410 driver probe, 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 --- Changes since V2: * Rebased to v3.8-rc4. Changes since V1: * Rebased as per the V2 patch series. 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 4b6cc13..4d1ba8d 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -1030,23 +1030,20 @@ 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->regs = devm_request_and_ioremap(&pdev->dev, res); if (i2c->regs == NULL) { dev_err(&pdev->dev, "cannot request and map IO\n"); - ret = -ENXIO; - goto err_clk; + return -ENXIO; } dev_dbg(&pdev->dev, "registers %p (%p)\n", @@ -1064,16 +1061,18 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) if (i2c->pdata->cfg_gpio) { i2c->pdata->cfg_gpio(to_platform_device(i2c->dev)); } else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) { - ret = -EINVAL; - goto err_clk; + return -EINVAL; } /* 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 */ @@ -1081,7 +1080,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, @@ -1089,13 +1088,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() @@ -1120,14 +1119,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; }