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

staging: comedi: comedi_bond: return error code in do_dev_config()

Change `do_dev_config()` to return an error code on failure and 0 on
success, instead of 0 on failure and 1 on success.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a7e240a4
...@@ -209,17 +209,17 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -209,17 +209,17 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
if (minor < 0 || minor >= COMEDI_NUM_BOARD_MINORS) { if (minor < 0 || minor >= COMEDI_NUM_BOARD_MINORS) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"Minor %d is invalid!\n", minor); "Minor %d is invalid!\n", minor);
return 0; return -EINVAL;
} }
if (minor == dev->minor) { if (minor == dev->minor) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"Cannot bond this driver to itself!\n"); "Cannot bond this driver to itself!\n");
return 0; return -EINVAL;
} }
if (devs_opened[minor]) { if (devs_opened[minor]) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"Minor %d specified more than once!\n", minor); "Minor %d specified more than once!\n", minor);
return 0; return -EINVAL;
} }
snprintf(file, sizeof(file), "/dev/comedi%u", minor); snprintf(file, sizeof(file), "/dev/comedi%u", minor);
...@@ -230,7 +230,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -230,7 +230,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
if (!d) { if (!d) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"Minor %u could not be opened\n", minor); "Minor %u could not be opened\n", minor);
return 0; return -ENODEV;
} }
/* Do DIO, as that's all we support now.. */ /* Do DIO, as that's all we support now.. */
...@@ -241,11 +241,11 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -241,11 +241,11 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
dev_err(dev->class_dev, dev_err(dev->class_dev,
"comedi_get_n_channels() returned %d on minor %u subdev %d!\n", "comedi_get_n_channels() returned %d on minor %u subdev %d!\n",
nchans, minor, sdev); nchans, minor, sdev);
return 0; return -EINVAL;
} }
bdev = kmalloc(sizeof(*bdev), GFP_KERNEL); bdev = kmalloc(sizeof(*bdev), GFP_KERNEL);
if (!bdev) if (!bdev)
return 0; return -ENOMEM;
bdev->dev = d; bdev->dev = d;
bdev->minor = minor; bdev->minor = minor;
...@@ -272,7 +272,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -272,7 +272,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
if (!devpriv->devs) { if (!devpriv->devs) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"Could not allocate memory. Out of memory?\n"); "Could not allocate memory. Out of memory?\n");
return 0; return -ENOMEM;
} }
devpriv->devs[devpriv->ndevs - 1] = bdev; devpriv->devs[devpriv->ndevs - 1] = bdev;
...@@ -292,10 +292,10 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -292,10 +292,10 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
if (!devpriv->nchans) { if (!devpriv->nchans) {
dev_err(dev->class_dev, "No channels found!\n"); dev_err(dev->class_dev, "No channels found!\n");
return 0; return -EINVAL;
} }
return 1; return 0;
} }
static int bonding_attach(struct comedi_device *dev, static int bonding_attach(struct comedi_device *dev,
...@@ -312,8 +312,9 @@ static int bonding_attach(struct comedi_device *dev, ...@@ -312,8 +312,9 @@ static int bonding_attach(struct comedi_device *dev,
/* /*
* Setup our bonding from config params.. sets up our private struct.. * Setup our bonding from config params.. sets up our private struct..
*/ */
if (!do_dev_config(dev, it)) ret = do_dev_config(dev, it);
return -EINVAL; if (ret)
return ret;
dev->board_name = devpriv->name; dev->board_name = devpriv->name;
......
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