Commit 1ee02fe1 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_atmio: cleanup ni_getboardtype()

Make this function return a pointer to the boardinfo instead of an index.

For aesthetics, rename the function to ni_atmio_probe().
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e38576ce
...@@ -274,14 +274,16 @@ static int ni_isapnp_find_board(struct pnp_dev **dev) ...@@ -274,14 +274,16 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
return 0; return 0;
} }
static int ni_getboardtype(struct comedi_device *dev) static const struct ni_board_struct *ni_atmio_probe(struct comedi_device *dev)
{ {
int device_id = ni_read_eeprom(dev, 511); int device_id = ni_read_eeprom(dev, 511);
int i; int i;
for (i = 0; i < ARRAY_SIZE(ni_boards); i++) { for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
if (ni_boards[i].device_id == device_id) const struct ni_board_struct *board = &ni_boards[i];
return i;
if (board->device_id == device_id)
return board;
} }
if (device_id == 255) if (device_id == 255)
dev_err(dev->class_dev, "can't find board\n"); dev_err(dev->class_dev, "can't find board\n");
...@@ -292,17 +294,16 @@ static int ni_getboardtype(struct comedi_device *dev) ...@@ -292,17 +294,16 @@ static int ni_getboardtype(struct comedi_device *dev)
dev_err(dev->class_dev, dev_err(dev->class_dev,
"unknown device ID %d -- contact author\n", device_id); "unknown device ID %d -- contact author\n", device_id);
return -1; return NULL;
} }
static int ni_atmio_attach(struct comedi_device *dev, static int ni_atmio_attach(struct comedi_device *dev,
struct comedi_devconfig *it) struct comedi_devconfig *it)
{ {
const struct ni_board_struct *boardtype; const struct ni_board_struct *board;
struct pnp_dev *isapnp_dev; struct pnp_dev *isapnp_dev;
int ret; int ret;
unsigned long iobase; unsigned long iobase;
int board;
unsigned int irq; unsigned int irq;
ret = ni_alloc_private(dev); ret = ni_alloc_private(dev);
...@@ -326,15 +327,11 @@ static int ni_atmio_attach(struct comedi_device *dev, ...@@ -326,15 +327,11 @@ static int ni_atmio_attach(struct comedi_device *dev,
if (ret) if (ret)
return ret; return ret;
/* get board type */ board = ni_atmio_probe(dev);
if (!board)
board = ni_getboardtype(dev); return -ENODEV;
if (board < 0) dev->board_ptr = board;
return -EIO; dev->board_name = board->name;
dev->board_ptr = ni_boards + board;
boardtype = dev->board_ptr;
dev->board_name = boardtype->name;
/* irq stuff */ /* irq stuff */
......
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