From patchwork Sun Aug 26 16:00:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 1375441 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork1.kernel.org (Postfix) with ESMTP id 94D87402E1 for ; Sun, 26 Aug 2012 16:01:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1T5fHC-0005eu-Pg; Sun, 26 Aug 2012 16:01:26 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1T5fHB-0005em-IL for spi-devel-general@lists.sourceforge.net; Sun, 26 Aug 2012 16:01:25 +0000 Received-SPF: neutral (sog-mx-1.v43.ch3.sourceforge.com: 192.134.164.105 is neither permitted nor denied by domain of lip6.fr) client-ip=192.134.164.105; envelope-from=Julia.Lawall@lip6.fr; helo=mail4-relais-sop.national.inria.fr; Received: from mail4-relais-sop.national.inria.fr ([192.134.164.105]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1T5fH5-0005oj-I7 for spi-devel-general@lists.sourceforge.net; Sun, 26 Aug 2012 16:01:25 +0000 X-IronPort-AV: E=Sophos;i="4.80,315,1344204000"; d="scan'208";a="153852288" 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: Grant Likely Subject: [PATCH 2/13] drivers/spi/spi-{orion, pl022}.c: use clk_prepare_enable and clk_disable_unprepare Date: Sun, 26 Aug 2012 18:00:54 +0200 Message-Id: <1345996865-32082-3-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-Score: 0.4 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.7 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -0.3 AWL AWL: From: address is in the auto white-list X-Headers-End: 1T5fH5-0005oj-I7 Cc: spi-devel-general@lists.sourceforge.net, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net 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 --- drivers/spi/spi-orion.c | 3 +-- drivers/spi/spi-pl022.c | 17 ++++------------- 2 files changed, 5 insertions(+), 15 deletions(-) ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index b17c09c..b2a7199 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -416,8 +416,7 @@ static int __init orion_spi_probe(struct platform_device *pdev) goto out; } - clk_prepare(spi->clk); - clk_enable(spi->clk); + clk_prepare_enable(spi->clk); tclk_hz = clk_get_rate(spi->clk); spi->max_speed = DIV_ROUND_UP(tclk_hz, 4); spi->min_speed = DIV_ROUND_UP(tclk_hz, 30); diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index b0fec03..0d235d4 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -2142,16 +2142,10 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) goto err_no_clk; } - status = clk_prepare(pl022->clk); - if (status) { - dev_err(&adev->dev, "could not prepare SSP/SPI bus clock\n"); - goto err_clk_prep; - } - - status = clk_enable(pl022->clk); + status = clk_prepare_enable(pl022->clk); if (status) { dev_err(&adev->dev, "could not enable SSP/SPI bus clock\n"); - goto err_no_clk_en; + goto err_clk_prep; } /* Initialize transfer pump */ @@ -2207,9 +2201,7 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) free_irq(adev->irq[0], pl022); err_no_irq: - clk_disable(pl022->clk); - err_no_clk_en: - clk_unprepare(pl022->clk); + clk_disable_unprepare(pl022->clk); err_clk_prep: clk_put(pl022->clk); err_no_clk: @@ -2243,8 +2235,7 @@ pl022_remove(struct amba_device *adev) pl022_dma_remove(pl022); free_irq(adev->irq[0], pl022); - clk_disable(pl022->clk); - clk_unprepare(pl022->clk); + clk_disable_unprepare(pl022->clk); clk_put(pl022->clk); pm_runtime_disable(&adev->dev); iounmap(pl022->virtbase);