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 i;
for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
- if (ni_boards[i].device_id == device_id)
- return i;
+ const struct ni_board_struct *board = &ni_boards[i];
+
+ if (board->device_id == device_id)
+ return board;
}
if (device_id == 255)
dev_err(dev->class_dev, "can't find board\n");
dev_err(dev->class_dev,
"unknown device ID %d -- contact author\n", device_id);
- return -1;
+ return NULL;
}
static int ni_atmio_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
- const struct ni_board_struct *boardtype;
+ const struct ni_board_struct *board;
struct pnp_dev *isapnp_dev;
int ret;
unsigned long iobase;
- int board;
unsigned int irq;
ret = ni_alloc_private(dev);
if (ret)
return ret;
- /* get board type */
-
- board = ni_getboardtype(dev);
- if (board < 0)
- return -EIO;
-
- dev->board_ptr = ni_boards + board;
- boardtype = dev->board_ptr;
- dev->board_name = boardtype->name;
+ board = ni_atmio_probe(dev);
+ if (!board)
+ return -ENODEV;
+ dev->board_ptr = board;
+ dev->board_name = board->name;
/* irq stuff */