From patchwork Sun Aug 26 16:00:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 1375621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 5FDC9DFABE for ; Sun, 26 Aug 2012 16:05:11 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T5fHJ-0004Pl-SL; Sun, 26 Aug 2012 16:01:34 +0000 Received: from mail4-relais-sop.national.inria.fr ([192.134.164.105]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T5fH7-0004N9-Ba for linux-arm-kernel@lists.infradead.org; Sun, 26 Aug 2012 16:01:21 +0000 X-IronPort-AV: E=Sophos;i="4.80,315,1344204000"; d="scan'208";a="153852292" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Aug 2012 18:01:12 +0200 From: Julia Lawall To: Barry Song Subject: [PATCH 4/13] i2c: sirf: use clk_prepare_enable and clk_disable_unprepare Date: Sun, 26 Aug 2012 18:00:56 +0200 Message-Id: <1345996865-32082-5-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1345996865-32082-1-git-send-email-Julia.Lawall@lip6.fr> References: <1345996865-32082-1-git-send-email-Julia.Lawall@lip6.fr> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -6.1 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.134.164.105 listed in list.dnswl.org] 0.8 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kernel-janitors@vger.kernel.org, "Wolfram Sang \(embedded platforms\)" , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, "Ben Dooks \(embedded platforms\)" , "Jean Delvare \(PC drivers, core\)" , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Julia Lawall Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and clk_enable, and clk_disable and clk_unprepare. They make the code more concise, and ensure that clk_unprepare is called when clk_enable fails. A simplified version of the semantic patch that introduces calls to these functions is as follows: (http://coccinelle.lip6.fr/) // @@ expression e; @@ - clk_prepare(e); - clk_enable(e); + clk_prepare_enable(e); @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); // Signed-off-by: Julia Lawall Acked-by: Barry Song <21cnbao@gmail.com> --- drivers/i2c/busses/i2c-sirf.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c index 5574a47..110660a 100644 --- a/drivers/i2c/busses/i2c-sirf.c +++ b/drivers/i2c/busses/i2c-sirf.c @@ -278,18 +278,12 @@ static int __devinit i2c_sirfsoc_probe(struct platform_device *pdev) goto err_get_clk; } - err = clk_prepare(clk); + err = clk_prepare_enable(clk); if (err) { - dev_err(&pdev->dev, "Clock prepare failed\n"); + dev_err(&pdev->dev, "Clock prepare or enable failed\n"); goto err_clk_prep; } - err = clk_enable(clk); - if (err) { - dev_err(&pdev->dev, "Clock enable failed\n"); - goto err_clk_en; - } - ctrl_speed = clk_get_rate(clk); siic = devm_kzalloc(&pdev->dev, sizeof(*siic), GFP_KERNEL); @@ -376,9 +370,7 @@ static int __devinit i2c_sirfsoc_probe(struct platform_device *pdev) return 0; out: - clk_disable(clk); -err_clk_en: - clk_unprepare(clk); + clk_disable_unprepare(clk); err_clk_prep: clk_put(clk); err_get_clk: