diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2013-04-04 13:58:51 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-05 21:33:17 (GMT) |
commit | 07778393d9a8dbc4b9306d20a8ecfe053771ba93 (patch) | |
tree | 85dfeee58a70d808b837a30e5112ccdaa7fe2b82 /drivers/staging/comedi/drivers.c | |
parent | 7638ffcb50903d9ddbf605c7e9578d72658a960a (diff) | |
download | linux-fsl-qoriq-07778393d9a8dbc4b9306d20a8ecfe053771ba93.tar.xz |
staging: comedi: pre-lock mutex on creation of comedi device
Return from `comedi_alloc_board_minor()` with the mutex of the created
`struct comedi_device` pre-locked. This allows further initialization
by the caller without the worry of something getting in there first.
`comedi_auto_config()` no longer needs to check if the device is already
"attached" since whatever was trying to attach the device would need to
have locked the mutex first.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
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 | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 0b72af8..caadd3b 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -429,11 +429,9 @@ int comedi_auto_config(struct device *hardware_device, comedi_dev = comedi_alloc_board_minor(hardware_device); if (IS_ERR(comedi_dev)) return PTR_ERR(comedi_dev); + /* Note: comedi_alloc_board_minor() locked comedi_dev->mutex. */ - mutex_lock(&comedi_dev->mutex); - if (comedi_dev->attached) - ret = -EBUSY; - else if (!try_module_get(driver->module)) + if (!try_module_get(driver->module)) ret = -EIO; else { comedi_set_hw_dev(comedi_dev, hardware_device); |