diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2019-04-17 15:39:29 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-04-19 14:33:41 +0200 |
commit | 77c21b626be5b6b30ca6f76ccd5ba1d14a8278a9 (patch) | |
tree | c54dbfaf09078a152b507ef200f8fbc4da9898f8 /drivers/staging/comedi/drivers.c | |
parent | f439696c81fcfe70ad46554fbec1c851bab9345a (diff) |
staging: comedi: Add lockdep_assert_held() calls for dev->mutex
Lots of functions in the core comedi module expect the mutex in `struct
comedi_device` to be held, so add calls to `lockdep_assert_held()` to
check and document that. An unusual case is the calls to
`lockdep_assert_held()` after successful return from
`comedi_alloc_board_minor()` which allocates a `struct comedi_device`
and returns with its mutex locked.
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 | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index b7b9e48d4303..fdf0a5761f9b 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -159,6 +159,7 @@ static void comedi_device_detach_cleanup(struct comedi_device *dev) int i; struct comedi_subdevice *s; + lockdep_assert_held(&dev->mutex); if (dev->subdevices) { for (i = 0; i < dev->n_subdevices; i++) { s = &dev->subdevices[i]; @@ -196,6 +197,7 @@ static void comedi_device_detach_cleanup(struct comedi_device *dev) void comedi_device_detach(struct comedi_device *dev) { + lockdep_assert_held(&dev->mutex); comedi_device_cancel_all(dev); down_write(&dev->attach_lock); dev->attached = false; @@ -643,6 +645,7 @@ static int __comedi_device_postconfig_async(struct comedi_device *dev, unsigned int buf_size; int ret; + lockdep_assert_held(&dev->mutex); if ((s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) == 0) { dev_warn(dev->class_dev, "async subdevices must support SDF_CMD_READ or SDF_CMD_WRITE\n"); @@ -690,6 +693,7 @@ static int __comedi_device_postconfig(struct comedi_device *dev) int ret; int i; + lockdep_assert_held(&dev->mutex); if (!dev->insn_device_config) dev->insn_device_config = insn_device_inval; @@ -747,6 +751,7 @@ static int comedi_device_postconfig(struct comedi_device *dev) { int ret; + lockdep_assert_held(&dev->mutex); ret = __comedi_device_postconfig(dev); if (ret < 0) return ret; @@ -946,6 +951,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) struct comedi_driver *driv; int ret; + lockdep_assert_held(&dev->mutex); if (dev->attached) return -EBUSY; @@ -1053,6 +1059,7 @@ int comedi_auto_config(struct device *hardware_device, return PTR_ERR(dev); } /* Note: comedi_alloc_board_minor() locked dev->mutex. */ + lockdep_assert_held(&dev->mutex); dev->driver = driver; dev->board_name = dev->driver->driver_name; |