diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-01-21 21:37:15 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-21 22:26:20 (GMT) |
commit | 57b71c3e6f4c8b944e6721d89ccb566aee439f97 (patch) | |
tree | 11e46e705fec8630e2f708bbdc79b0843ee730c1 | |
parent | 40f58a65c9f6cbb540ec2db6ac9d963d402014c3 (diff) | |
download | linux-57b71c3e6f4c8b944e6721d89ccb566aee439f97.tar.xz |
staging: comedi: drivers (core): don't BUG_ON due to faulty drivers
The postconfig for drivers that support async commands currently can
BUG_ON if the subdevice was improperly configured by the driver.
Change the BUG_ON so that a dev_warn() is output and the postconfig
returns -EINVAL. This will prevent the comedi core from attaching to
the faulty driver but does not BUG the kernel.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index e5fe2e1..7e8ee5d 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -178,8 +178,16 @@ static int __comedi_device_postconfig_async(struct comedi_device *dev, unsigned int buf_size; int ret; - BUG_ON((s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) == 0); - BUG_ON(!s->do_cmdtest); + 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"); + return -EINVAL; + } + if (!s->do_cmdtest) { + dev_warn(dev->class_dev, + "async subdevices must have a do_cmdtest() function\n"); + return -EINVAL; + } async = kzalloc(sizeof(*async), GFP_KERNEL); if (!async) { |