diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2015-06-18 20:54:58 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-06-19 07:19:04 +0300 |
commit | 1ee02fe1a100f57a2d35e78c38d22dedddc52ff4 (patch) | |
tree | 319083dfd2b59beac821afd7a9447c5bc2e0fa53 /drivers/staging | |
parent | e38576ce7301ddd5e39b969e3f2a136002fb429d (diff) | |
download | linux-1ee02fe1a100f57a2d35e78c38d22dedddc52ff4.tar.xz |
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: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/comedi/drivers/ni_atmio.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c index 1304b06980a6..95435b81aa55 100644 --- a/drivers/staging/comedi/drivers/ni_atmio.c +++ b/drivers/staging/comedi/drivers/ni_atmio.c @@ -274,14 +274,16 @@ static int ni_isapnp_find_board(struct pnp_dev **dev) 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"); @@ -292,17 +294,16 @@ static int ni_getboardtype(struct comedi_device *dev) 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); @@ -326,15 +327,11 @@ static int ni_atmio_attach(struct comedi_device *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 */ |