aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/amplc_pc263.c
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2012-08-16 11:14:18 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-16 11:33:16 -0700
commitd26769446f5389fa5dd5b8745ddc12d4371fc267 (patch)
treebfd75fa3d29c65904ac21aa84180e34ae740b8f5 /drivers/staging/comedi/drivers/amplc_pc263.c
parent00d7a906cdd05b76b059102cacf98cfb853fa109 (diff)
staging: comedi: amplc_pc263: 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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/amplc_pc263.c')
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc263.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c
index 40ec1ffebba..a389aea4d2a 100644
--- a/drivers/staging/comedi/drivers/amplc_pc263.c
+++ b/drivers/staging/comedi/drivers/amplc_pc263.c
@@ -93,6 +93,20 @@ static const struct pc263_board pc263_boards[] = {
#endif
};
+/* test if ISA supported and this is an ISA board */
+static inline bool is_isa_board(const struct pc263_board *board)
+{
+ return IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA)
+ && board->bustype == isa_bustype;
+}
+
+/* test if PCI supported and this is a PCI board */
+static inline bool is_pci_board(const struct pc263_board *board)
+{
+ return IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI)
+ && board->bustype == pci_bustype;
+}
+
/*
* This function looks for a board matching the supplied PCI device.
*/
@@ -101,7 +115,7 @@ static const struct pc263_board *pc263_find_pci_board(struct pci_dev *pci_dev)
unsigned int i;
for (i = 0; i < ARRAY_SIZE(pc263_boards); i++)
- if (pc263_boards[i].bustype == pci_bustype &&
+ if (is_pci_board(&pc263_boards[i]) &&
pci_dev->device == pc263_boards[i].devid)
return &pc263_boards[i];
return NULL;
@@ -187,11 +201,9 @@ static void pc263_report_attach(struct comedi_device *dev)
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
char tmpbuf[40];
- if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) &&
- thisboard->bustype == isa_bustype)
+ if (is_isa_board(thisboard))
snprintf(tmpbuf, sizeof(tmpbuf), "(base %#lx) ", dev->iobase);
- else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) &&
- thisboard->bustype == pci_bustype)
+ else if (is_pci_board(thisboard))
snprintf(tmpbuf, sizeof(tmpbuf), "(pci %s) ",
pci_name(pcidev));
else
@@ -259,15 +271,13 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev_info(dev->class_dev, PC263_DRIVER_NAME ": attach\n");
/* Process options and reserve resources according to bus type. */
- if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) &&
- thisboard->bustype == isa_bustype) {
+ if (is_isa_board(thisboard)) {
unsigned long iobase = it->options[0];
ret = pc263_request_region(dev, iobase, PC263_IO_SIZE);
if (ret < 0)
return ret;
return pc263_common_attach(dev, iobase);
- } else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) &&
- thisboard->bustype == pci_bustype) {
+ } else if (is_pci_board(thisboard)) {
struct pci_dev *pci_dev;
pci_dev = pc263_find_pci_dev(dev, it);