Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752523Ab1BGGJA (ORCPT ); Mon, 7 Feb 2011 01:09:00 -0500 Received: from ozlabs.org ([203.10.76.45]:35571 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752103Ab1BGGI3 (ORCPT ); Mon, 7 Feb 2011 01:08:29 -0500 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [RFC, PATCH 3/3] clk: add warnings for incorrect enable/prepare semantics Message-Id: <1297058877.800990.238556019385.3.gpush@pororo> In-Reply-To: <201102011711.31258.jeremy.kerr@canonical.com> To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Nicolas Pitre , Dima Zavin , Lorenzo Pieralisi , Vincent Guittot , , Ben Herrenschmidt , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Sascha Hauer , Paul Mundt , Saravana Kannan , Ben Dooks , Jeremy Kerr , Russell King From: Jeremy Kerr Date: Mon, 07 Feb 2011 14:07:57 +0800 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1186 Lines: 42 This change adds warnings to check for: 1) enabling a clock that hasn't been prepared; and 2) unpreparing a clock that is still enabled While the correctness can't be guaranteed, these warnings should cover most situations. Signed-off-by: Jeremy Kerr --- drivers/clk/clk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 51dbd33..2369959 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -35,6 +35,8 @@ void clk_unprepare(struct clk *clk) if (!clk->ops->unprepare) return; + WARN_ON(clk->enable_count); + mutex_lock(&clk->prepare_lock); if (--clk->prepare_count == 0) clk->ops->unprepare(clk); @@ -50,6 +52,8 @@ int clk_enable(struct clk *clk) if (!clk->ops->enable) return 0; + WARN_ON(clk->ops->prepare && clk->prepare_count); + spin_lock(&clk->enable_lock); if (!clk->enable_count) ret = clk->ops->enable(clk); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/