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

staging: comedi: amplc_dio200: replace macros with inline functions

Replace the IS_ISA_BOARD() and IS_PCI_BOARD() functionlike macros with
inline functions is_isa_board() and is_pci_board().  Also call
is_pci_board() in dio200_find_pci_board() instead of an explicit
comparison operator.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8c3714d6
...@@ -294,9 +294,6 @@ struct dio200_board { ...@@ -294,9 +294,6 @@ struct dio200_board {
enum dio200_layout layout; enum dio200_layout layout;
}; };
#define IS_ISA_BOARD(board) (DO_ISA && (board)->bustype == isa_bustype)
#define IS_PCI_BOARD(board) (DO_PCI && (board)->bustype == pci_bustype)
static const struct dio200_board dio200_boards[] = { static const struct dio200_board dio200_boards[] = {
#if DO_ISA #if DO_ISA
{ {
...@@ -455,6 +452,16 @@ struct dio200_subdev_intr { ...@@ -455,6 +452,16 @@ struct dio200_subdev_intr {
int continuous; int continuous;
}; };
static inline bool is_pci_board(const struct dio200_board *board)
{
return DO_PCI && board->bustype == pci_bustype;
}
static inline bool is_isa_board(const struct dio200_board *board)
{
return DO_ISA && board->bustype == isa_bustype;
}
/* /*
* This function looks for a board matching the supplied PCI device. * This function looks for a board matching the supplied PCI device.
*/ */
...@@ -464,7 +471,7 @@ dio200_find_pci_board(struct pci_dev *pci_dev) ...@@ -464,7 +471,7 @@ dio200_find_pci_board(struct pci_dev *pci_dev)
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(dio200_boards); i++) for (i = 0; i < ARRAY_SIZE(dio200_boards); i++)
if (dio200_boards[i].bustype == pci_bustype && if (is_pci_board(&dio200_boards[i]) &&
pci_dev->device == dio200_boards[i].devid) pci_dev->device == dio200_boards[i].devid)
return &dio200_boards[i]; return &dio200_boards[i];
return NULL; return NULL;
...@@ -1234,10 +1241,10 @@ static void dio200_report_attach(struct comedi_device *dev, unsigned int irq) ...@@ -1234,10 +1241,10 @@ static void dio200_report_attach(struct comedi_device *dev, unsigned int irq)
char tmpbuf[60]; char tmpbuf[60];
int tmplen; int tmplen;
if (IS_ISA_BOARD(thisboard)) if (is_isa_board(thisboard))
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
"(base %#lx) ", dev->iobase); "(base %#lx) ", dev->iobase);
else if (IS_PCI_BOARD(thisboard)) else if (is_pci_board(thisboard))
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
"(pci %s) ", pci_name(pcidev)); "(pci %s) ", pci_name(pcidev));
else else
...@@ -1365,7 +1372,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1365,7 +1372,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
} }
/* Process options and reserve resources according to bus type. */ /* Process options and reserve resources according to bus type. */
if (IS_ISA_BOARD(thisboard)) { if (is_isa_board(thisboard)) {
unsigned long iobase; unsigned long iobase;
unsigned int irq; unsigned int irq;
...@@ -1375,7 +1382,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1375,7 +1382,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret < 0) if (ret < 0)
return ret; return ret;
return dio200_common_attach(dev, iobase, irq, 0); return dio200_common_attach(dev, iobase, irq, 0);
} else if (IS_PCI_BOARD(thisboard)) { } else if (is_pci_board(thisboard)) {
struct pci_dev *pci_dev; struct pci_dev *pci_dev;
pci_dev = dio200_find_pci_dev(dev, it); pci_dev = dio200_find_pci_dev(dev, it);
...@@ -1444,10 +1451,10 @@ static void dio200_detach(struct comedi_device *dev) ...@@ -1444,10 +1451,10 @@ static void dio200_detach(struct comedi_device *dev)
} }
} }
} }
if (IS_ISA_BOARD(thisboard)) { if (is_isa_board(thisboard)) {
if (dev->iobase) if (dev->iobase)
release_region(dev->iobase, DIO200_IO_SIZE); release_region(dev->iobase, DIO200_IO_SIZE);
} else if (IS_PCI_BOARD(thisboard)) { } else if (is_pci_board(thisboard)) {
struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (pcidev) { if (pcidev) {
if (dev->iobase) if (dev->iobase)
......
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