Re: [PATCH 2/2] regmap: Make regmap-mmio usable from differentcontexts

From: Mark Brown
Date: Thu May 23 2013 - 10:32:14 EST

On Thu, May 23, 2013 at 04:20:27PM +0200, Lars-Peter Clausen wrote:
> On 05/23/2013 04:05 PM, Mark Brown wrote:

> > This seems really invasive, why not just have the lock that gets passed
> > in point to a struct which has both the lock and the flags? As far as
> > the core is concerned the lock is just whatever data is required to do
> > the locking, the fact that it's actually two values is an implementation
> > detail of this locking implementation.

> I think that won't work. spin_lock_irqsave() will write to the flags
> parameter before it has successfully taken the look. So if a process running
> on another CPU tries to acquire the the lock while it is already held we'll
> end up overwriting the flags. E.g:

So you'd have to allocate a struct on the stack with a pointer and the
flags in it and initialise the pointer. Not awesome but not the end of
the world.

Attachment: signature.asc
Description: Digital signature