diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-03-22 09:44:38 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-25 11:41:51 -0700 |
commit | 370c8e1f76a316ba698d3ef525dd95d83db7b097 (patch) | |
tree | e573a594a144360fb309f8adc12987689c2d9c5f | |
parent | 9bffb75d7510c44ce227d940cd8663df911bc487 (diff) | |
download | blackbird-op-linux-370c8e1f76a316ba698d3ef525dd95d83db7b097.tar.gz blackbird-op-linux-370c8e1f76a316ba698d3ef525dd95d83db7b097.zip |
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: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/ni_labpc.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index ef9a206068fd..94de40b273de 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -1393,8 +1393,7 @@ static int labpc_ao_insn_read(struct comedi_device *dev, return 1; } -static int labpc_dio_mem_callback(int dir, int port, int data, - unsigned long iobase) +static int labpc_8255_mmio(int dir, int port, int data, unsigned long iobase) { if (dir) { writeb(data, (void __iomem *)(iobase + port)); @@ -1802,13 +1801,11 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, /* 8255 dio */ s = &dev->subdevices[2]; - /* if board uses io memory we have to give a custom callback - * function to the 8255 driver */ - if (board->has_mmio) - subdev_8255_init(dev, s, labpc_dio_mem_callback, - (unsigned long)(dev->iobase + DIO_BASE_REG)); - else - subdev_8255_init(dev, s, NULL, dev->iobase + DIO_BASE_REG); + ret = subdev_8255_init(dev, s, + (board->has_mmio) ? labpc_8255_mmio : NULL, + dev->iobase + DIO_BASE_REG); + if (ret) + return ret; /* calibration subdevices for boards that have one */ s = &dev->subdevices[3]; |