diff options
author | Ian Abbott | 2013-11-08 16:03:28 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2013-11-12 01:16:44 +0100 |
commit | d19db51a0eeb659cd924a9d08b20a2ed4ee46b15 (patch) | |
tree | bed15b7a8d0dd01f0d5dfbffced7e0282c5ae65a /drivers/staging/comedi/comedi_fops.c | |
parent | staging: comedi: wake up async waiters when become non-busy (diff) | |
download | kernel-qcow2-linux-d19db51a0eeb659cd924a9d08b20a2ed4ee46b15.tar.gz kernel-qcow2-linux-d19db51a0eeb659cd924a9d08b20a2ed4ee46b15.tar.xz kernel-qcow2-linux-d19db51a0eeb659cd924a9d08b20a2ed4ee46b15.zip |
staging: comedi: cancel commands before detaching device
The comedi core module's handling of the `COMEDI_DEVCONFIG` ioctl will
not allow a device to be detached if it is busy. However, comedi
devices can also be auto-detached due to a removal of a hardware device.
One of the things we should do in that case is cancel any asynchronous
commands that are running. Add a new function
`comedi_device_cancel_all()` to do that and call it from
`comedi_device_detach()`.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedi_fops.c')
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 9c85f01e847b..eafa18efdeea 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -584,6 +584,21 @@ static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s) return ret; } +void comedi_device_cancel_all(struct comedi_device *dev) +{ + struct comedi_subdevice *s; + int i; + + if (!dev->attached) + return; + + for (i = 0; i < dev->n_subdevices; i++) { + s = &dev->subdevices[i]; + if (s->async) + do_cancel(dev, s); + } +} + static int is_device_busy(struct comedi_device *dev) { struct comedi_subdevice *s; |