mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-14 12:21:15 -04:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3d9bfccd13
commit
3c6b670d4f
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user