Commit e6439a45 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: drivers: propogate errno from subdev_8255_init()

The initialization of the 8255 subdevice can fail due to the allocation
of the private data. Make sure all callers of subdev_8255_init() propogate
the errno.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 52a1c19d
......@@ -1130,10 +1130,12 @@ static int pci_dio_auto_attach(struct comedi_device *dev,
for (i = 0; i < MAX_DIO_SUBDEVG; i++)
for (j = 0; j < this_board->sdio[i].regs; j++) {
s = &dev->subdevices[subdev];
subdev_8255_init(dev, s, NULL,
dev->iobase +
this_board->sdio[i].addr +
SIZE_8255 * j);
ret = subdev_8255_init(dev, s, NULL,
dev->iobase +
this_board->sdio[i].addr +
SIZE_8255 * j);
if (ret)
return ret;
subdev++;
}
......
......@@ -3816,16 +3816,19 @@ static int setup_subdevices(struct comedi_device *dev)
if (thisboard->has_8255) {
if (thisboard->layout == LAYOUT_4020) {
dio_8255_iobase = devpriv->main_iobase + I8255_4020_REG;
subdev_8255_init(dev, s, dio_callback_4020,
(unsigned long)dio_8255_iobase);
ret = subdev_8255_init(dev, s, dio_callback_4020,
(unsigned long)dio_8255_iobase);
} else {
dio_8255_iobase =
devpriv->dio_counter_iobase + DIO_8255_OFFSET;
subdev_8255_init(dev, s, dio_callback,
(unsigned long)dio_8255_iobase);
ret = subdev_8255_init(dev, s, dio_callback,
(unsigned long)dio_8255_iobase);
}
} else
if (ret)
return ret;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
/* 8 channel dio for 60xx */
s = &dev->subdevices[5];
......
......@@ -247,7 +247,9 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev,
s = &dev->subdevices[2];
/* digital i/o subdevice */
subdev_8255_init(dev, s, NULL, iobase_8255);
ret = subdev_8255_init(dev, s, NULL, iobase_8255);
if (ret)
return ret;
dev_info(dev->class_dev, "%s attached\n", dev->board_name);
......
......@@ -529,9 +529,10 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
s = &dev->subdevices[4];
/* 8255 */
if (thisboard->i8255_offset != 0) {
subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase +
thisboard->
i8255_offset));
ret = subdev_8255_init(dev, s, NULL,
dev->iobase + thisboard->i8255_offset);
if (ret)
return ret;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
......
......@@ -723,10 +723,13 @@ static int atmio16d_attach(struct comedi_device *dev,
/* 8255 subdevice */
s = &dev->subdevices[3];
if (board->has_8255)
subdev_8255_init(dev, s, NULL, dev->iobase);
else
if (board->has_8255) {
ret = subdev_8255_init(dev, s, NULL, dev->iobase);
if (ret)
return ret;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
/* don't yet know how to deal with counter/timers */
#if 0
......
......@@ -4292,10 +4292,14 @@ static int ni_E_init(struct comedi_device *dev)
/* 8255 device */
s = &dev->subdevices[NI_8255_DIO_SUBDEV];
if (board->has_8255)
subdev_8255_init(dev, s, ni_8255_callback, (unsigned long)dev);
else
if (board->has_8255) {
ret = subdev_8255_init(dev, s, ni_8255_callback,
(unsigned long)dev);
if (ret)
return ret;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
/* formerly general purpose counter/timer device, but no longer used */
s = &dev->subdevices[NI_UNUSED_SUBDEV];
......
......@@ -225,8 +225,10 @@ static int pcm3724_attach(struct comedi_device *dev,
for (i = 0; i < dev->n_subdevices; i++) {
s = &dev->subdevices[i];
subdev_8255_init(dev, s, subdev_8255_cb,
(unsigned long)(dev->iobase + SIZE_8255 * i));
ret = subdev_8255_init(dev, s, subdev_8255_cb,
dev->iobase + SIZE_8255 * i);
if (ret)
return ret;
s->insn_config = subdev_3724_insn_config;
}
return 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