From patchwork Tue Nov 15 06:47:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 5126 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 9527423E10 for ; Tue, 15 Nov 2011 06:48:29 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 899CFA18209 for ; Tue, 15 Nov 2011 06:48:29 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id a26so111371faa.11 for ; Mon, 14 Nov 2011 22:48:29 -0800 (PST) Received: by 10.152.134.116 with SMTP id pj20mr16308056lab.5.1321339709403; Mon, 14 Nov 2011 22:48:29 -0800 (PST) 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.152.41.198 with SMTP id h6cs27850lal; Mon, 14 Nov 2011 22:48:29 -0800 (PST) Received: by 10.68.9.130 with SMTP id z2mr40473348pba.35.1321339706480; Mon, 14 Nov 2011 22:48:26 -0800 (PST) Received: from VA3EHSOBE008.bigfish.com (mail-va3.bigfish.com. [216.32.180.10]) by mx.google.com with ESMTPS id d4si29631683pbq.164.2011.11.14.22.48.25 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 14 Nov 2011 22:48:26 -0800 (PST) Received-SPF: neutral (google.com: 216.32.180.10 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) client-ip=216.32.180.10; Authentication-Results: mx.google.com; spf=neutral (google.com: 216.32.180.10 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) smtp.mail=richard.zhao@linaro.org Received: from mail22-va3-R.bigfish.com (10.7.14.249) by VA3EHSOBE008.bigfish.com (10.7.40.28) with Microsoft SMTP Server id 14.1.225.22; Tue, 15 Nov 2011 06:47:54 +0000 Received: from mail22-va3 (localhost [127.0.0.1]) by mail22-va3-R.bigfish.com (Postfix) with ESMTP id 89A2A1C01EB; Tue, 15 Nov 2011 06:50:09 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275dhz2dh87h2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-SS: 0, X-FB-DOMAIN-IP-MATCH: fail Received: from mail22-va3 (localhost.localdomain [127.0.0.1]) by mail22-va3 (MessageSwitch) id 1321339809184001_27028; Tue, 15 Nov 2011 06:50:09 +0000 (UTC) Received: from VA3EHSMHS013.bigfish.com (unknown [10.7.14.244]) by mail22-va3.bigfish.com (Postfix) with ESMTP id 221C3600043; Tue, 15 Nov 2011 06:50:09 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS013.bigfish.com (10.7.99.23) with Microsoft SMTP Server (TLS) id 14.1.225.22; Tue, 15 Nov 2011 06:47:53 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server id 14.1.339.2; Tue, 15 Nov 2011 00:48:22 -0600 Received: from b20223-02.ap.freescale.net (b20223-02.ap.freescale.net [10.192.242.124]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id pAF6mDVJ025706; Tue, 15 Nov 2011 00:48:19 -0600 (CST) From: Richard Zhao To: , , , , CC: , , , , , , , Subject: [PATCH V4 01/14] clk: add helper functions clk_prepare_enable and clk_disable_unprepare Date: Tue, 15 Nov 2011 14:47:56 +0800 Message-ID: <1321339689-25256-2-git-send-email-richard.zhao@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1321339689-25256-1-git-send-email-richard.zhao@linaro.org> References: <1321339689-25256-1-git-send-email-richard.zhao@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com It's for migrating to generic clk framework API. The helper functions help cases clk_enable/clk_disable is used in non-atomic context. For example, Call clk_enable in probe and clk_disable in remove. Signed-off-by: Richard Zhao --- include/linux/clk.h | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/include/linux/clk.h b/include/linux/clk.h index 7213b52..b9d46fa 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -107,6 +107,28 @@ static inline void clk_unprepare(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_get_rate - obtain the current clock rate (in Hz) for a clock source. * This is only valid once the clock source has been enabled.