diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2013-04-04 13:59:00 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-05 21:33:19 (GMT) |
commit | db2e3487a5fa1f650680c672e0742d943039d2cc (patch) | |
tree | 7a3df53c74e993431a6dbdb4b4b142f30dba79ff /drivers/staging/comedi/drivers.c | |
parent | 74ece108f9e55e7967d24a61e30f43e3aceb4809 (diff) | |
download | linux-fsl-qoriq-db2e3487a5fa1f650680c672e0742d943039d2cc.tar.xz |
staging: comedi: set hw_dev in comedi_alloc_board_minor()
Call `comedi_set_hw_dev()` to set the `hw_dev` member of `struct
comedi_device` in `comedi_alloc_board_minor()` instead of in
`comedi_auto_config()`. Don't bother to check for an error returned by
`comedi_set_hw_dev()` here; it only fails when changing a non-NULL
pointer to a different non-NULL pointer and since the `struct
comedi_device` has just been allocated and initialized, its `hw_dev`
will be NULL already. Calling `comedi_set_hw_dev()` with a non-NULL
hardware device pointer increments the kref counter for the hardware
device.
If `comedi_alloc_board_minor()` fails further down the function, we rely
on its call to `comedi_device_cleanup()` to call `comedi_clear_hw_dev()`
(via `comedi_device_detach()` and `cleanup_device()`) to clear `hw_dev`
and decrement its kref counter. (That's the "beneficial side-effect"
mentioned in the patch that replaced `__comedi_device_detach()`.)
Remove the call to `comedi_set_hw_dev()` from `comedi_auto_config()` as
the call to `comedi_alloc_board_minor()` does it for us.
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 | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index fe2ad91..81705fb 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -422,7 +422,6 @@ int comedi_auto_config(struct device *hardware_device, return PTR_ERR(comedi_dev); /* Note: comedi_alloc_board_minor() locked comedi_dev->mutex. */ - comedi_set_hw_dev(comedi_dev, hardware_device); comedi_dev->driver = driver; ret = driver->auto_attach(comedi_dev, context); if (ret >= 0) |