diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2013-11-08 15:03:25 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-11 16:16:43 -0800 |
commit | bf11c134246e8f3cfa2582a3d2af84ed7dfd59b6 (patch) | |
tree | b8951e6a59b3aedcac6cc20e4df997aaaf841178 /drivers/staging/comedi/drivers.c | |
parent | 2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 (diff) | |
download | op-kernel-dev-bf11c134246e8f3cfa2582a3d2af84ed7dfd59b6.zip op-kernel-dev-bf11c134246e8f3cfa2582a3d2af84ed7dfd59b6.tar.gz |
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>
Diffstat (limited to 'drivers/staging/comedi/drivers.c')
-rw-r--r-- | drivers/staging/comedi/drivers.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 8f02bf6..c398422 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -133,10 +133,12 @@ static void cleanup_device(struct comedi_device *dev) void comedi_device_detach(struct comedi_device *dev) { + down_write(&dev->attach_lock); dev->attached = false; if (dev->driver) dev->driver->detach(dev); cleanup_device(dev); + up_write(&dev->attach_lock); } static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s) @@ -355,8 +357,9 @@ static int comedi_device_postconfig(struct comedi_device *dev) ret = __comedi_device_postconfig(dev); if (ret < 0) return ret; - smp_wmb(); + down_write(&dev->attach_lock); dev->attached = true; + up_write(&dev->attach_lock); return 0; } |