From patchwork Tue Nov 20 09:22:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 1772151 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 388A9DF2AB for ; Tue, 20 Nov 2012 09:24:54 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tak2n-0001NA-IK; Tue, 20 Nov 2012 09:23:03 +0000 Received: from mail-da0-f49.google.com ([209.85.210.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Tak2J-0001Cr-Fu for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2012 09:22:32 +0000 Received: by mail-da0-f49.google.com with SMTP id v40so1487198dad.36 for ; Tue, 20 Nov 2012 01:22:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=uUs/yELvjUo58ygYAxC0TEEtfPfBuTjj9NljjdX2WwI=; b=cx5PR1w1Bor4QHhrYsj0HYeN3zdCwTT9Gdsyx/kW5oLs4EHKVTk4EAvpBzzw6gn3S1 hG5iJNGtvvc1oNzDQUo9D75zrkOMoCN0WK0Go2Kt+/v2S43jvDkohfGlEAfq+seYKGb+ 7HoW2K7T6pyRaD+OMXO8xsPlvm2SmCS9Y4ZwJaXrmsZx0Rhd0YouuZtSM5cPV7ruWnUz lVijVo2KYsNfoTid2fh78jqBw7tP2rDZF3z0yn7QiPUCxsb2Z+jw0nDkGKv2yEAeKQ4j J9paO5PDEkEkVhsk7HzVz2glIPgCT7Wp0kVcY9Xm6dMe1JJz/Gol8P9q4rh8tKaefSov fU4w== Received: by 10.68.234.100 with SMTP id ud4mr40780232pbc.82.1353403350657; Tue, 20 Nov 2012 01:22:30 -0800 (PST) Received: from mailhub.coreip.homeip.net (c-67-188-112-76.hsd1.ca.comcast.net. [67.188.112.76]) by mx.google.com with ESMTPS id kb3sm7779189pbc.27.2012.11.20.01.22.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Nov 2012 01:22:29 -0800 (PST) From: Dmitry Torokhov To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] CLK: uninline clk_prepare_enable() and clk_disable_unprepare() Date: Tue, 20 Nov 2012 01:22:18 -0800 Message-Id: <1353403339-11679-3-git-send-email-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1353403339-11679-1-git-send-email-dmitry.torokhov@gmail.com> References: <1353403339-11679-1-git-send-email-dmitry.torokhov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121120_042231_698865_57B25DA5 X-CRM114-Status: GOOD ( 13.35 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dmitry.torokhov[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Viresh Kumar , Russell King , linux-kernel@vger.kernel.org, Mike Turquette 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 We'll need to invoke clk_disable_unprepare() via a pointer in our devm_* conversion so let's uninline the pair. Signed-off-by: Dmitry Torokhov Reviewed-by: Viresh Kumar --- drivers/clk/clk.c | 23 +++++++++++++++++++++++ include/linux/clk.h | 53 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 1b642f2..69dc7ba 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -561,6 +561,29 @@ int clk_enable(struct clk *clk) } EXPORT_SYMBOL_GPL(clk_enable); +int clk_prepare_enable(struct clk *clk) +{ + int ret; + + ret = clk_prepare(clk); + if (ret) + return ret; + + ret = clk_enable(clk); + if (ret) + clk_unprepare(clk); + + return ret; +} +EXPORT_SYMBOL_GPL(clk_prepare_enable); + +void clk_disable_unprepare(struct clk *clk) +{ + clk_disable(clk); + clk_unprepare(clk); +} +EXPORT_SYMBOL_GPL(clk_disable_unprepare); + /** * __clk_round_rate - round the given rate for a clk * @clk: round the rate of this clock diff --git a/include/linux/clk.h b/include/linux/clk.h index f8204c3..8bf149e 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -172,6 +172,26 @@ int clk_enable(struct clk *clk); void clk_disable(struct clk *clk); /** + * clk_prepare_enable - prepare and enable a clock source + * @clk: clock source + * + * This prepares the clock source for use and enables it. + * + * Must not be called from within atomic context. + */ +int clk_prepare_enable(struct clk *clk); + +/** + * clk_disable_unprepare - disable and undo preparation of a clock source + * @clk: clock source + * + * This disables and undoes a previously prepared clock. + * + * Must not be called from within atomic context. + */ +void clk_disable_unprepare(struct clk *clk); + +/** * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. * This is only valid once the clock source has been enabled. * @clk: clock source @@ -295,6 +315,17 @@ static inline int clk_enable(struct clk *clk) static inline void clk_disable(struct clk *clk) {} +static inline int clk_prepare_enable(struct clk *clk) +{ + might_sleep(); + return 0; +} + +static inline void clk_disable_unprepare(struct clk *clk) +{ + might_sleep(); +} + static inline unsigned long clk_get_rate(struct clk *clk) { return 0; @@ -322,28 +353,6 @@ static inline struct clk *clk_get_parent(struct clk *clk) #endif -/* clk_prepare_enable helps cases using clk_enable in non-atomic context. */ -static inline int clk_prepare_enable(struct clk *clk) -{ - int ret; - - ret = clk_prepare(clk); - if (ret) - return ret; - ret = clk_enable(clk); - if (ret) - clk_unprepare(clk); - - return ret; -} - -/* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */ -static inline void clk_disable_unprepare(struct clk *clk) -{ - clk_disable(clk); - clk_unprepare(clk); -} - /** * clk_add_alias - add a new clock alias * @alias: name for clock alias