Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: comedi: das08: split out bus specific code

Split the bus specific ISA/PC-104 and PCI code out of this driver
and create two new drivers, das08_isa and das08_pci.

This allows removing all the #ifdef'ery in the das08 driver that
handled if the CONFIG_COMEDI_DAS08_{ISA,PCI} options were enabled.

It also makes the PCI driver cleanly Plug-and-Play since the comedi
driver only has an auto_attach callback. Previously it also had an
attach callback in order to handle the ISA cards.

Since the PCMCIA support was already split out, we can also remove
the now unused enum das08_bustype and it's use in the boardinfo.
The bus specific code deals with the bustype automatically before
it calls the common attach function in das08.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

H Hartley Sweeten and committed by
Greg Kroah-Hartman
f91f9bea ec6e0f63

+349 -348
+2 -2
drivers/staging/comedi/Kconfig
··· 274 274 DAS08/JR-16-AO, PC104-DAS08, DAS08/JR/16. 275 275 276 276 To compile this driver as a module, choose M here: the module will be 277 - called das08. 277 + called das08_isa. 278 278 279 279 config COMEDI_DAS16 280 280 tristate "DAS-16 compatible ISA and PC/104 card support" ··· 802 802 Enable support for PCI DAS-08 cards. 803 803 804 804 To compile this driver as a module, choose M here: the module will be 805 - called das08. 805 + called das08_pci. 806 806 807 807 config COMEDI_DT3000 808 808 tristate "Data Translation DT3000 series support"
+2
drivers/staging/comedi/drivers/Makefile
··· 25 25 obj-$(CONFIG_COMEDI_RTI800) += rti800.o 26 26 obj-$(CONFIG_COMEDI_RTI802) += rti802.o 27 27 obj-$(CONFIG_COMEDI_DAS16M1) += das16m1.o 28 + obj-$(CONFIG_COMEDI_DAS08_ISA) += das08_isa.o 28 29 obj-$(CONFIG_COMEDI_DAS16) += das16.o 29 30 obj-$(CONFIG_COMEDI_DAS800) += das800.o 30 31 obj-$(CONFIG_COMEDI_DAS1800) += das1800.o ··· 82 81 obj-$(CONFIG_COMEDI_AMPLC_PCI224) += amplc_pci224.o 83 82 obj-$(CONFIG_COMEDI_AMPLC_PCI230) += amplc_pci230.o 84 83 obj-$(CONFIG_COMEDI_CONTEC_PCI_DIO) += contec_pci_dio.o 84 + obj-$(CONFIG_COMEDI_DAS08_PCI) += das08_pci.o 85 85 obj-$(CONFIG_COMEDI_DT3000) += dt3000.o 86 86 obj-$(CONFIG_COMEDI_DYNA_PCI10XX) += dyna_pci10xx.o 87 87 obj-$(CONFIG_COMEDI_UNIOXX5) += unioxx5.o
+7 -343
drivers/staging/comedi/drivers/das08.c
··· 1 1 /* 2 2 * comedi/drivers/das08.c 3 - * DAS08 driver 3 + * comedi driver for common DAS08 support (used by ISA/PCI/PCMCIA drivers) 4 4 * 5 5 * COMEDI - Linux Control and Measurement Device Interface 6 6 * Copyright (C) 2000 David A. Schleef <ds@schleef.org> ··· 27 27 /* 28 28 * Driver: das08 29 29 * Description: DAS-08 compatible boards 30 + * Devices: various, see das08_isa, das08_cs, and das08_pci drivers 30 31 * Author: Warren Jasper, ds, Frank Hess 31 - * Devices: [Keithley Metrabyte] DAS08 (isa-das08), 32 - * [ComputerBoards] DAS08 (isa-das08), DAS08-PGM (das08-pgm), 33 - * DAS08-PGH (das08-pgh), DAS08-PGL (das08-pgl), DAS08-AOH (das08-aoh), 34 - * DAS08-AOL (das08-aol), DAS08-AOM (das08-aom), DAS08/JR-AO (das08/jr-ao), 35 - * DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (pci-das08), 36 - * PC104-DAS08 (pc104-das08), DAS08/JR/16 (das08jr/16) 37 32 * Updated: Fri, 31 Aug 2012 19:19:06 +0100 38 33 * Status: works 39 34 * 40 - * This is a rewrite of the das08 and das08jr drivers. 35 + * This driver is used by the das08_isa, das08_cs, and das08_pci 36 + * drivers to provide the common support for the DAS-08 hardware. 41 37 * 42 - * Options (for ISA cards): 43 - * [0] - base io address 44 - * 45 - * Manual configuration of PCI cards is not supported; they are 46 - * configured automatically. 47 - * 48 - * The das08 driver doesn't support asynchronous commands, since 49 - * the cheap das08 hardware doesn't really support them. The 50 - * comedi_rt_timer driver can be used to emulate commands for this 51 - * driver. 38 + * The driver doesn't support asynchronous commands, since the 39 + * cheap das08 hardware doesn't really support them. 52 40 */ 53 41 54 - #include <linux/pci.h> 55 42 #include <linux/delay.h> 56 43 57 44 #include "../comedidev.h" ··· 46 59 #include "8255.h" 47 60 #include "8253.h" 48 61 #include "das08.h" 49 - 50 - #define DRV_NAME "das08" 51 - 52 - #define DO_ISA IS_ENABLED(CONFIG_COMEDI_DAS08_ISA) 53 - #define DO_PCI IS_ENABLED(CONFIG_COMEDI_DAS08_PCI) 54 - #define DO_COMEDI_DRIVER_REGISTER (DO_ISA || DO_PCI) 55 - 56 - #define PCI_DEVICE_ID_PCIDAS08 0x29 57 - #define PCIDAS08_SIZE 0x54 58 - 59 - /* pci configuration registers */ 60 - #define INTCSR 0x4c 61 - #define INTR1_ENABLE 0x1 62 - #define INTR1_HIGH_POLARITY 0x2 63 - #define PCI_INTR_ENABLE 0x40 64 - #define INTR1_EDGE_TRIG 0x100 /* requires high polarity */ 65 - #define CNTRL 0x50 66 - #define CNTRL_DIR 0x2 67 - #define CNTRL_INTR 0x4 68 62 69 63 /* 70 64 cio-das08.pdf ··· 203 235 das08_pgl_gainlist, 204 236 das08_pgm_gainlist, 205 237 }; 206 - 207 - static inline bool is_isa_board(const struct das08_board_struct *board) 208 - { 209 - return DO_ISA && board->bustype == isa; 210 - } 211 - 212 - static inline bool is_pci_board(const struct das08_board_struct *board) 213 - { 214 - return DO_PCI && board->bustype == pci; 215 - } 216 238 217 239 #define TIMEOUT 100000 218 240 ··· 460 502 return 2; 461 503 } 462 504 463 - #if DO_COMEDI_DRIVER_REGISTER 464 - static const struct das08_board_struct das08_boards[] = { 465 - #if DO_ISA 466 - { 467 - .name = "isa-das08", /* cio-das08.pdf */ 468 - .bustype = isa, 469 - .ai_nbits = 12, 470 - .ai_pg = das08_pg_none, 471 - .ai_encoding = das08_encode12, 472 - .di_nchan = 3, 473 - .do_nchan = 4, 474 - .i8255_offset = 8, 475 - .i8254_offset = 4, 476 - .iosize = 16, /* unchecked */ 477 - }, 478 - { 479 - .name = "das08-pgm", /* cio-das08pgx.pdf */ 480 - .bustype = isa, 481 - .ai_nbits = 12, 482 - .ai_pg = das08_pgm, 483 - .ai_encoding = das08_encode12, 484 - .di_nchan = 3, 485 - .do_nchan = 4, 486 - .i8255_offset = 0, 487 - .i8254_offset = 0x04, 488 - .iosize = 16, /* unchecked */ 489 - }, 490 - { 491 - .name = "das08-pgh", /* cio-das08pgx.pdf */ 492 - .bustype = isa, 493 - .ai_nbits = 12, 494 - .ai_pg = das08_pgh, 495 - .ai_encoding = das08_encode12, 496 - .di_nchan = 3, 497 - .do_nchan = 4, 498 - .i8254_offset = 0x04, 499 - .iosize = 16, /* unchecked */ 500 - }, 501 - { 502 - .name = "das08-pgl", /* cio-das08pgx.pdf */ 503 - .bustype = isa, 504 - .ai_nbits = 12, 505 - .ai_pg = das08_pgl, 506 - .ai_encoding = das08_encode12, 507 - .di_nchan = 3, 508 - .do_nchan = 4, 509 - .i8254_offset = 0x04, 510 - .iosize = 16, /* unchecked */ 511 - }, 512 - { 513 - .name = "das08-aoh", /* cio-das08_aox.pdf */ 514 - .bustype = isa, 515 - .ai_nbits = 12, 516 - .ai_pg = das08_pgh, 517 - .ai_encoding = das08_encode12, 518 - .ao_nbits = 12, 519 - .di_nchan = 3, 520 - .do_nchan = 4, 521 - .i8255_offset = 0x0c, 522 - .i8254_offset = 0x04, 523 - .iosize = 16, /* unchecked */ 524 - }, 525 - { 526 - .name = "das08-aol", /* cio-das08_aox.pdf */ 527 - .bustype = isa, 528 - .ai_nbits = 12, 529 - .ai_pg = das08_pgl, 530 - .ai_encoding = das08_encode12, 531 - .ao_nbits = 12, 532 - .di_nchan = 3, 533 - .do_nchan = 4, 534 - .i8255_offset = 0x0c, 535 - .i8254_offset = 0x04, 536 - .iosize = 16, /* unchecked */ 537 - }, 538 - { 539 - .name = "das08-aom", /* cio-das08_aox.pdf */ 540 - .bustype = isa, 541 - .ai_nbits = 12, 542 - .ai_pg = das08_pgm, 543 - .ai_encoding = das08_encode12, 544 - .ao_nbits = 12, 545 - .di_nchan = 3, 546 - .do_nchan = 4, 547 - .i8255_offset = 0x0c, 548 - .i8254_offset = 0x04, 549 - .iosize = 16, /* unchecked */ 550 - }, 551 - { 552 - .name = "das08/jr-ao", /* cio-das08-jr-ao.pdf */ 553 - .bustype = isa, 554 - .is_jr = true, 555 - .ai_nbits = 12, 556 - .ai_pg = das08_pg_none, 557 - .ai_encoding = das08_encode12, 558 - .ao_nbits = 12, 559 - .di_nchan = 8, 560 - .do_nchan = 8, 561 - .iosize = 16, /* unchecked */ 562 - }, 563 - { 564 - .name = "das08jr-16-ao", /* cio-das08jr-16-ao.pdf */ 565 - .bustype = isa, 566 - .is_jr = true, 567 - .ai_nbits = 16, 568 - .ai_pg = das08_pg_none, 569 - .ai_encoding = das08_encode16, 570 - .ao_nbits = 16, 571 - .di_nchan = 8, 572 - .do_nchan = 8, 573 - .i8254_offset = 0x04, 574 - .iosize = 16, /* unchecked */ 575 - }, 576 - { 577 - .name = "pc104-das08", 578 - .bustype = isa, 579 - .ai_nbits = 12, 580 - .ai_pg = das08_pg_none, 581 - .ai_encoding = das08_encode12, 582 - .di_nchan = 3, 583 - .do_nchan = 4, 584 - .i8254_offset = 4, 585 - .iosize = 16, /* unchecked */ 586 - }, 587 - { 588 - .name = "das08jr/16", 589 - .bustype = isa, 590 - .is_jr = true, 591 - .ai_nbits = 16, 592 - .ai_pg = das08_pg_none, 593 - .ai_encoding = das08_encode16, 594 - .di_nchan = 8, 595 - .do_nchan = 8, 596 - .iosize = 16, /* unchecked */ 597 - }, 598 - #endif /* DO_ISA */ 599 - #if DO_PCI 600 - { 601 - .name = "pci-das08", /* pci-das08 */ 602 - .id = PCI_DEVICE_ID_PCIDAS08, 603 - .bustype = pci, 604 - .ai_nbits = 12, 605 - .ai_pg = das08_bipolar5, 606 - .ai_encoding = das08_encode12, 607 - .di_nchan = 3, 608 - .do_nchan = 4, 609 - .i8254_offset = 4, 610 - .iosize = 8, 611 - }, 612 - #endif /* DO_PCI */ 613 - }; 614 - #endif /* DO_COMEDI_DRIVER_REGISTER */ 615 - 616 505 int das08_common_attach(struct comedi_device *dev, unsigned long iobase) 617 506 { 618 507 const struct das08_board_struct *thisboard = comedi_board(dev); ··· 566 761 } 567 762 EXPORT_SYMBOL_GPL(das08_common_attach); 568 763 569 - static const struct das08_board_struct * 570 - das08_find_pci_board(struct pci_dev *pdev) 571 - { 572 - #if DO_COMEDI_DRIVER_REGISTER 573 - unsigned int i; 574 - for (i = 0; i < ARRAY_SIZE(das08_boards); i++) 575 - if (is_pci_board(&das08_boards[i]) && 576 - pdev->device == das08_boards[i].id) 577 - return &das08_boards[i]; 578 - #endif 579 - return NULL; 580 - } 581 - 582 - /* only called in the PCI probe path, via comedi_pci_auto_config() */ 583 - static int __maybe_unused 584 - das08_auto_attach(struct comedi_device *dev, unsigned long context_unused) 585 - { 586 - struct pci_dev *pdev; 587 - struct das08_private_struct *devpriv; 588 - unsigned long iobase; 589 - 590 - if (!DO_PCI) 591 - return -EINVAL; 592 - 593 - pdev = comedi_to_pci_dev(dev); 594 - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); 595 - if (!devpriv) 596 - return -ENOMEM; 597 - dev->private = devpriv; 598 - 599 - dev_info(dev->class_dev, "attach pci %s\n", pci_name(pdev)); 600 - dev->board_ptr = das08_find_pci_board(pdev); 601 - if (dev->board_ptr == NULL) { 602 - dev_err(dev->class_dev, "BUG! cannot determine board type!\n"); 603 - return -EINVAL; 604 - } 605 - 606 - /* enable PCI device and reserve I/O spaces */ 607 - if (comedi_pci_enable(pdev, dev->driver->driver_name)) { 608 - dev_err(dev->class_dev, 609 - "Error enabling PCI device and requesting regions\n"); 610 - return -EIO; 611 - } 612 - /* read base addresses */ 613 - iobase = pci_resource_start(pdev, 2); 614 - return das08_common_attach(dev, iobase); 615 - } 616 - 617 - static int __maybe_unused 618 - das08_attach(struct comedi_device *dev, struct comedi_devconfig *it) 619 - { 620 - const struct das08_board_struct *thisboard = comedi_board(dev); 621 - struct das08_private_struct *devpriv; 622 - unsigned long iobase; 623 - 624 - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); 625 - if (!devpriv) 626 - return -ENOMEM; 627 - dev->private = devpriv; 628 - 629 - dev_info(dev->class_dev, "attach\n"); 630 - if (is_pci_board(thisboard)) { 631 - dev_err(dev->class_dev, 632 - "Manual configuration of PCI board '%s' is not supported\n", 633 - thisboard->name); 634 - return -EIO; 635 - } else if (is_isa_board(thisboard)) { 636 - iobase = it->options[0]; 637 - dev_info(dev->class_dev, "iobase 0x%lx\n", iobase); 638 - if (!request_region(iobase, thisboard->iosize, DRV_NAME)) { 639 - dev_err(dev->class_dev, "I/O port conflict\n"); 640 - return -EIO; 641 - } 642 - return das08_common_attach(dev, iobase); 643 - } else 644 - return -EIO; 645 - } 646 - 647 764 void das08_common_detach(struct comedi_device *dev) 648 765 { 649 766 if (dev->subdevices) ··· 573 846 } 574 847 EXPORT_SYMBOL_GPL(das08_common_detach); 575 848 576 - static void __maybe_unused das08_detach(struct comedi_device *dev) 577 - { 578 - const struct das08_board_struct *thisboard = comedi_board(dev); 579 - 580 - if (!thisboard) 581 - return; 582 - das08_common_detach(dev); 583 - if (is_isa_board(thisboard)) { 584 - if (dev->iobase) 585 - release_region(dev->iobase, thisboard->iosize); 586 - } else if (is_pci_board(thisboard)) { 587 - struct pci_dev *pdev = comedi_to_pci_dev(dev); 588 - if (pdev) { 589 - if (dev->iobase) 590 - comedi_pci_disable(pdev); 591 - } 592 - } 593 - } 594 - 595 - #if DO_COMEDI_DRIVER_REGISTER 596 - static struct comedi_driver das08_driver = { 597 - .driver_name = DRV_NAME, 598 - .module = THIS_MODULE, 599 - .attach = das08_attach, 600 - .auto_attach = das08_auto_attach, 601 - .detach = das08_detach, 602 - .board_name = &das08_boards[0].name, 603 - .num_names = sizeof(das08_boards) / sizeof(struct das08_board_struct), 604 - .offset = sizeof(struct das08_board_struct), 605 - }; 606 - #endif 607 - 608 - #if DO_PCI 609 - static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = { 610 - { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_PCIDAS08) }, 611 - {0} 612 - }; 613 - 614 - MODULE_DEVICE_TABLE(pci, das08_pci_table); 615 - 616 - static int das08_pci_probe(struct pci_dev *dev, 617 - const struct pci_device_id *ent) 618 - { 619 - return comedi_pci_auto_config(dev, &das08_driver); 620 - } 621 - 622 - static struct pci_driver das08_pci_driver = { 623 - .id_table = das08_pci_table, 624 - .name = DRV_NAME, 625 - .probe = &das08_pci_probe, 626 - .remove = comedi_pci_auto_unconfig, 627 - }; 628 - #endif /* DO_PCI */ 629 - 630 - #if DO_COMEDI_DRIVER_REGISTER 631 - #if DO_PCI 632 - module_comedi_pci_driver(das08_driver, das08_pci_driver); 633 - #else 634 - module_comedi_driver(das08_driver); 635 - #endif 636 - #else /* DO_COMEDI_DRIVER_REGISTER */ 637 849 static int __init das08_init(void) 638 850 { 639 851 return 0; 640 852 } 853 + module_init(das08_init); 641 854 642 855 static void __exit das08_exit(void) 643 856 { 644 857 } 645 - 646 - module_init(das08_init); 647 858 module_exit(das08_exit); 648 - #endif /* DO_COMEDI_DRIVER_REGISTER */ 649 859 650 860 MODULE_AUTHOR("Comedi http://www.comedi.org"); 651 861 MODULE_DESCRIPTION("Comedi low-level driver");
-2
drivers/staging/comedi/drivers/das08.h
··· 24 24 #ifndef _DAS08_H 25 25 #define _DAS08_H 26 26 27 - enum das08_bustype { isa, pci, pcmcia }; 28 27 /* different ways ai data is encoded in first two registers */ 29 28 enum das08_ai_encoding { das08_encode12, das08_encode16, das08_pcm_encode12 }; 30 29 enum das08_lrange { das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl, ··· 33 34 struct das08_board_struct { 34 35 const char *name; 35 36 unsigned int id; /* id for pci/pcmcia boards */ 36 - enum das08_bustype bustype; 37 37 bool is_jr; /* true for 'JR' boards */ 38 38 unsigned int ai_nbits; 39 39 enum das08_lrange ai_pg;
-1
drivers/staging/comedi/drivers/das08_cs.c
··· 60 60 { 61 61 .name = "pcm-das08", 62 62 .id = 0x0, /* XXX */ 63 - .bustype = pcmcia, 64 63 .ai_nbits = 12, 65 64 .ai_pg = das08_bipolar5, 66 65 .ai_encoding = das08_pcm_encode12,
+217
drivers/staging/comedi/drivers/das08_isa.c
··· 1 + /* 2 + * das08_isa.c 3 + * comedi driver for DAS08 ISA/PC-104 boards 4 + * 5 + * COMEDI - Linux Control and Measurement Device Interface 6 + * Copyright (C) 2000 David A. Schleef <ds@schleef.org> 7 + * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net> 8 + * Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org> 9 + * 10 + * This program is free software; you can redistribute it and/or modify 11 + * it under the terms of the GNU General Public License as published by 12 + * the Free Software Foundation; either version 2 of the License, or 13 + * (at your option) any later version. 14 + * 15 + * This program is distributed in the hope that it will be useful, 16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 + * GNU General Public License for more details. 19 + * 20 + * You should have received a copy of the GNU General Public License 21 + * along with this program; if not, write to the Free Software 22 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 + */ 24 + 25 + /* 26 + * Driver: das08_isa 27 + * Description: DAS-08 ISA/PC-104 compatible boards 28 + * Devices: (Keithley Metrabyte) DAS08 [isa-das08], 29 + * (ComputerBoards) DAS08 [isa-das08] 30 + * (ComputerBoards) DAS08-PGM [das08-pgm] 31 + * (ComputerBoards) DAS08-PGH [das08-pgh] 32 + * (ComputerBoards) DAS08-PGL [das08-pgl] 33 + * (ComputerBoards) DAS08-AOH [das08-aoh] 34 + * (ComputerBoards) DAS08-AOL [das08-aol] 35 + * (ComputerBoards) DAS08-AOM [das08-aom] 36 + * (ComputerBoards) DAS08/JR-AO [das08/jr-ao] 37 + * (ComputerBoards) DAS08/JR-16-AO [das08jr-16-ao] 38 + * (ComputerBoards) PC104-DAS08 [pc104-das08] 39 + * (ComputerBoards) DAS08/JR/16 [das08jr/16] 40 + * Author: Warren Jasper, ds, Frank Hess 41 + * Updated: Fri, 31 Aug 2012 19:19:06 +0100 42 + * Status: works 43 + * 44 + * This is the ISA/PC-104-specific support split off from the das08 driver. 45 + * 46 + * Configuration Options: 47 + * [0] - base io address 48 + */ 49 + 50 + #include "../comedidev.h" 51 + 52 + #include "das08.h" 53 + 54 + static const struct das08_board_struct das08_isa_boards[] = { 55 + { 56 + /* cio-das08.pdf */ 57 + .name = "isa-das08", 58 + .ai_nbits = 12, 59 + .ai_pg = das08_pg_none, 60 + .ai_encoding = das08_encode12, 61 + .di_nchan = 3, 62 + .do_nchan = 4, 63 + .i8255_offset = 8, 64 + .i8254_offset = 4, 65 + .iosize = 16, /* unchecked */ 66 + }, { 67 + /* cio-das08pgx.pdf */ 68 + .name = "das08-pgm", 69 + .ai_nbits = 12, 70 + .ai_pg = das08_pgm, 71 + .ai_encoding = das08_encode12, 72 + .di_nchan = 3, 73 + .do_nchan = 4, 74 + .i8255_offset = 0, 75 + .i8254_offset = 0x04, 76 + .iosize = 16, /* unchecked */ 77 + }, { 78 + /* cio-das08pgx.pdf */ 79 + .name = "das08-pgh", 80 + .ai_nbits = 12, 81 + .ai_pg = das08_pgh, 82 + .ai_encoding = das08_encode12, 83 + .di_nchan = 3, 84 + .do_nchan = 4, 85 + .i8254_offset = 0x04, 86 + .iosize = 16, /* unchecked */ 87 + }, { 88 + /* cio-das08pgx.pdf */ 89 + .name = "das08-pgl", 90 + .ai_nbits = 12, 91 + .ai_pg = das08_pgl, 92 + .ai_encoding = das08_encode12, 93 + .di_nchan = 3, 94 + .do_nchan = 4, 95 + .i8254_offset = 0x04, 96 + .iosize = 16, /* unchecked */ 97 + }, { 98 + /* cio-das08_aox.pdf */ 99 + .name = "das08-aoh", 100 + .ai_nbits = 12, 101 + .ai_pg = das08_pgh, 102 + .ai_encoding = das08_encode12, 103 + .ao_nbits = 12, 104 + .di_nchan = 3, 105 + .do_nchan = 4, 106 + .i8255_offset = 0x0c, 107 + .i8254_offset = 0x04, 108 + .iosize = 16, /* unchecked */ 109 + }, { 110 + /* cio-das08_aox.pdf */ 111 + .name = "das08-aol", 112 + .ai_nbits = 12, 113 + .ai_pg = das08_pgl, 114 + .ai_encoding = das08_encode12, 115 + .ao_nbits = 12, 116 + .di_nchan = 3, 117 + .do_nchan = 4, 118 + .i8255_offset = 0x0c, 119 + .i8254_offset = 0x04, 120 + .iosize = 16, /* unchecked */ 121 + }, { 122 + /* cio-das08_aox.pdf */ 123 + .name = "das08-aom", 124 + .ai_nbits = 12, 125 + .ai_pg = das08_pgm, 126 + .ai_encoding = das08_encode12, 127 + .ao_nbits = 12, 128 + .di_nchan = 3, 129 + .do_nchan = 4, 130 + .i8255_offset = 0x0c, 131 + .i8254_offset = 0x04, 132 + .iosize = 16, /* unchecked */ 133 + }, { 134 + /* cio-das08-jr-ao.pdf */ 135 + .name = "das08/jr-ao", 136 + .is_jr = true, 137 + .ai_nbits = 12, 138 + .ai_pg = das08_pg_none, 139 + .ai_encoding = das08_encode12, 140 + .ao_nbits = 12, 141 + .di_nchan = 8, 142 + .do_nchan = 8, 143 + .iosize = 16, /* unchecked */ 144 + }, { 145 + /* cio-das08jr-16-ao.pdf */ 146 + .name = "das08jr-16-ao", 147 + .is_jr = true, 148 + .ai_nbits = 16, 149 + .ai_pg = das08_pg_none, 150 + .ai_encoding = das08_encode16, 151 + .ao_nbits = 16, 152 + .di_nchan = 8, 153 + .do_nchan = 8, 154 + .i8254_offset = 0x04, 155 + .iosize = 16, /* unchecked */ 156 + }, { 157 + .name = "pc104-das08", 158 + .ai_nbits = 12, 159 + .ai_pg = das08_pg_none, 160 + .ai_encoding = das08_encode12, 161 + .di_nchan = 3, 162 + .do_nchan = 4, 163 + .i8254_offset = 4, 164 + .iosize = 16, /* unchecked */ 165 + }, { 166 + .name = "das08jr/16", 167 + .is_jr = true, 168 + .ai_nbits = 16, 169 + .ai_pg = das08_pg_none, 170 + .ai_encoding = das08_encode16, 171 + .di_nchan = 8, 172 + .do_nchan = 8, 173 + .iosize = 16, /* unchecked */ 174 + }, 175 + }; 176 + 177 + static int das08_isa_attach(struct comedi_device *dev, 178 + struct comedi_devconfig *it) 179 + { 180 + const struct das08_board_struct *thisboard = comedi_board(dev); 181 + struct das08_private_struct *devpriv; 182 + 183 + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); 184 + if (!devpriv) 185 + return -ENOMEM; 186 + dev->private = devpriv; 187 + 188 + if (!request_region(it->options[0], thisboard->iosize, 189 + thisboard->name)) 190 + return -EIO; 191 + 192 + return das08_common_attach(dev, it->options[0]); 193 + } 194 + 195 + static void das08_isa_detach(struct comedi_device *dev) 196 + { 197 + const struct das08_board_struct *thisboard = comedi_board(dev); 198 + 199 + das08_common_detach(dev); 200 + if (dev->iobase) 201 + release_region(dev->iobase, thisboard->iosize); 202 + } 203 + 204 + static struct comedi_driver das08_isa_driver = { 205 + .driver_name = "isa-das08", 206 + .module = THIS_MODULE, 207 + .attach = das08_isa_attach, 208 + .detach = das08_isa_detach, 209 + .board_name = &das08_isa_boards[0].name, 210 + .num_names = ARRAY_SIZE(das08_isa_boards), 211 + .offset = sizeof(das08_isa_boards[0]), 212 + }; 213 + module_comedi_driver(das08_isa_driver); 214 + 215 + MODULE_AUTHOR("Comedi http://www.comedi.org"); 216 + MODULE_DESCRIPTION("Comedi low-level driver"); 217 + MODULE_LICENSE("GPL");
+121
drivers/staging/comedi/drivers/das08_pci.c
··· 1 + /* 2 + * das08_pci.c 3 + * comedi driver for DAS08 PCI boards 4 + * 5 + * COMEDI - Linux Control and Measurement Device Interface 6 + * Copyright (C) 2000 David A. Schleef <ds@schleef.org> 7 + * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net> 8 + * Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org> 9 + * 10 + * This program is free software; you can redistribute it and/or modify 11 + * it under the terms of the GNU General Public License as published by 12 + * the Free Software Foundation; either version 2 of the License, or 13 + * (at your option) any later version. 14 + * 15 + * This program is distributed in the hope that it will be useful, 16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 + * GNU General Public License for more details. 19 + * 20 + * You should have received a copy of the GNU General Public License 21 + * along with this program; if not, write to the Free Software 22 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 + */ 24 + 25 + /* 26 + * Driver: das08_pci 27 + * Description: DAS-08 PCI compatible boards 28 + * Devices: (ComputerBoards) PCI-DAS08 [pci-das08] 29 + * Author: Warren Jasper, ds, Frank Hess 30 + * Updated: Fri, 31 Aug 2012 19:19:06 +0100 31 + * Status: works 32 + * 33 + * This is the PCI-specific support split off from the das08 driver. 34 + * 35 + * Configuration Options: not applicable, uses PCI auto config 36 + */ 37 + 38 + #include <linux/pci.h> 39 + 40 + #include "../comedidev.h" 41 + 42 + #include "das08.h" 43 + 44 + #define PCI_DEVICE_ID_PCIDAS08 0x0029 45 + 46 + static const struct das08_board_struct das08_pci_boards[] = { 47 + { 48 + .name = "pci-das08", 49 + .id = PCI_DEVICE_ID_PCIDAS08, 50 + .ai_nbits = 12, 51 + .ai_pg = das08_bipolar5, 52 + .ai_encoding = das08_encode12, 53 + .di_nchan = 3, 54 + .do_nchan = 4, 55 + .i8254_offset = 4, 56 + .iosize = 8, 57 + }, 58 + }; 59 + 60 + static int das08_pci_auto_attach(struct comedi_device *dev, 61 + unsigned long context_unused) 62 + { 63 + struct pci_dev *pdev = comedi_to_pci_dev(dev); 64 + struct das08_private_struct *devpriv; 65 + int ret; 66 + 67 + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); 68 + if (!devpriv) 69 + return -ENOMEM; 70 + dev->private = devpriv; 71 + 72 + /* The das08 driver needs the board_ptr */ 73 + dev->board_ptr = &das08_pci_boards[0]; 74 + 75 + ret = comedi_pci_enable(pdev, dev->driver->driver_name); 76 + if (ret) 77 + return ret; 78 + dev->iobase = pci_resource_start(pdev, 2); 79 + 80 + return das08_common_attach(dev, dev->iobase); 81 + } 82 + 83 + static void das08_pci_detach(struct comedi_device *dev) 84 + { 85 + struct pci_dev *pdev = comedi_to_pci_dev(dev); 86 + 87 + das08_common_detach(dev); 88 + if (dev->iobase) 89 + comedi_pci_disable(pdev); 90 + } 91 + 92 + static struct comedi_driver das08_pci_comedi_driver = { 93 + .driver_name = "pci-das08", 94 + .module = THIS_MODULE, 95 + .auto_attach = das08_pci_auto_attach, 96 + .detach = das08_pci_detach, 97 + }; 98 + 99 + static int das08_pci_probe(struct pci_dev *dev, 100 + const struct pci_device_id *ent) 101 + { 102 + return comedi_pci_auto_config(dev, &das08_pci_comedi_driver); 103 + } 104 + 105 + static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = { 106 + { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_PCIDAS08) }, 107 + { 0 } 108 + }; 109 + MODULE_DEVICE_TABLE(pci, das08_pci_table); 110 + 111 + static struct pci_driver das08_pci_driver = { 112 + .name = "pci-das08", 113 + .id_table = das08_pci_table, 114 + .probe = das08_pci_probe, 115 + .remove = comedi_pci_auto_unconfig, 116 + }; 117 + module_comedi_pci_driver(das08_pci_comedi_driver, das08_pci_driver); 118 + 119 + MODULE_AUTHOR("Comedi http://www.comedi.org"); 120 + MODULE_DESCRIPTION("Comedi low-level driver"); 121 + MODULE_LICENSE("GPL");