Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c6b670d authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman
Browse files

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: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3d9bfccd
Loading
Loading
Loading
Loading
+15 −31
Original line number Diff line number Diff line
@@ -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,11 +1895,6 @@ 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);
@@ -1909,16 +1903,6 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
	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;
	}
}

/*