Re: [RFC, PATCH 3/3] clk: add warnings for incorrect enable/prepare semantics

From: Jassi Brar
Date: Mon Feb 07 2011 - 01:29:23 EST


On Mon, Feb 7, 2011 at 3:07 PM, Jeremy Kerr <jeremy.kerr@xxxxxxxxxxxxx> wrote:
> 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 <jeremy.kerr@xxxxxxxxxxxxx>
>
> ---
> Â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);
> +

Shouldn't the prepare_count be checked against 0 ?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/