Commit 9bfdd962 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: das08: Add helper functions to check bus type

Add inline helper function `is_isa_board(board)` to check if the driver
supports ISA boards and this is an ISA board, and `is_pci_board(board)`
to check if the driver supports PCI boards and this is a PCI board.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7c2b2315
...@@ -236,6 +236,16 @@ static const int *const das08_gainlists[] = { ...@@ -236,6 +236,16 @@ static const int *const das08_gainlists[] = {
das08_pgm_gainlist, das08_pgm_gainlist,
}; };
static inline bool is_isa_board(const struct das08_board_struct *board)
{
return IS_ENABLED(CONFIG_COMEDI_DAS08_ISA) && board->bustype == isa;
}
static inline bool is_pci_board(const struct das08_board_struct *board)
{
return IS_ENABLED(CONFIG_COMEDI_DAS08_PCI) && board->bustype == pci;
}
#define TIMEOUT 100000 #define TIMEOUT 100000
static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
...@@ -757,7 +767,7 @@ das08_find_pci_board(struct pci_dev *pdev) ...@@ -757,7 +767,7 @@ das08_find_pci_board(struct pci_dev *pdev)
#if DO_COMEDI_DRIVER_REGISTER #if DO_COMEDI_DRIVER_REGISTER
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(das08_boards); i++) for (i = 0; i < ARRAY_SIZE(das08_boards); i++)
if (das08_boards[i].bustype == pci && if (is_pci_board(&das08_boards[i]) &&
pdev->device == das08_boards[i].id) pdev->device == das08_boards[i].id)
return &das08_boards[i]; return &das08_boards[i];
#endif #endif
...@@ -817,13 +827,12 @@ das08_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -817,13 +827,12 @@ das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv = dev->private; devpriv = dev->private;
dev_info(dev->class_dev, "attach\n"); dev_info(dev->class_dev, "attach\n");
if (IS_ENABLED(CONFIG_COMEDI_DAS08_PCI) && thisboard->bustype == pci) { if (is_pci_board(thisboard)) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"Manual configuration of PCI board '%s' is not supported\n", "Manual configuration of PCI board '%s' is not supported\n",
thisboard->name); thisboard->name);
return -EIO; return -EIO;
} else if (IS_ENABLED(CONFIG_COMEDI_DAS08_ISA) && } else if (is_isa_board(thisboard)) {
thisboard->bustype == isa) {
iobase = it->options[0]; iobase = it->options[0];
dev_info(dev->class_dev, "iobase 0x%lx\n", iobase); dev_info(dev->class_dev, "iobase 0x%lx\n", iobase);
if (!request_region(iobase, thisboard->iosize, DRV_NAME)) { if (!request_region(iobase, thisboard->iosize, DRV_NAME)) {
...@@ -848,11 +857,10 @@ static void __maybe_unused das08_detach(struct comedi_device *dev) ...@@ -848,11 +857,10 @@ static void __maybe_unused das08_detach(struct comedi_device *dev)
struct das08_private_struct *devpriv = dev->private; struct das08_private_struct *devpriv = dev->private;
das08_common_detach(dev); das08_common_detach(dev);
if (IS_ENABLED(CONFIG_COMEDI_DAS08_ISA) && thisboard->bustype == isa) { if (is_isa_board(thisboard)) {
if (dev->iobase) if (dev->iobase)
release_region(dev->iobase, thisboard->iosize); release_region(dev->iobase, thisboard->iosize);
} else if (IS_ENABLED(CONFIG_COMEDI_DAS08_PCI) && } else if (is_pci_board(thisboard)) {
thisboard->bustype == pci) {
if (devpriv && devpriv->pdev) { if (devpriv && devpriv->pdev) {
if (dev->iobase) if (dev->iobase)
comedi_pci_disable(devpriv->pdev); comedi_pci_disable(devpriv->pdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment