aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2015-06-18 13:54:58 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-06-19 00:19:04 -0400
commit1ee02fe1a100f57a2d35e78c38d22dedddc52ff4 (patch)
tree319083dfd2b59beac821afd7a9447c5bc2e0fa53 /drivers/staging
parente38576ce7301ddd5e39b969e3f2a136002fb429d (diff)
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.c27
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)
274 return 0; 274 return 0;
275} 275}
276 276
277static int ni_getboardtype(struct comedi_device *dev) 277static const struct ni_board_struct *ni_atmio_probe(struct comedi_device *dev)
278{ 278{
279 int device_id = ni_read_eeprom(dev, 511); 279 int device_id = ni_read_eeprom(dev, 511);
280 int i; 280 int i;
281 281
282 for (i = 0; i < ARRAY_SIZE(ni_boards); i++) { 282 for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
283 if (ni_boards[i].device_id == device_id) 283 const struct ni_board_struct *board = &ni_boards[i];
284 return i; 284
285 if (board->device_id == device_id)
286 return board;
285 } 287 }
286 if (device_id == 255) 288 if (device_id == 255)
287 dev_err(dev->class_dev, "can't find board\n"); 289 dev_err(dev->class_dev, "can't find board\n");
@@ -292,17 +294,16 @@ static int ni_getboardtype(struct comedi_device *dev)
292 dev_err(dev->class_dev, 294 dev_err(dev->class_dev,
293 "unknown device ID %d -- contact author\n", device_id); 295 "unknown device ID %d -- contact author\n", device_id);
294 296
295 return -1; 297 return NULL;
296} 298}
297 299
298static int ni_atmio_attach(struct comedi_device *dev, 300static int ni_atmio_attach(struct comedi_device *dev,
299 struct comedi_devconfig *it) 301 struct comedi_devconfig *it)
300{ 302{
301 const struct ni_board_struct *boardtype; 303 const struct ni_board_struct *board;
302 struct pnp_dev *isapnp_dev; 304 struct pnp_dev *isapnp_dev;
303 int ret; 305 int ret;
304 unsigned long iobase; 306 unsigned long iobase;
305 int board;
306 unsigned int irq; 307 unsigned int irq;
307 308
308 ret = ni_alloc_private(dev); 309 ret = ni_alloc_private(dev);
@@ -326,15 +327,11 @@ static int ni_atmio_attach(struct comedi_device *dev,
326 if (ret) 327 if (ret)
327 return ret; 328 return ret;
328 329
329 /* get board type */ 330 board = ni_atmio_probe(dev);
330 331 if (!board)
331 board = ni_getboardtype(dev); 332 return -ENODEV;
332 if (board < 0) 333 dev->board_ptr = board;
333 return -EIO; 334 dev->board_name = board->name;
334
335 dev->board_ptr = ni_boards + board;
336 boardtype = dev->board_ptr;
337 dev->board_name = boardtype->name;
338 335
339 /* irq stuff */ 336 /* irq stuff */
340 337