From patchwork Sun Aug 26 16:00:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 1375591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id B1FC93FC71 for ; Sun, 26 Aug 2012 16:05:10 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T5fHA-0004OP-2O; Sun, 26 Aug 2012 16:01:24 +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 1T5fH5-0004N9-TL for linux-arm-kernel@lists.infradead.org; Sun, 26 Aug 2012 16:01:20 +0000 X-IronPort-AV: E=Sophos;i="4.80,315,1344204000"; d="scan'208";a="153852293" 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: Russell King Subject: [PATCH 5/13] arch/arm: use clk_prepare_enable and clk_disable_unprepare Date: Sun, 26 Aug 2012 18:00:57 +0200 Message-Id: <1345996865-32082-6-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, linux-kernel@vger.kernel.org, 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 Reviewed-by: Pankaj Jangra --- arch/arm/common/sa1111.c | 3 +-- arch/arm/common/timer-sp.c | 16 ++++------------ arch/arm/kernel/smp_twd.c | 13 +++---------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index 9173d11..bd58414 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -834,8 +834,7 @@ static void __sa1111_remove(struct sa1111 *sachip) sa1111_writel(0, irqbase + SA1111_WAKEEN0); sa1111_writel(0, irqbase + SA1111_WAKEEN1); - clk_disable(sachip->clk); - clk_unprepare(sachip->clk); + clk_disable_unprepare(sachip->clk); if (sachip->irq != NO_IRQ) { irq_set_chained_handler(sachip->irq, NULL); diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c index df13a3f..af1a4ab 100644 --- a/arch/arm/common/timer-sp.c +++ b/arch/arm/common/timer-sp.c @@ -42,17 +42,10 @@ static long __init sp804_get_clock_rate(const char *name) return PTR_ERR(clk); } - err = clk_prepare(clk); + err = clk_prepare_enable(clk); if (err) { - pr_err("sp804: %s clock failed to prepare: %d\n", name, err); - clk_put(clk); - return err; - } - - err = clk_enable(clk); - if (err) { - pr_err("sp804: %s clock failed to enable: %d\n", name, err); - clk_unprepare(clk); + pr_err("sp804: %s clock failed to prepare or to enable: %d\n", + name, err); clk_put(clk); return err; } @@ -60,8 +53,7 @@ static long __init sp804_get_clock_rate(const char *name) rate = clk_get_rate(clk); if (rate < 0) { pr_err("sp804: %s clock failed to get rate: %ld\n", name, rate); - clk_disable(clk); - clk_unprepare(clk); + clk_disable_unprepare(clk); clk_put(clk); } diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index fef42b2..8c94b8b 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -204,17 +204,10 @@ static struct clk *twd_get_clock(void) return clk; } - err = clk_prepare(clk); + err = clk_prepare_enable(clk); if (err) { - pr_err("smp_twd: clock failed to prepare: %d\n", err); - clk_put(clk); - return ERR_PTR(err); - } - - err = clk_enable(clk); - if (err) { - pr_err("smp_twd: clock failed to enable: %d\n", err); - clk_unprepare(clk); + pr_err("smp_twd: clock failed to prepare or to enable: %d\n", + err); clk_put(clk); return ERR_PTR(err); }