From patchwork Mon Aug 18 15:30:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 4737651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C0421C0338 for ; Mon, 18 Aug 2014 15:38:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BB2920120 for ; Mon, 18 Aug 2014 15:38:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D48F120114 for ; Mon, 18 Aug 2014 15:38:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJOuG-0004BM-Jn; Mon, 18 Aug 2014 15:31:36 +0000 Received: from mail-la0-x22f.google.com ([2a00:1450:4010:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJOuA-00044g-UG for linux-arm-kernel@lists.infradead.org; Mon, 18 Aug 2014 15:31:34 +0000 Received: by mail-la0-f47.google.com with SMTP id mc6so4626972lab.6 for ; Mon, 18 Aug 2014 08:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0atKoZHFfS6QuOR+0LmOsP3tTAz2VUm6H3j9yihOHSQ=; b=HM2nAmfrMw1atjm/FC8z803pwXOHlXR5LDajuJ/cAObKH19cDxBUqqQ98N0AsJCsOM 5/p6ux3x5+dYt7ZZvtOcw+ixe265dtgCsEy3+bds8wwz7QQhC/1GppskfkFPJRu2seHM lzQizpO9haWAeTPov202iK8/0bWk7ChaOG1dCnDXPopk4/vQg6lnFCaQoQRmWMsjbCsJ r7FRfO4E8+4Cq+jJ6XCTkSBE7Cv+5pCuV1pWRvCb1LgDSxYGqqLH4/ig1l1LchWNU3al Rd+bxuvhyH/aolxx60lnfNlWKkY+fY17e+7kT2ZlLtJLbRRw0BdPhNNlbMxkyxY9zrOg LQjg== X-Received: by 10.152.245.171 with SMTP id xp11mr30798192lac.61.1408375866574; Mon, 18 Aug 2014 08:31:06 -0700 (PDT) Received: from cizrna.lan (37-48-35-72.tmcz.cz. [37.48.35.72]) by mx.google.com with ESMTPSA id q7sm1793990lag.16.2014.08.18.08.31.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Aug 2014 08:31:05 -0700 (PDT) From: Tomeu Vizoso To: Mike Turquette Subject: [PATCH v7 2/8] clk: provide public clk_is_enabled function Date: Mon, 18 Aug 2014 17:30:28 +0200 Message-Id: <1408375833-10703-3-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1408375833-10703-1-git-send-email-tomeu.vizoso@collabora.com> References: <1408375833-10703-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140818_083131_157411_EE6C79DA X-CRM114-Status: GOOD ( 11.42 ) X-Spam-Score: -0.7 (/) Cc: Tomeu Vizoso , Stephen Warren , Tomasz Figa , linux-kernel@vger.kernel.org, Javier Martinez Canillas , rabin@rab.in, Thierry Reding , Peter De Schrijver , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sebastian Hesselbarth To determine if a clk has been previously enabled, provide a public clk_is_enabled function. This is especially helpful to check the state of clk-gate without actually changing the state of the gate. Signed-off-by: Sebastian Hesselbarth Signed-off-by: Tomeu Vizoso --- drivers/clk/clk.c | 18 ++++++++++++++++++ include/linux/clk.h | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b76fa69..bf46d27 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -953,6 +953,24 @@ int clk_enable(struct clk *clk) EXPORT_SYMBOL_GPL(clk_enable); /** + * clk_is_enabled - return the enabled state of a clk + * @clk: the clk whose enabled state gets returned + * + * Returns true if the clock is enabled, false otherwise. + */ +bool clk_is_enabled(struct clk *clk) +{ + bool is_en; + + clk_prepare_lock(); + is_en = __clk_is_enabled(clk); + clk_prepare_unlock(); + + return is_en; +} +EXPORT_SYMBOL_GPL(clk_is_enabled); + +/** * __clk_round_rate - round the given rate for a clk * @clk: round the rate of this clock * @rate: the rate which is to be rounded diff --git a/include/linux/clk.h b/include/linux/clk.h index fb5e097..2cd8d3c 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -218,6 +218,14 @@ int clk_enable(struct clk *clk); void clk_disable(struct clk *clk); /** + * clk_is_enabled - return the enabled state of a clk + * @clk: the clk whose enabled state gets returned + * + * Returns true if the clock is enabled, false otherwise. + */ +bool clk_is_enabled(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 @@ -330,6 +338,11 @@ static inline int clk_enable(struct clk *clk) static inline void clk_disable(struct clk *clk) {} +static inline bool clk_is_enabled(struct clk *clk) +{ + return false; +} + static inline unsigned long clk_get_rate(struct clk *clk) { return 0;