From patchwork Mon Sep 10 04:12:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 11268 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 03CE223F26 for ; Mon, 10 Sep 2012 04:15:15 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8E023A1831C for ; Mon, 10 Sep 2012 04:15:14 +0000 (UTC) Received: by iafj25 with SMTP id j25so1424599iaf.11 for ; Sun, 09 Sep 2012 21:15:14 -0700 (PDT) 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:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=/zPLCaPLdH4MIa49ZXUHInYpwPT9Bj9dYr7RLHgKez0=; b=fk++cNWefWqV7UeVAyciq83evdEuWwD24dAL43K0ExOofZIEaZpcoT7eOcnIH04VVb BXJH0294wd7pHXOGVTJYU0l4Eb10PC0FhuQcSs6EHVdYsVYUsd1beSeRCDI9QsuQGAr6 gMfn3c0nwT0uhWQwySuOGwfuqX+Cy0QBy5dwDoeT08aA9t2iGCNAj9Ep//rkYIdJ4Lho oAXe23v97Rv2wNabdSs2jaK6O4u+cMjxNVGXJda0tzeFFZLJOahrzbdILKmgq8xk7dRU nLIVC9R8IdhmMXBjJmE3ag9xcT4CpZYN6sIfDyjGEnRRqp+3N2fgvQ8/A4dbGS3uXXP1 YV5w== Received: by 10.50.7.212 with SMTP id l20mr8929536iga.43.1347250514016; Sun, 09 Sep 2012 21:15:14 -0700 (PDT) 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.184.232 with SMTP id ex8csp72902igc; Sun, 9 Sep 2012 21:15:13 -0700 (PDT) Received: by 10.66.78.195 with SMTP id d3mr19846118pax.17.1347250513287; Sun, 09 Sep 2012 21:15:13 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id rr1si2743009pbc.248.2012.09.09.21.15.13 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 21:15:13 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by dade7 with SMTP id e7so1311691dad.37 for ; Sun, 09 Sep 2012 21:15:13 -0700 (PDT) Received: by 10.68.135.67 with SMTP id pq3mr3920266pbb.49.1347250512995; Sun, 09 Sep 2012 21:15:12 -0700 (PDT) Received: from localhost (ip-64-134-230-8.public.wayport.net. [64.134.230.8]) by mx.google.com with ESMTPS id pn4sm7428527pbb.50.2012.09.09.21.15.11 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 21:15:12 -0700 (PDT) Date: Sun, 9 Sep 2012 21:12:37 -0700 From: Anton Vorontsov To: Andrew Morton , Russell King , Jason Wessel , Greg Kroah-Hartman , Alan Cox Cc: Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= , Colin Cross , Brian Swetland , John Stultz , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com, kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH 02/14] drivers/tty/serial/amba-pl0{10,11}.c: use clk_prepare_enable and clk_disable_unprepare Message-ID: <20120910041237.GB29537@lizard> References: <20120910040802.GA1261@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120910040802.GA1261@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQmxmWMWE47sewo27JIgVDqqZoS0qS25PRXt/JO+yUK0vqpnpViK6Y3VrF3Yrda6myNpte7e From: Julia Lawall Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and clk_enable, and clk_disable and clk_unprepare. The9 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Anton Vorontsov --- The patch was taken from the TTY tree. If this patch rejects because 'already applied', this means that your tree is probably based on TTY tree or -next (e.g. -mm). In which case you don't need this patch, just drop it. If your tree is based on Linus' tree, you need this patch to not bring horrible conflicts into -next. drivers/tty/serial/amba-pl010.c | 15 ++++----------- drivers/tty/serial/amba-pl011.c | 15 ++++----------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c index 0d91a54..22317dd 100644 --- a/drivers/tty/serial/amba-pl010.c +++ b/drivers/tty/serial/amba-pl010.c @@ -312,16 +312,12 @@ static int pl010_startup(struct uart_port *port) struct uart_amba_port *uap = (struct uart_amba_port *)port; int retval; - retval = clk_prepare(uap->clk); - if (retval) - goto out; - /* * Try to enable the clock producer. */ - retval = clk_enable(uap->clk); + retval = clk_prepare_enable(uap->clk); if (retval) - goto clk_unprep; + goto out; uap->port.uartclk = clk_get_rate(uap->clk); @@ -346,9 +342,7 @@ static int pl010_startup(struct uart_port *port) return 0; clk_dis: - clk_disable(uap->clk); - clk_unprep: - clk_unprepare(uap->clk); + clk_disable_unprepare(uap->clk); out: return retval; } @@ -375,8 +369,7 @@ static void pl010_shutdown(struct uart_port *port) /* * Shut down the clock producer */ - clk_disable(uap->clk); - clk_unprepare(uap->clk); + clk_disable_unprepare(uap->clk); } static void diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 92b1ac8..3322023 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1324,16 +1324,12 @@ static int pl011_startup(struct uart_port *port) "could not set default pins\n"); } - retval = clk_prepare(uap->clk); - if (retval) - goto out; - /* * Try to enable the clock producer. */ - retval = clk_enable(uap->clk); + retval = clk_prepare_enable(uap->clk); if (retval) - goto clk_unprep; + goto out; uap->port.uartclk = clk_get_rate(uap->clk); @@ -1411,9 +1407,7 @@ static int pl011_startup(struct uart_port *port) return 0; clk_dis: - clk_disable(uap->clk); - clk_unprep: - clk_unprepare(uap->clk); + clk_disable_unprepare(uap->clk); out: return retval; } @@ -1473,8 +1467,7 @@ static void pl011_shutdown(struct uart_port *port) /* * Shut down the clock producer */ - clk_disable(uap->clk); - clk_unprepare(uap->clk); + clk_disable_unprepare(uap->clk); /* Optionally let pins go into sleep states */ if (!IS_ERR(uap->pins_sleep)) { retval = pinctrl_select_state(uap->pinctrl, uap->pins_sleep);