diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2015-06-18 10:54:43 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-06-18 21:19:01 -0700 |
commit | 30f23066424f8fc46e56f41195c51b33fdf36f58 (patch) | |
tree | 198c0283a37adb5a0edd58e438a9568a96d57742 | |
parent | 6e2b126dbda1f874b262fa212cc1cb0c2f6a9fe8 (diff) |
staging: comedi: ni_at_a2150: cleanup a2150_probe()
Make this function return a pointer to the boardinfo instead of an index.
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>
-rw-r--r-- | drivers/staging/comedi/drivers/ni_at_a2150.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 60469bb77ee4..1cd4869d3286 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -687,12 +687,14 @@ static void a2150_free_dma(struct comedi_device *dev) comedi_isadma_free(devpriv->dma); } -/* probes board type, returns offset */ -static int a2150_probe(struct comedi_device *dev) +static const struct a2150_board *a2150_probe(struct comedi_device *dev) { - int status = inw(dev->iobase + STATUS_REG); + int id = ID_BITS(inw(dev->iobase + STATUS_REG)); - return ID_BITS(status); + if (id >= ARRAY_SIZE(a2150_boards)) + return NULL; + + return &a2150_boards[id]; } static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it) @@ -712,12 +714,10 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - i = a2150_probe(dev); - if (i >= ARRAY_SIZE(a2150_boards)) + thisboard = a2150_probe(dev); + if (!thisboard) return -ENODEV; - - dev->board_ptr = a2150_boards + i; - thisboard = dev->board_ptr; + dev->board_ptr = thisboard; dev->board_name = thisboard->name; /* an IRQ and DMA are required to support async commands */ |