diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-05-22 20:09:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-04 23:30:03 -0400 |
commit | 3cb08e08fbeab09fa5f3ba1cf27176dd41f5b70f (patch) | |
tree | 03689a7002b188d1152b2510ec1c1f4190462279 | |
parent | 240c6e6a7125fd7a6ebcbdd8fbbf646df0f69186 (diff) |
staging: comedi: remove this_board macro in the pcl812 driver
The 'this_board' macro depends on having a local variable with
a magic name. The CodingStyle document suggests not doing this
to avoid confusion. Remove the macro and use the comedi_board()
inline helper to get the dev->board_ptr information.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/pcl812.c | 98 |
1 files changed, 51 insertions, 47 deletions
diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 51f4ca9f7927..28780ede1ee5 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c | |||
@@ -336,8 +336,6 @@ struct pcl812_board { | |||
336 | unsigned char haveMPC508; /* 1=board use MPC508A multiplexor */ | 336 | unsigned char haveMPC508; /* 1=board use MPC508A multiplexor */ |
337 | }; | 337 | }; |
338 | 338 | ||
339 | #define this_board ((const struct pcl812_board *)dev->board_ptr) | ||
340 | |||
341 | struct pcl812_private { | 339 | struct pcl812_private { |
342 | 340 | ||
343 | unsigned char valid; /* =1 device is OK */ | 341 | unsigned char valid; /* =1 device is OK */ |
@@ -560,6 +558,7 @@ static void pcl812_cmdtest_out(int e, struct comedi_cmd *cmd) | |||
560 | static int pcl812_ai_cmdtest(struct comedi_device *dev, | 558 | static int pcl812_ai_cmdtest(struct comedi_device *dev, |
561 | struct comedi_subdevice *s, struct comedi_cmd *cmd) | 559 | struct comedi_subdevice *s, struct comedi_cmd *cmd) |
562 | { | 560 | { |
561 | const struct pcl812_board *board = comedi_board(dev); | ||
563 | int err = 0; | 562 | int err = 0; |
564 | int tmp, divisor1, divisor2; | 563 | int tmp, divisor1, divisor2; |
565 | 564 | ||
@@ -666,8 +665,8 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, | |||
666 | } | 665 | } |
667 | 666 | ||
668 | if (cmd->convert_src == TRIG_TIMER) { | 667 | if (cmd->convert_src == TRIG_TIMER) { |
669 | if (cmd->convert_arg < this_board->ai_ns_min) { | 668 | if (cmd->convert_arg < board->ai_ns_min) { |
670 | cmd->convert_arg = this_board->ai_ns_min; | 669 | cmd->convert_arg = board->ai_ns_min; |
671 | err++; | 670 | err++; |
672 | } | 671 | } |
673 | } else { /* TRIG_EXT */ | 672 | } else { /* TRIG_EXT */ |
@@ -682,7 +681,7 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, | |||
682 | err++; | 681 | err++; |
683 | } | 682 | } |
684 | if (cmd->chanlist_len > MAX_CHANLIST_LEN) { | 683 | if (cmd->chanlist_len > MAX_CHANLIST_LEN) { |
685 | cmd->chanlist_len = this_board->n_aichan; | 684 | cmd->chanlist_len = board->n_aichan; |
686 | err++; | 685 | err++; |
687 | } | 686 | } |
688 | if (cmd->scan_end_arg != cmd->chanlist_len) { | 687 | if (cmd->scan_end_arg != cmd->chanlist_len) { |
@@ -715,11 +714,11 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, | |||
715 | 714 | ||
716 | if (cmd->convert_src == TRIG_TIMER) { | 715 | if (cmd->convert_src == TRIG_TIMER) { |
717 | tmp = cmd->convert_arg; | 716 | tmp = cmd->convert_arg; |
718 | i8253_cascade_ns_to_timer(this_board->i8254_osc_base, &divisor1, | 717 | i8253_cascade_ns_to_timer(board->i8254_osc_base, &divisor1, |
719 | &divisor2, &cmd->convert_arg, | 718 | &divisor2, &cmd->convert_arg, |
720 | cmd->flags & TRIG_ROUND_MASK); | 719 | cmd->flags & TRIG_ROUND_MASK); |
721 | if (cmd->convert_arg < this_board->ai_ns_min) | 720 | if (cmd->convert_arg < board->ai_ns_min) |
722 | cmd->convert_arg = this_board->ai_ns_min; | 721 | cmd->convert_arg = board->ai_ns_min; |
723 | if (tmp != cmd->convert_arg) | 722 | if (tmp != cmd->convert_arg) |
724 | err++; | 723 | err++; |
725 | } | 724 | } |
@@ -741,6 +740,7 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, | |||
741 | */ | 740 | */ |
742 | static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) | 741 | static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) |
743 | { | 742 | { |
743 | const struct pcl812_board *board = comedi_board(dev); | ||
744 | unsigned int divisor1 = 0, divisor2 = 0, i, dma_flags, bytes; | 744 | unsigned int divisor1 = 0, divisor2 = 0, i, dma_flags, bytes; |
745 | struct comedi_cmd *cmd = &s->async->cmd; | 745 | struct comedi_cmd *cmd = &s->async->cmd; |
746 | 746 | ||
@@ -767,9 +767,9 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) | |||
767 | return -EINVAL; | 767 | return -EINVAL; |
768 | 768 | ||
769 | if (cmd->convert_src == TRIG_TIMER) { | 769 | if (cmd->convert_src == TRIG_TIMER) { |
770 | if (cmd->convert_arg < this_board->ai_ns_min) | 770 | if (cmd->convert_arg < board->ai_ns_min) |
771 | cmd->convert_arg = this_board->ai_ns_min; | 771 | cmd->convert_arg = board->ai_ns_min; |
772 | i8253_cascade_ns_to_timer(this_board->i8254_osc_base, | 772 | i8253_cascade_ns_to_timer(board->i8254_osc_base, |
773 | &divisor1, &divisor2, | 773 | &divisor1, &divisor2, |
774 | &cmd->convert_arg, | 774 | &cmd->convert_arg, |
775 | cmd->flags & TRIG_ROUND_MASK); | 775 | cmd->flags & TRIG_ROUND_MASK); |
@@ -1192,6 +1192,7 @@ static void start_pacer(struct comedi_device *dev, int mode, | |||
1192 | */ | 1192 | */ |
1193 | static void free_resources(struct comedi_device *dev) | 1193 | static void free_resources(struct comedi_device *dev) |
1194 | { | 1194 | { |
1195 | const struct pcl812_board *board = comedi_board(dev); | ||
1195 | 1196 | ||
1196 | if (dev->private) { | 1197 | if (dev->private) { |
1197 | if (devpriv->dmabuf[0]) | 1198 | if (devpriv->dmabuf[0]) |
@@ -1204,7 +1205,7 @@ static void free_resources(struct comedi_device *dev) | |||
1204 | if (dev->irq) | 1205 | if (dev->irq) |
1205 | free_irq(dev->irq, dev); | 1206 | free_irq(dev->irq, dev); |
1206 | if (dev->iobase) | 1207 | if (dev->iobase) |
1207 | release_region(dev->iobase, this_board->io_range); | 1208 | release_region(dev->iobase, board->io_range); |
1208 | } | 1209 | } |
1209 | 1210 | ||
1210 | /* | 1211 | /* |
@@ -1234,6 +1235,8 @@ static int pcl812_ai_cancel(struct comedi_device *dev, | |||
1234 | */ | 1235 | */ |
1235 | static void pcl812_reset(struct comedi_device *dev) | 1236 | static void pcl812_reset(struct comedi_device *dev) |
1236 | { | 1237 | { |
1238 | const struct pcl812_board *board = comedi_board(dev); | ||
1239 | |||
1237 | #ifdef PCL812_EXTDEBUG | 1240 | #ifdef PCL812_EXTDEBUG |
1238 | printk(KERN_DEBUG "pcl812 EDBG: BGN: pcl812_reset(...)\n"); | 1241 | printk(KERN_DEBUG "pcl812 EDBG: BGN: pcl812_reset(...)\n"); |
1239 | #endif | 1242 | #endif |
@@ -1242,7 +1245,7 @@ static void pcl812_reset(struct comedi_device *dev) | |||
1242 | devpriv->old_chan_reg = -1; /* invalidate chain/gain memory */ | 1245 | devpriv->old_chan_reg = -1; /* invalidate chain/gain memory */ |
1243 | devpriv->old_gain_reg = -1; | 1246 | devpriv->old_gain_reg = -1; |
1244 | 1247 | ||
1245 | switch (this_board->board_type) { | 1248 | switch (board->board_type) { |
1246 | case boardPCL812PG: | 1249 | case boardPCL812PG: |
1247 | case boardPCL812: | 1250 | case boardPCL812: |
1248 | case boardACL8112: | 1251 | case boardACL8112: |
@@ -1273,6 +1276,7 @@ static void pcl812_reset(struct comedi_device *dev) | |||
1273 | 1276 | ||
1274 | static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) | 1277 | static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) |
1275 | { | 1278 | { |
1279 | const struct pcl812_board *board = comedi_board(dev); | ||
1276 | int ret, subdev; | 1280 | int ret, subdev; |
1277 | unsigned long iobase; | 1281 | unsigned long iobase; |
1278 | unsigned int irq; | 1282 | unsigned int irq; |
@@ -1283,9 +1287,9 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
1283 | 1287 | ||
1284 | iobase = it->options[0]; | 1288 | iobase = it->options[0]; |
1285 | printk(KERN_INFO "comedi%d: pcl812: board=%s, ioport=0x%03lx", | 1289 | printk(KERN_INFO "comedi%d: pcl812: board=%s, ioport=0x%03lx", |
1286 | dev->minor, this_board->name, iobase); | 1290 | dev->minor, board->name, iobase); |
1287 | 1291 | ||
1288 | if (!request_region(iobase, this_board->io_range, "pcl812")) { | 1292 | if (!request_region(iobase, board->io_range, "pcl812")) { |
1289 | printk("I/O port conflict\n"); | 1293 | printk("I/O port conflict\n"); |
1290 | return -EIO; | 1294 | return -EIO; |
1291 | } | 1295 | } |
@@ -1297,13 +1301,13 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
1297 | return ret; /* Can't alloc mem */ | 1301 | return ret; /* Can't alloc mem */ |
1298 | } | 1302 | } |
1299 | 1303 | ||
1300 | dev->board_name = this_board->name; | 1304 | dev->board_name = board->name; |
1301 | 1305 | ||
1302 | irq = 0; | 1306 | irq = 0; |
1303 | if (this_board->IRQbits != 0) { /* board support IRQ */ | 1307 | if (board->IRQbits != 0) { /* board support IRQ */ |
1304 | irq = it->options[1]; | 1308 | irq = it->options[1]; |
1305 | if (irq) { /* we want to use IRQ */ | 1309 | if (irq) { /* we want to use IRQ */ |
1306 | if (((1 << irq) & this_board->IRQbits) == 0) { | 1310 | if (((1 << irq) & board->IRQbits) == 0) { |
1307 | printk | 1311 | printk |
1308 | (", IRQ %u is out of allowed range, " | 1312 | (", IRQ %u is out of allowed range, " |
1309 | "DISABLING IT", irq); | 1313 | "DISABLING IT", irq); |
@@ -1328,9 +1332,9 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
1328 | devpriv->dma = dma; | 1332 | devpriv->dma = dma; |
1329 | if (!dev->irq) | 1333 | if (!dev->irq) |
1330 | goto no_dma; /* if we haven't IRQ, we can't use DMA */ | 1334 | goto no_dma; /* if we haven't IRQ, we can't use DMA */ |
1331 | if (this_board->DMAbits != 0) { /* board support DMA */ | 1335 | if (board->DMAbits != 0) { /* board support DMA */ |
1332 | dma = it->options[2]; | 1336 | dma = it->options[2]; |
1333 | if (((1 << dma) & this_board->DMAbits) == 0) { | 1337 | if (((1 << dma) & board->DMAbits) == 0) { |
1334 | printk(", DMA is out of allowed range, FAIL!\n"); | 1338 | printk(", DMA is out of allowed range, FAIL!\n"); |
1335 | return -EINVAL; /* Bad DMA */ | 1339 | return -EINVAL; /* Bad DMA */ |
1336 | } | 1340 | } |
@@ -1369,13 +1373,13 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
1369 | no_dma: | 1373 | no_dma: |
1370 | 1374 | ||
1371 | n_subdevices = 0; | 1375 | n_subdevices = 0; |
1372 | if (this_board->n_aichan > 0) | 1376 | if (board->n_aichan > 0) |
1373 | n_subdevices++; | 1377 | n_subdevices++; |
1374 | if (this_board->n_aochan > 0) | 1378 | if (board->n_aochan > 0) |
1375 | n_subdevices++; | 1379 | n_subdevices++; |
1376 | if (this_board->n_dichan > 0) | 1380 | if (board->n_dichan > 0) |
1377 | n_subdevices++; | 1381 | n_subdevices++; |
1378 | if (this_board->n_dochan > 0) | 1382 | if (board->n_dochan > 0) |
1379 | n_subdevices++; | 1383 | n_subdevices++; |
1380 | 1384 | ||
1381 | ret = alloc_subdevices(dev, n_subdevices); | 1385 | ret = alloc_subdevices(dev, n_subdevices); |
@@ -1387,46 +1391,46 @@ no_dma: | |||
1387 | subdev = 0; | 1391 | subdev = 0; |
1388 | 1392 | ||
1389 | /* analog input */ | 1393 | /* analog input */ |
1390 | if (this_board->n_aichan > 0) { | 1394 | if (board->n_aichan > 0) { |
1391 | s = dev->subdevices + subdev; | 1395 | s = dev->subdevices + subdev; |
1392 | s->type = COMEDI_SUBD_AI; | 1396 | s->type = COMEDI_SUBD_AI; |
1393 | s->subdev_flags = SDF_READABLE; | 1397 | s->subdev_flags = SDF_READABLE; |
1394 | switch (this_board->board_type) { | 1398 | switch (board->board_type) { |
1395 | case boardA821: | 1399 | case boardA821: |
1396 | if (it->options[2] == 1) { | 1400 | if (it->options[2] == 1) { |
1397 | s->n_chan = this_board->n_aichan_diff; | 1401 | s->n_chan = board->n_aichan_diff; |
1398 | s->subdev_flags |= SDF_DIFF; | 1402 | s->subdev_flags |= SDF_DIFF; |
1399 | devpriv->use_diff = 1; | 1403 | devpriv->use_diff = 1; |
1400 | } else { | 1404 | } else { |
1401 | s->n_chan = this_board->n_aichan; | 1405 | s->n_chan = board->n_aichan; |
1402 | s->subdev_flags |= SDF_GROUND; | 1406 | s->subdev_flags |= SDF_GROUND; |
1403 | } | 1407 | } |
1404 | break; | 1408 | break; |
1405 | case boardACL8112: | 1409 | case boardACL8112: |
1406 | case boardACL8216: | 1410 | case boardACL8216: |
1407 | if (it->options[4] == 1) { | 1411 | if (it->options[4] == 1) { |
1408 | s->n_chan = this_board->n_aichan_diff; | 1412 | s->n_chan = board->n_aichan_diff; |
1409 | s->subdev_flags |= SDF_DIFF; | 1413 | s->subdev_flags |= SDF_DIFF; |
1410 | devpriv->use_diff = 1; | 1414 | devpriv->use_diff = 1; |
1411 | } else { | 1415 | } else { |
1412 | s->n_chan = this_board->n_aichan; | 1416 | s->n_chan = board->n_aichan; |
1413 | s->subdev_flags |= SDF_GROUND; | 1417 | s->subdev_flags |= SDF_GROUND; |
1414 | } | 1418 | } |
1415 | break; | 1419 | break; |
1416 | default: | 1420 | default: |
1417 | s->n_chan = this_board->n_aichan; | 1421 | s->n_chan = board->n_aichan; |
1418 | s->subdev_flags |= SDF_GROUND; | 1422 | s->subdev_flags |= SDF_GROUND; |
1419 | break; | 1423 | break; |
1420 | } | 1424 | } |
1421 | s->maxdata = this_board->ai_maxdata; | 1425 | s->maxdata = board->ai_maxdata; |
1422 | s->len_chanlist = MAX_CHANLIST_LEN; | 1426 | s->len_chanlist = MAX_CHANLIST_LEN; |
1423 | s->range_table = this_board->rangelist_ai; | 1427 | s->range_table = board->rangelist_ai; |
1424 | if (this_board->board_type == boardACL8216) | 1428 | if (board->board_type == boardACL8216) |
1425 | s->insn_read = acl8216_ai_insn_read; | 1429 | s->insn_read = acl8216_ai_insn_read; |
1426 | else | 1430 | else |
1427 | s->insn_read = pcl812_ai_insn_read; | 1431 | s->insn_read = pcl812_ai_insn_read; |
1428 | 1432 | ||
1429 | devpriv->use_MPC = this_board->haveMPC508; | 1433 | devpriv->use_MPC = board->haveMPC508; |
1430 | s->cancel = pcl812_ai_cancel; | 1434 | s->cancel = pcl812_ai_cancel; |
1431 | if (dev->irq) { | 1435 | if (dev->irq) { |
1432 | dev->read_subdev = s; | 1436 | dev->read_subdev = s; |
@@ -1435,7 +1439,7 @@ no_dma: | |||
1435 | s->do_cmd = pcl812_ai_cmd; | 1439 | s->do_cmd = pcl812_ai_cmd; |
1436 | s->poll = pcl812_ai_poll; | 1440 | s->poll = pcl812_ai_poll; |
1437 | } | 1441 | } |
1438 | switch (this_board->board_type) { | 1442 | switch (board->board_type) { |
1439 | case boardPCL812PG: | 1443 | case boardPCL812PG: |
1440 | if (it->options[4] == 1) | 1444 | if (it->options[4] == 1) |
1441 | s->range_table = &range_pcl812pg2_ai; | 1445 | s->range_table = &range_pcl812pg2_ai; |
@@ -1529,17 +1533,17 @@ no_dma: | |||
1529 | } | 1533 | } |
1530 | 1534 | ||
1531 | /* analog output */ | 1535 | /* analog output */ |
1532 | if (this_board->n_aochan > 0) { | 1536 | if (board->n_aochan > 0) { |
1533 | s = dev->subdevices + subdev; | 1537 | s = dev->subdevices + subdev; |
1534 | s->type = COMEDI_SUBD_AO; | 1538 | s->type = COMEDI_SUBD_AO; |
1535 | s->subdev_flags = SDF_WRITABLE | SDF_GROUND; | 1539 | s->subdev_flags = SDF_WRITABLE | SDF_GROUND; |
1536 | s->n_chan = this_board->n_aochan; | 1540 | s->n_chan = board->n_aochan; |
1537 | s->maxdata = 0xfff; | 1541 | s->maxdata = 0xfff; |
1538 | s->len_chanlist = 1; | 1542 | s->len_chanlist = 1; |
1539 | s->range_table = this_board->rangelist_ao; | 1543 | s->range_table = board->rangelist_ao; |
1540 | s->insn_read = pcl812_ao_insn_read; | 1544 | s->insn_read = pcl812_ao_insn_read; |
1541 | s->insn_write = pcl812_ao_insn_write; | 1545 | s->insn_write = pcl812_ao_insn_write; |
1542 | switch (this_board->board_type) { | 1546 | switch (board->board_type) { |
1543 | case boardA821: | 1547 | case boardA821: |
1544 | if (it->options[3] == 1) | 1548 | if (it->options[3] == 1) |
1545 | s->range_table = &range_unipolar10; | 1549 | s->range_table = &range_unipolar10; |
@@ -1558,32 +1562,32 @@ no_dma: | |||
1558 | } | 1562 | } |
1559 | 1563 | ||
1560 | /* digital input */ | 1564 | /* digital input */ |
1561 | if (this_board->n_dichan > 0) { | 1565 | if (board->n_dichan > 0) { |
1562 | s = dev->subdevices + subdev; | 1566 | s = dev->subdevices + subdev; |
1563 | s->type = COMEDI_SUBD_DI; | 1567 | s->type = COMEDI_SUBD_DI; |
1564 | s->subdev_flags = SDF_READABLE; | 1568 | s->subdev_flags = SDF_READABLE; |
1565 | s->n_chan = this_board->n_dichan; | 1569 | s->n_chan = board->n_dichan; |
1566 | s->maxdata = 1; | 1570 | s->maxdata = 1; |
1567 | s->len_chanlist = this_board->n_dichan; | 1571 | s->len_chanlist = board->n_dichan; |
1568 | s->range_table = &range_digital; | 1572 | s->range_table = &range_digital; |
1569 | s->insn_bits = pcl812_di_insn_bits; | 1573 | s->insn_bits = pcl812_di_insn_bits; |
1570 | subdev++; | 1574 | subdev++; |
1571 | } | 1575 | } |
1572 | 1576 | ||
1573 | /* digital output */ | 1577 | /* digital output */ |
1574 | if (this_board->n_dochan > 0) { | 1578 | if (board->n_dochan > 0) { |
1575 | s = dev->subdevices + subdev; | 1579 | s = dev->subdevices + subdev; |
1576 | s->type = COMEDI_SUBD_DO; | 1580 | s->type = COMEDI_SUBD_DO; |
1577 | s->subdev_flags = SDF_WRITABLE; | 1581 | s->subdev_flags = SDF_WRITABLE; |
1578 | s->n_chan = this_board->n_dochan; | 1582 | s->n_chan = board->n_dochan; |
1579 | s->maxdata = 1; | 1583 | s->maxdata = 1; |
1580 | s->len_chanlist = this_board->n_dochan; | 1584 | s->len_chanlist = board->n_dochan; |
1581 | s->range_table = &range_digital; | 1585 | s->range_table = &range_digital; |
1582 | s->insn_bits = pcl812_do_insn_bits; | 1586 | s->insn_bits = pcl812_do_insn_bits; |
1583 | subdev++; | 1587 | subdev++; |
1584 | } | 1588 | } |
1585 | 1589 | ||
1586 | switch (this_board->board_type) { | 1590 | switch (board->board_type) { |
1587 | case boardACL8216: | 1591 | case boardACL8216: |
1588 | devpriv->ai_is16b = 1; | 1592 | devpriv->ai_is16b = 1; |
1589 | case boardPCL812PG: | 1593 | case boardPCL812PG: |