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

staging: comedi: ni_labpc: fix 8255 dio subdevice init

The subdev_8255_init() function can fail. Check for failure and
return the errno.

Consolidate the mmio/ioport calls to subdev_8255_init(). The callback
function can be added with a simple ? : test and the cast of the iobase
is not necessary.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9bffb75d
...@@ -1393,8 +1393,7 @@ static int labpc_ao_insn_read(struct comedi_device *dev, ...@@ -1393,8 +1393,7 @@ static int labpc_ao_insn_read(struct comedi_device *dev,
return 1; return 1;
} }
static int labpc_dio_mem_callback(int dir, int port, int data, static int labpc_8255_mmio(int dir, int port, int data, unsigned long iobase)
unsigned long iobase)
{ {
if (dir) { if (dir) {
writeb(data, (void __iomem *)(iobase + port)); writeb(data, (void __iomem *)(iobase + port));
...@@ -1802,13 +1801,11 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, ...@@ -1802,13 +1801,11 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
/* 8255 dio */ /* 8255 dio */
s = &dev->subdevices[2]; s = &dev->subdevices[2];
/* if board uses io memory we have to give a custom callback ret = subdev_8255_init(dev, s,
* function to the 8255 driver */ (board->has_mmio) ? labpc_8255_mmio : NULL,
if (board->has_mmio) dev->iobase + DIO_BASE_REG);
subdev_8255_init(dev, s, labpc_dio_mem_callback, if (ret)
(unsigned long)(dev->iobase + DIO_BASE_REG)); return ret;
else
subdev_8255_init(dev, s, NULL, dev->iobase + DIO_BASE_REG);
/* calibration subdevices for boards that have one */ /* calibration subdevices for boards that have one */
s = &dev->subdevices[3]; s = &dev->subdevices[3];
......
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