Commit 3e6be97e authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: amplc_pc263: separately configure ISA and PCI

The amplc_pc263 driver supports both ISA and PCI cards, but currently
it is only possible to select the driver if PCI is configured.  This
patch splits the configuration to make the ISA and PCI parts seperately
selectable, and changes the driver to only include the selected ISA
and/or PCI board types.

Also fix a conditionally mismatched brace in pc263_detach().
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 717ab674
...@@ -233,6 +233,16 @@ config COMEDI_AMPLC_PC236_ISA ...@@ -233,6 +233,16 @@ config COMEDI_AMPLC_PC236_ISA
To compile this driver as a module, choose M here: the module will be To compile this driver as a module, choose M here: the module will be
called amplc_pc236. 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 config COMEDI_RTI800
tristate "Analog Devices RTI-800/815 ISA card support" tristate "Analog Devices RTI-800/815 ISA card support"
default N default N
...@@ -814,11 +824,12 @@ config COMEDI_AMPLC_PC236_PCI ...@@ -814,11 +824,12 @@ config COMEDI_AMPLC_PC236_PCI
To compile this driver as a module, choose M here: the module will be To compile this driver as a module, choose M here: the module will be
called amplc_pc236. called amplc_pc236.
config COMEDI_AMPLC_PC263 config COMEDI_AMPLC_PC263_PCI
tristate "Amplicon PC263 and PCI263 relay board support" tristate "Amplicon PCI263 relay board support"
select COMEDI_AMPLC_PC263
default N default N
---help--- ---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 To compile this driver as a module, choose M here: the module will be
called amplc_pc263. called amplc_pc263.
...@@ -1414,3 +1425,7 @@ config COMEDI_AMPLC_PC236 ...@@ -1414,3 +1425,7 @@ config COMEDI_AMPLC_PC236
def_tristate N def_tristate N
depends on COMEDI depends on COMEDI
select COMEDI_8255 select COMEDI_8255
config COMEDI_AMPLC_PC263
def_tristate N
depends on COMEDI
...@@ -50,6 +50,14 @@ The state of the outputs can be read. ...@@ -50,6 +50,14 @@ The state of the outputs can be read.
#define PC263_DRIVER_NAME "amplc_pc263" #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 */ /* PCI263 PCI configuration register information */
#define PCI_VENDOR_ID_AMPLICON 0x14dc #define PCI_VENDOR_ID_AMPLICON 0x14dc
#define PCI_DEVICE_ID_AMPLICON_PCI263 0x000c #define PCI_DEVICE_ID_AMPLICON_PCI263 0x000c
...@@ -73,13 +81,15 @@ struct pc263_board { ...@@ -73,13 +81,15 @@ struct pc263_board {
enum pc263_model model; enum pc263_model model;
}; };
static const struct pc263_board pc263_boards[] = { static const struct pc263_board pc263_boards[] = {
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
{ {
.name = "pc263", .name = "pc263",
.fancy_name = "PC263", .fancy_name = "PC263",
.bustype = isa_bustype, .bustype = isa_bustype,
.model = pc263_model, .model = pc263_model,
}, },
#ifdef CONFIG_COMEDI_PCI #endif
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
{ {
.name = "pci263", .name = "pci263",
.fancy_name = "PCI263", .fancy_name = "PCI263",
...@@ -87,8 +97,6 @@ static const struct pc263_board pc263_boards[] = { ...@@ -87,8 +97,6 @@ static const struct pc263_board pc263_boards[] = {
.bustype = pci_bustype, .bustype = pci_bustype,
.model = pci263_model, .model = pci263_model,
}, },
#endif
#ifdef CONFIG_COMEDI_PCI
{ {
.name = PC263_DRIVER_NAME, .name = PC263_DRIVER_NAME,
.fancy_name = PC263_DRIVER_NAME, .fancy_name = PC263_DRIVER_NAME,
...@@ -99,14 +107,14 @@ static const struct pc263_board pc263_boards[] = { ...@@ -99,14 +107,14 @@ static const struct pc263_board pc263_boards[] = {
#endif #endif
}; };
#ifdef CONFIG_COMEDI_PCI #ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = { static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263) }, { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263) },
{0} {0}
}; };
MODULE_DEVICE_TABLE(pci, pc263_pci_table); 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 * Useful for shorthand access to the particular board structure
...@@ -117,14 +125,14 @@ MODULE_DEVICE_TABLE(pci, pc263_pci_table); ...@@ -117,14 +125,14 @@ MODULE_DEVICE_TABLE(pci, pc263_pci_table);
several hardware drivers keep similar information in this structure, several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct. 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 { struct pc263_private {
/* PCI device. */ /* PCI device. */
struct pci_dev *pci_dev; struct pci_dev *pci_dev;
}; };
#define devpriv ((struct pc263_private *)dev->private) #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 * The struct comedi_driver structure tells the Comedi core module
...@@ -144,8 +152,10 @@ static struct comedi_driver driver_amplc_pc263 = { ...@@ -144,8 +152,10 @@ static struct comedi_driver driver_amplc_pc263 = {
.num_names = ARRAY_SIZE(pc263_boards), .num_names = ARRAY_SIZE(pc263_boards),
}; };
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
static int pc263_request_region(unsigned minor, unsigned long from, static int pc263_request_region(unsigned minor, unsigned long from,
unsigned long extent); unsigned long extent);
#endif
static int pc263_dio_insn_bits(struct comedi_device *dev, static int pc263_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data); struct comedi_insn *insn, unsigned int *data);
...@@ -157,7 +167,7 @@ static int pc263_dio_insn_config(struct comedi_device *dev, ...@@ -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, * This function looks for a PCI device matching the requested board name,
* bus and slot. * bus and slot.
*/ */
#ifdef CONFIG_COMEDI_PCI #ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
static int static int
pc263_find_pci(struct comedi_device *dev, int bus, int slot, pc263_find_pci(struct comedi_device *dev, int bus, int slot,
struct pci_dev **pci_dev_p) struct pci_dev **pci_dev_p)
...@@ -225,7 +235,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -225,7 +235,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{ {
struct comedi_subdevice *s; struct comedi_subdevice *s;
unsigned long iobase = 0; unsigned long iobase = 0;
#ifdef CONFIG_COMEDI_PCI #ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
struct pci_dev *pci_dev = NULL; struct pci_dev *pci_dev = NULL;
int bus = 0, slot = 0; int bus = 0, slot = 0;
#endif #endif
...@@ -237,7 +247,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -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 * Allocate the private structure area. alloc_private() is a
* convenient macro defined in comedidev.h. * convenient macro defined in comedidev.h.
*/ */
#ifdef CONFIG_COMEDI_PCI #ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
ret = alloc_private(dev, sizeof(struct pc263_private)); ret = alloc_private(dev, sizeof(struct pc263_private));
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n", printk(KERN_ERR "comedi%d: error! out of memory!\n",
...@@ -247,10 +257,12 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -247,10 +257,12 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#endif #endif
/* Process options. */ /* Process options. */
switch (thisboard->bustype) { switch (thisboard->bustype) {
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
case isa_bustype: case isa_bustype:
iobase = it->options[0]; iobase = it->options[0];
break; break;
#ifdef CONFIG_COMEDI_PCI #endif
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
case pci_bustype: case pci_bustype:
bus = it->options[0]; bus = it->options[0];
slot = it->options[1]; slot = it->options[1];
...@@ -260,7 +272,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -260,7 +272,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return ret; return ret;
devpriv->pci_dev = pci_dev; devpriv->pci_dev = pci_dev;
break; break;
#endif /* CONFIG_COMEDI_PCI */ #endif
default: default:
printk(KERN_ERR printk(KERN_ERR
"comedi%d: %s: BUG! cannot determine board type!\n", "comedi%d: %s: BUG! cannot determine board type!\n",
...@@ -275,7 +287,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -275,7 +287,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = thisboard->name; dev->board_name = thisboard->name;
/* Enable device and reserve I/O spaces. */ /* Enable device and reserve I/O spaces. */
#ifdef CONFIG_COMEDI_PCI #ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
if (pci_dev) { if (pci_dev) {
ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME); ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME);
if (ret < 0) { if (ret < 0) {
...@@ -289,9 +301,11 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -289,9 +301,11 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
} else } else
#endif #endif
{ {
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
ret = pc263_request_region(dev->minor, iobase, PC263_IO_SIZE); ret = pc263_request_region(dev->minor, iobase, PC263_IO_SIZE);
if (ret < 0) if (ret < 0)
return ret; return ret;
#endif
} }
dev->iobase = iobase; dev->iobase = iobase;
...@@ -322,12 +336,18 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -322,12 +336,18 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->state = s->state | (inb(dev->iobase) << 8); s->state = s->state | (inb(dev->iobase) << 8);
printk(KERN_INFO "comedi%d: %s ", dev->minor, dev->board_name); 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); printk("(base %#lx) ", iobase);
} else { break;
#ifdef CONFIG_COMEDI_PCI #endif
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
printk("(pci %s) ", pci_name(pci_dev)); printk("(pci %s) ", pci_name(pci_dev));
break;
#endif #endif
default:
break;
} }
printk("attached\n"); printk("attached\n");
...@@ -348,10 +368,11 @@ static int pc263_detach(struct comedi_device *dev) ...@@ -348,10 +368,11 @@ static int pc263_detach(struct comedi_device *dev)
printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
PC263_DRIVER_NAME); PC263_DRIVER_NAME);
#ifdef CONFIG_COMEDI_PCI #ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
if (devpriv) { if (devpriv)
#endif #endif
#ifdef CONFIG_COMEDI_PCI {
#ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
if (devpriv->pci_dev) { if (devpriv->pci_dev) {
if (dev->iobase) if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev); comedi_pci_disable(devpriv->pci_dev);
...@@ -359,8 +380,10 @@ static int pc263_detach(struct comedi_device *dev) ...@@ -359,8 +380,10 @@ static int pc263_detach(struct comedi_device *dev)
} else } else
#endif #endif
{ {
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
if (dev->iobase) if (dev->iobase)
release_region(dev->iobase, PC263_IO_SIZE); release_region(dev->iobase, PC263_IO_SIZE);
#endif
} }
} }
if (dev->board_name) { if (dev->board_name) {
...@@ -374,6 +397,7 @@ static int pc263_detach(struct comedi_device *dev) ...@@ -374,6 +397,7 @@ static int pc263_detach(struct comedi_device *dev)
* This function checks and requests an I/O region, reporting an error * This function checks and requests an I/O region, reporting an error
* if there is a conflict. * if there is a conflict.
*/ */
#ifdef CONFIG_COMEDI_AMPLC_PC263_ISA
static int pc263_request_region(unsigned minor, unsigned long from, static int pc263_request_region(unsigned minor, unsigned long from,
unsigned long extent) unsigned long extent)
{ {
...@@ -384,6 +408,7 @@ static int pc263_request_region(unsigned minor, unsigned long from, ...@@ -384,6 +408,7 @@ static int pc263_request_region(unsigned minor, unsigned long from,
} }
return 0; return 0;
} }
#endif
/* DIO devices are slightly special. Although it is possible to /* DIO devices are slightly special. Although it is possible to
* implement the insn_read/insn_write interface, it is much more * implement the insn_read/insn_write interface, it is much more
...@@ -429,7 +454,7 @@ static int pc263_dio_insn_config(struct comedi_device *dev, ...@@ -429,7 +454,7 @@ static int pc263_dio_insn_config(struct comedi_device *dev,
* A convenient macro that defines init_module() and cleanup_module(), * A convenient macro that defines init_module() and cleanup_module(),
* as necessary. * as necessary.
*/ */
#ifdef CONFIG_COMEDI_PCI #ifdef CONFIG_COMEDI_AMPLC_PC263_PCI
static int __devinit driver_amplc_pc263_pci_probe(struct pci_dev *dev, static int __devinit driver_amplc_pc263_pci_probe(struct pci_dev *dev,
const struct pci_device_id const struct pci_device_id
*ent) *ent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment