From patchwork Fri Oct 4 10:08:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 2987701 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 80C33BFF0B for ; Fri, 4 Oct 2013 10:09:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58B3120451 for ; Fri, 4 Oct 2013 10:09:44 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E37A0203B4 for ; Fri, 4 Oct 2013 10:09:42 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VS2KH-0003A8-0B; Fri, 04 Oct 2013 10:09:37 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VS2KE-000717-1m; Fri, 04 Oct 2013 10:09:34 +0000 Received: from mail-bk0-x22b.google.com ([2a00:1450:4008:c01::22b]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VS2KA-00070C-0q for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2013 10:09:31 +0000 Received: by mail-bk0-f43.google.com with SMTP id mz13so1416077bkb.2 for ; Fri, 04 Oct 2013 03:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=OiCBgtqphck7YSaRyX/R164AlxsGmqYamj5v/pkTq54=; b=qbJGtu0rwlqDtf0YZ5KX3rnHxwpjp4D8NCLm4Y98+DBZiazGZfWv0JcNVVliFoS6Fn lXDdP6vWgKwvuTnJ3i11MqCG7HqroXnoF7115Mfz2vxd2T2u7zJqfvQqqtO4L1vfOthI OkFBUpploHoZztMK9xy55XVbcUPHp3OQNNUO3xGsgcKjW+IuP69DmuYdq7OPBehJr1Yx RbgQ4pr40RggULjWt2OdCbXVcZ9J6Vlu/YvOQWxzLa34cZTVyKLHDEo/eQPDopYH6VJC 54DlKCKuzsfEouInQFsbHcTWXwUaKnmpU9GgTuCskYW7BEBHKMnYdnFpHAfj7qbrdoeX JIbg== X-Received: by 10.204.234.8 with SMTP id ka8mr11894958bkb.5.1380881340004; Fri, 04 Oct 2013 03:09:00 -0700 (PDT) Received: from topkick.lan (dslc-082-083-247-252.pools.arcor-ip.net. [82.83.247.252]) by mx.google.com with ESMTPSA id on10sm7554987bkb.13.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Oct 2013 03:08:59 -0700 (PDT) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH] clk: provide public clk_is_enabled function Date: Fri, 4 Oct 2013 12:08:30 +0200 Message-Id: <1380881310-24345-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131004_060930_248915_B9742D53 X-CRM114-Status: GOOD ( 11.73 ) X-Spam-Score: 1.4 (+) Cc: Andrew Lunn , Russell King , Jason Cooper , Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, Jason Gunthorpe , Ezequiel Garcia , Grant Likely , Mike Turquette , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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=-1.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no 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 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 Tested-by: Andrew Lunn --- Cc: Mike Turquette Cc: Russell King Cc: Jason Cooper Cc: Andrew Lunn Cc: Grant Likely Cc: Benjamin Herrenschmidt Cc: Jason Gunthorpe Cc: Ezequiel Garcia Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- 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 a004769..26698d3 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -929,6 +929,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 9a6d045..8cbf2f7 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -187,6 +187,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 @@ -299,6 +307,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;