Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304312
b: refs/heads/master
c: 3e6be97
h: refs/heads/master
v: v3
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Apr 10, 2012
1 parent 30c8601 commit f540663
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 717ab674e261932ca642af838ef9eea111623682
refs/heads/master: 3e6be97ebbb0b45bb834670a45b343383d6de97f
21 changes: 18 additions & 3 deletions trunk/drivers/staging/comedi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ config COMEDI_AMPLC_PC236_ISA
To compile this driver as a module, choose M here: the module will be
called amplc_pc236.

config COMEDI_AMPLC_PC263_ISA
tristate "Amplicon PC263 relay board support"
select COMEDI_AMPLC_PC263
default N
---help---
Enable support for Amplicon PC263 ISA relay board.

To compile this driver as a module, choose M here: the module will be
called amplc_pc263.

config COMEDI_RTI800
tristate "Analog Devices RTI-800/815 ISA card support"
default N
Expand Down Expand Up @@ -814,11 +824,12 @@ config COMEDI_AMPLC_PC236_PCI
To compile this driver as a module, choose M here: the module will be
called amplc_pc236.

config COMEDI_AMPLC_PC263
tristate "Amplicon PC263 and PCI263 relay board support"
config COMEDI_AMPLC_PC263_PCI
tristate "Amplicon PCI263 relay board support"
select COMEDI_AMPLC_PC263
default N
---help---
Enable support for Amplicon PC263 and PCI263 relay boards
Enable support for Amplicon PCI263 relay board.

To compile this driver as a module, choose M here: the module will be
called amplc_pc263.
Expand Down Expand Up @@ -1414,3 +1425,7 @@ config COMEDI_AMPLC_PC236
def_tristate N
depends on COMEDI
select COMEDI_8255

config COMEDI_AMPLC_PC263
def_tristate N
depends on COMEDI
65 changes: 45 additions & 20 deletions trunk/drivers/staging/comedi/drivers/amplc_pc263.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ The state of the outputs can be read.

#define PC263_DRIVER_NAME "amplc_pc263"

#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA_MODULE
#define CONFIG_COMEDI_AMPLC_PC263_ISA
#endif

#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI_MODULE
#define CONFIG_COMEDI_AMPLC_PC263_PCI
#endif

/* PCI263 PCI configuration register information */
#define PCI_VENDOR_ID_AMPLICON 0x14dc
#define PCI_DEVICE_ID_AMPLICON_PCI263 0x000c
Expand All @@ -73,22 +81,22 @@ struct pc263_board {
enum pc263_model model;
};
static const struct pc263_board pc263_boards[] = {
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
{
.name = "pc263",
.fancy_name = "PC263",
.bustype = isa_bustype,
.model = pc263_model,
},
#ifdef CONFIG_COMEDI_PCI
#endif
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
{
.name = "pci263",
.fancy_name = "PCI263",
.devid = PCI_DEVICE_ID_AMPLICON_PCI263,
.bustype = pci_bustype,
.model = pci263_model,
},
#endif
#ifdef CONFIG_COMEDI_PCI
{
.name = PC263_DRIVER_NAME,
.fancy_name = PC263_DRIVER_NAME,
Expand All @@ -99,14 +107,14 @@ static const struct pc263_board pc263_boards[] = {
#endif
};

#ifdef CONFIG_COMEDI_PCI
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263) },
{0}
};

MODULE_DEVICE_TABLE(pci, pc263_pci_table);
#endif /* CONFIG_COMEDI_PCI */
#endif /* CONFIG_COMEDI_AMPLC_PC263_PCI */

/*
* Useful for shorthand access to the particular board structure
Expand All @@ -117,14 +125,14 @@ MODULE_DEVICE_TABLE(pci, pc263_pci_table);
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct.
*/
#ifdef CONFIG_COMEDI_PCI
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
struct pc263_private {
/* PCI device. */
struct pci_dev *pci_dev;
};

#define devpriv ((struct pc263_private *)dev->private)
#endif /* CONFIG_COMEDI_PCI */
#endif /* CONFIG_COMEDI_AMPLC_PC263_PCI */

/*
* The struct comedi_driver structure tells the Comedi core module
Expand All @@ -144,8 +152,10 @@ static struct comedi_driver driver_amplc_pc263 = {
.num_names = ARRAY_SIZE(pc263_boards),
};

#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
static int pc263_request_region(unsigned minor, unsigned long from,
unsigned long extent);
#endif
static int pc263_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
Expand All @@ -157,7 +167,7 @@ static int pc263_dio_insn_config(struct comedi_device *dev,
* This function looks for a PCI device matching the requested board name,
* bus and slot.
*/
#ifdef CONFIG_COMEDI_PCI
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
static int
pc263_find_pci(struct comedi_device *dev, int bus, int slot,
struct pci_dev **pci_dev_p)
Expand Down Expand Up @@ -225,7 +235,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase = 0;
#ifdef CONFIG_COMEDI_PCI
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
struct pci_dev *pci_dev = NULL;
int bus = 0, slot = 0;
#endif
Expand All @@ -237,7 +247,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
* Allocate the private structure area. alloc_private() is a
* convenient macro defined in comedidev.h.
*/
#ifdef CONFIG_COMEDI_PCI
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
ret = alloc_private(dev, sizeof(struct pc263_private));
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
Expand All @@ -247,10 +257,12 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#endif
/* Process options. */
switch (thisboard->bustype) {
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
case isa_bustype:
iobase = it->options[0];
break;
#ifdef CONFIG_COMEDI_PCI
#endif
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
case pci_bustype:
bus = it->options[0];
slot = it->options[1];
Expand All @@ -260,7 +272,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return ret;
devpriv->pci_dev = pci_dev;
break;
#endif /* CONFIG_COMEDI_PCI */
#endif
default:
printk(KERN_ERR
"comedi%d: %s: BUG! cannot determine board type!\n",
Expand All @@ -275,7 +287,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = thisboard->name;

/* Enable device and reserve I/O spaces. */
#ifdef CONFIG_COMEDI_PCI
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
if (pci_dev) {
ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME);
if (ret < 0) {
Expand All @@ -289,9 +301,11 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
} else
#endif
{
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
ret = pc263_request_region(dev->minor, iobase, PC263_IO_SIZE);
if (ret < 0)
return ret;
#endif
}
dev->iobase = iobase;

Expand Down Expand Up @@ -322,12 +336,18 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->state = s->state | (inb(dev->iobase) << 8);

printk(KERN_INFO "comedi%d: %s ", dev->minor, dev->board_name);
if (thisboard->bustype == isa_bustype) {
switch (thisboard->bustype) {
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
case isa_bustype:
printk("(base %#lx) ", iobase);
} else {
#ifdef CONFIG_COMEDI_PCI
break;
#endif
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
printk("(pci %s) ", pci_name(pci_dev));
break;
#endif
default:
break;
}

printk("attached\n");
Expand All @@ -348,19 +368,22 @@ static int pc263_detach(struct comedi_device *dev)
printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
PC263_DRIVER_NAME);

#ifdef CONFIG_COMEDI_PCI
if (devpriv) {
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
if (devpriv)
#endif
#ifdef CONFIG_COMEDI_PCI
{
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
if (devpriv->pci_dev) {
if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
} else
#endif
{
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
if (dev->iobase)
release_region(dev->iobase, PC263_IO_SIZE);
#endif
}
}
if (dev->board_name) {
Expand All @@ -374,6 +397,7 @@ static int pc263_detach(struct comedi_device *dev)
* This function checks and requests an I/O region, reporting an error
* if there is a conflict.
*/
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
static int pc263_request_region(unsigned minor, unsigned long from,
unsigned long extent)
{
Expand All @@ -384,6 +408,7 @@ static int pc263_request_region(unsigned minor, unsigned long from,
}
return 0;
}
#endif

/* DIO devices are slightly special. Although it is possible to
* implement the insn_read/insn_write interface, it is much more
Expand Down Expand Up @@ -429,7 +454,7 @@ static int pc263_dio_insn_config(struct comedi_device *dev,
* A convenient macro that defines init_module() and cleanup_module(),
* as necessary.
*/
#ifdef CONFIG_COMEDI_PCI
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
static int __devinit driver_amplc_pc263_pci_probe(struct pci_dev *dev,
const struct pci_device_id
*ent)
Expand Down

0 comments on commit f540663

Please sign in to comment.