Skip to content

Commit

Permalink
staging: comedi: cb_pcimdda: cleanup the 8255 subdevice init
Browse files Browse the repository at this point in the history
The dio_registers variable in the private data is only used to
pass the base address to the 8255 subdevice. Remove the variable
from the private data and pass the value directly to the
subdev_8255_init() function.

Make sure to check the return from subdev_8255_init(). That
function can fail. For aesthetic reasons, rename the local
variable 'err' to 'ret'.

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>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Aug 17, 2012
1 parent 8b00a2f commit ce774ea
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions drivers/staging/comedi/drivers/cb_pcimdda.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ static const struct cb_pcimdda_board cb_pcimdda_boards[] = {
* struct.
*/
struct cb_pcimdda_private {
unsigned long dio_registers;
char attached_to_8255; /* boolean */

#define MAX_AO_READBACK_CHANNELS 6
Expand Down Expand Up @@ -243,11 +242,11 @@ static int cb_pcimdda_attach(struct comedi_device *dev,
struct cb_pcimdda_private *devpriv;
struct pci_dev *pcidev;
struct comedi_subdevice *s;
int err;
int ret;

err = alloc_private(dev, sizeof(*devpriv));
if (err)
return err;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;

pcidev = cb_pcimdda_probe(dev, it);
Expand All @@ -257,15 +256,14 @@ static int cb_pcimdda_attach(struct comedi_device *dev,
thisboard = comedi_board(dev);
dev->board_name = thisboard->name;

err = comedi_pci_enable(pcidev, dev->board_name);
if (err)
return err;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, thisboard->regs_badrindex);
devpriv->dio_registers = dev->iobase + thisboard->dio_offset;

err = comedi_alloc_subdevices(dev, 2);
if (err)
return err;
ret = comedi_alloc_subdevices(dev, 2);
if (ret)
return ret;

s = dev->subdevices + 0;

Expand All @@ -287,11 +285,10 @@ static int cb_pcimdda_attach(struct comedi_device *dev,
if (thisboard->dio_chans) {
switch (thisboard->dio_method) {
case DIO_8255:
/*
* this is a straight 8255, so register us with
* the 8255 driver
*/
subdev_8255_init(dev, s, NULL, devpriv->dio_registers);
ret = subdev_8255_init(dev, s, NULL,
dev->iobase + thisboard->dio_offset);
if (ret)
return ret;
devpriv->attached_to_8255 = 1;
break;
case DIO_INTERNAL:
Expand Down

0 comments on commit ce774ea

Please sign in to comment.