summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/amplc_dio200.c
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2013-03-18 17:18:59 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-25 11:30:05 -0700
commit3c6b670d4fa1c811f80a11aa4a3b68ea257a7179 (patch)
treebdf357885c0576b5fce9c536c4d43f05a6b959f6 /drivers/staging/comedi/drivers/amplc_dio200.c
parent3d9bfccd13252efffbe2f31e8e66cecfd9e6cc65 (diff)
staging: comedi: amplc_dio200: don't check bus type in attach
Since the legacy attach routine `dio200_attach()` is only called for board names matching an entry in our array of ISA boards `dio200_isa_boards[]`, and it is reasonable to expect all elements of `dio200_isa_boards[]` to have their `bustype` member initialized correctly to `isa_bustype`, don't bother checking the bus type in `dio200_attach()`. Add `if (!DO_ISA) return -EINVAL` to optimize out the remainder of the function if `CONFIG_COMEDI_AMPLC_DIO200_ISA` is not defined. Similarly, don't bother checking the bus type in `dio200_find_pci_board()` as it is reasonable to expect all elements of `dio200_pci_boards[]` to have their `bustype` member initialized correctly to `pci_bustype`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/amplc_dio200.c')
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200.c46
1 files changed, 15 insertions, 31 deletions
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c
index 8fa8fecf64bb..a0e894af1e95 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200.c
@@ -741,8 +741,7 @@ dio200_find_pci_board(struct pci_dev *pci_dev)
unsigned int i;
for (i = 0; i < ARRAY_SIZE(dio200_pci_boards); i++)
- if (is_pci_board(&dio200_pci_boards[i]) &&
- pci_dev->device == dio200_pci_boards[i].devid)
+ if (pci_dev->device == dio200_pci_boards[i].devid)
return &dio200_pci_boards[i];
return NULL;
}
@@ -1877,18 +1876,18 @@ static int dio200_common_attach(struct comedi_device *dev, unsigned int irq,
return 1;
}
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
+/* Only called for ISA boards. */
static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct dio200_board *thisboard = comedi_board(dev);
struct dio200_private *devpriv;
+ unsigned long iobase;
+ unsigned int irq;
int ret;
+ if (!DO_ISA)
+ return -EINVAL;
+
dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach\n");
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
@@ -1896,29 +1895,14 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return -ENOMEM;
dev->private = devpriv;
- /* Process options and reserve resources according to bus type. */
- if (is_isa_board(thisboard)) {
- unsigned long iobase;
- unsigned int irq;
-
- iobase = it->options[0];
- irq = it->options[1];
- ret = dio200_request_region(dev, iobase, thisboard->mainsize);
- if (ret < 0)
- return ret;
- devpriv->io.u.iobase = iobase;
- devpriv->io.regtype = io_regtype;
- return dio200_common_attach(dev, irq, 0);
- } else if (is_pci_board(thisboard)) {
- dev_err(dev->class_dev,
- "Manual configuration of PCI board '%s' is not supported\n",
- thisboard->name);
- return -EIO;
- } else {
- dev_err(dev->class_dev, DIO200_DRIVER_NAME
- ": BUG! cannot determine board type!\n");
- return -EINVAL;
- }
+ iobase = it->options[0];
+ irq = it->options[1];
+ ret = dio200_request_region(dev, iobase, thisboard->mainsize);
+ if (ret < 0)
+ return ret;
+ devpriv->io.u.iobase = iobase;
+ devpriv->io.regtype = io_regtype;
+ return dio200_common_attach(dev, irq, 0);
}
/*