staging: comedi: use attach_lock semaphore during attach and detach
authorIan Abbott <abbotti@mev.co.uk>
Fri, 8 Nov 2013 15:03:25 +0000 (15:03 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Nov 2013 00:16:43 +0000 (16:16 -0800)
commitbf11c134246e8f3cfa2582a3d2af84ed7dfd59b6
treeb8951e6a59b3aedcac6cc20e4df997aaaf841178
parent2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1
staging: comedi: use attach_lock semaphore during attach and detach

Acquire the `attach_lock` semaphore in the `struct comedi_device` while
modifying the `attached` flag.  This is a "write" acquire.  Note that
the main mutex in the `struct comedi_device` is also held at this time.
Tasks wishing to check the device is attached will need to either
acquire the main mutex, or "read" acquire the `attach_lock` semaphore,
or both in that order.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers.c