Commit 74ece108 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: move detach out of post-config

`comedi_device_postconfig()` calls `comedi_device_detach()` on failure.
Remove that call and make the callers of `comedi_device_postconfig()`
call `comedi_device_detach()` themselves if it returns an error.  This
seems more logical as the callers of `comedi_device_postconfig()` called
`comedi_device_detach()` anyway if they didn't call
`comedi_device_postconfig()`.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 016599f5
...@@ -273,7 +273,6 @@ static int comedi_device_postconfig(struct comedi_device *dev) ...@@ -273,7 +273,6 @@ static int comedi_device_postconfig(struct comedi_device *dev)
ret = __comedi_device_postconfig(dev); ret = __comedi_device_postconfig(dev);
if (ret < 0) { if (ret < 0) {
comedi_device_detach(dev);
return ret; return ret;
} }
if (!dev->board_name) { if (!dev->board_name) {
...@@ -385,14 +384,12 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -385,14 +384,12 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
* comedi_error() can be called from attach */ * comedi_error() can be called from attach */
dev->driver = driv; dev->driver = driv;
ret = driv->attach(dev, it); ret = driv->attach(dev, it);
if (ret >= 0)
ret = comedi_device_postconfig(dev);
if (ret < 0) { if (ret < 0) {
comedi_device_detach(dev); comedi_device_detach(dev);
module_put(dev->driver->module); module_put(dev->driver->module);
return ret;
} }
ret = comedi_device_postconfig(dev);
if (ret < 0)
module_put(dev->driver->module);
/* On success, the driver module count has been incremented. */ /* On success, the driver module count has been incremented. */
return ret; return ret;
} }
...@@ -428,10 +425,10 @@ int comedi_auto_config(struct device *hardware_device, ...@@ -428,10 +425,10 @@ int comedi_auto_config(struct device *hardware_device,
comedi_set_hw_dev(comedi_dev, hardware_device); comedi_set_hw_dev(comedi_dev, hardware_device);
comedi_dev->driver = driver; comedi_dev->driver = driver;
ret = driver->auto_attach(comedi_dev, context); ret = driver->auto_attach(comedi_dev, context);
if (ret >= 0)
ret = comedi_device_postconfig(comedi_dev);
if (ret < 0) if (ret < 0)
comedi_device_detach(comedi_dev); comedi_device_detach(comedi_dev);
else
ret = comedi_device_postconfig(comedi_dev);
mutex_unlock(&comedi_dev->mutex); mutex_unlock(&comedi_dev->mutex);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment