diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2013-06-27 13:50:58 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-23 21:22:29 (GMT) |
commit | c383e2d6dacf0b6fdd40fbaf044e235cac54a20f (patch) | |
tree | 1bef60f78f65ca435ffa515a17314e945613f341 /drivers/staging/comedi/comedi_internal.h | |
parent | 99c0e2691736d56190764bfdc59f11b090cda4ff (diff) | |
download | linux-fsl-qoriq-c383e2d6dacf0b6fdd40fbaf044e235cac54a20f.tar.xz |
staging: comedi: use a mutex when accessing driver list
Low-level comedi drivers registered with the comedi core by
`comedi_driver_register()` are linked together into a simple linked list
headed by the `comedi_drivers` variable and chained by the `next` member
of `struct comedi_driver`. A driver is removed from the list by
`comedi_driver_unregister()`. The driver list is iterated through by
`comedi_device_attach()` when the `COMEDI_DEVCONFIG` ioctl is used to
attach a "legacy" device to a driver, and is also iterated through by
`comedi_read()` in "proc.c" when reading "/proc/comedi".
There is currently no protection against items being added or removed
from the list while it is being iterated. Add a mutex
`comedi_drivers_list_lock` to be locked while adding or removing an item
on the list, or when iterating through the list.
`comedi_driver_unregister()` also checks for and detaches any devices
using the driver. This is currently done before unlinking the driver
from the list, but it makes more sense to unlink the driver from the
list first to prevent `comedi_device_attach()` attempting to use it, so
move the unlinking part to the start of the function. Also, in
`comedi_device_attach()` hold on to the mutex until we've finished
attempting to attach the device to avoid it interfering with the
detachment in `comedi_driver_unregister()`.
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_internal.h')
-rw-r--r-- | drivers/staging/comedi/comedi_internal.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h index d5e03e5..fda1a7b 100644 --- a/drivers/staging/comedi/comedi_internal.h +++ b/drivers/staging/comedi/comedi_internal.h @@ -24,6 +24,7 @@ extern unsigned int comedi_default_buf_maxsize_kb; /* drivers.c */ extern struct comedi_driver *comedi_drivers; +extern struct mutex comedi_drivers_list_lock; int insn_inval(struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, unsigned int *); |