Holding a comedi device.. was Re: Race conditions in comedi config?

On Thu, 3 Jul 2003, Frank Mori Hess wrote:

> It does look like a race is possible.  You can't hold a spinlock while
> executing code that may sleep though.  You would need to use a mutex.

Yes you would.. oh so the comedi lock is a spinlock? Yeah you're right it
is.. yeah so maybe if we wanted to avoid this condition we could try a
mutex.

On a related note: basically I am writing a bonding driver to hold two or
more cards together as one logical comedi device (merging the AI and AO
subdevices, and possibly the DIO, but not supporting commands)... I was
wondering what the best approach would be to 'lock' these devices so that
the user can't unconfigure them.  I could increase the module use count on
each of the device's modules, and decrease it once the bonding driver is
unloaded, or I could use comedi_device.use_count, or perhaps set the
comedi_subdevice.busy (or comedi_subdevice.lock) field?  I am not sure
though what these fields mean semantically, and even if I did what the
best approach would be.. how do I most safely do this while cooperating
with comedi_lock() semantics?

Any quick suggestions would be appreciated..  or I should just "use the
source, Luke"?

-Calin

Received on 2003-07-03Z20:24:14