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@xxxxxxxxx> --- drivers/staging/comedi/comedidev.h | 1 + drivers/staging/comedi/drivers.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 70de355..05cc8db 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 4f72773..15b1ab8 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); -- 1.8.4.2 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel