summaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorIan Abbott2013-11-08 16:03:29 +0100
committerGreg Kroah-Hartman2013-11-12 01:16:44 +0100
commitef77c0b2570623f1d72527cb1c6c3f3d3c59793e (patch)
treebb6222077014fb9a924e2fdc4a6ac15a9d3205d5 /drivers/staging
parentstaging: comedi: cancel commands before detaching device (diff)
downloadkernel-qcow2-linux-ef77c0b2570623f1d72527cb1c6c3f3d3c59793e.tar.gz
kernel-qcow2-linux-ef77c0b2570623f1d72527cb1c6c3f3d3c59793e.tar.xz
kernel-qcow2-linux-ef77c0b2570623f1d72527cb1c6c3f3d3c59793e.zip
staging: comedi: add detachment counter for validity checks
Add a member `detach_count` to `struct comedi_device` that is incremented every time the device gets detached. This will be used in some validity checks in the 'read' and 'write' file operations to make sure the attachment remains valid. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/comedi/comedidev.h1
-rw-r--r--drivers/staging/comedi/drivers.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index 70de3558c74e..05cc8dbcd515 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -173,6 +173,7 @@ struct comedi_device {
struct device *class_dev;
int minor;
+ unsigned int detach_count;
/* hw_dev is passed to dma_alloc_coherent when allocating async buffers
* for subdevices that have async_dma_dir set to something other than
* DMA_NONE */
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 4f727731a72d..15b1ab885e77 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -136,6 +136,7 @@ void comedi_device_detach(struct comedi_device *dev)
comedi_device_cancel_all(dev);
down_write(&dev->attach_lock);
dev->attached = false;
+ dev->detach_count++;
if (dev->driver)
dev->driver->detach(dev);
comedi_device_detach_cleanup(dev);