Thread (126 messages) 126 messages, 18 authors, 2011-04-20

Re: Locking in the clk API, part 2: clk_prepare/clk_unprepare

From: Jassi Brar <jassisinghbrar@gmail.com>
Date: 2011-02-04 11:04:09
Also in: linux-arm-kernel, lkml

On Fri, Feb 4, 2011 at 7:48 PM, Russell King - ARM Linux
[off-list ref] wrote:
int clk_enable(struct clk *clk)
{
       unsigned long flags;
       int ret = 0;

       if (clk) {
               if (WARN_ON(!clk->prepare_count))
                       return -EINVAL;

               spin_lock_irqsave(&clk->lock, flags);
               if (clk->enable_count++ = 0)
                       ret = clk->ops->enable(clk);
               spin_unlock_irqrestore(&clk->lock, flags);
       }
       return ret;
}

is entirely sufficient to catch the case of a single-use clock not being
prepared before clk_enable() is called.

We're after detecting drivers missing calls to clk_prepare(), we're not
after detecting concurrent calls to clk_prepare()/clk_unprepare().
I hope you mean 'making sure the clock is prepared before it's enabled
' rather than
'catching a driver that doesn't do clk_prepare before clk_enable'.
Because, the above implementation still doesn't catch a driver that
doesn't call clk_prepare
but simply uses a clock that happens to have been already prepare'd by
some other
driver or the platform.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help