Commit 3297d6c7 authored by Randy Dunlap's avatar Randy Dunlap Committed by Greg Kroah-Hartman

staging: fix comedi NI labpc driver build when ISA_DMA_API is not enabled

Fix ni_labpc.c to build when CONFIG_ISA_DMA_API is not enabled.

This is a driver that supports both ISA and PCI devices.
It now builds when for PCI-only support or for both
ISA and PCI device support.
(It does not support ISA-only without PCI.)
Signed-off-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 819cbb12
...@@ -213,8 +213,10 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it); ...@@ -213,8 +213,10 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it);
static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static irqreturn_t labpc_interrupt(int irq, void *d); static irqreturn_t labpc_interrupt(int irq, void *d);
static int labpc_drain_fifo(struct comedi_device *dev); static int labpc_drain_fifo(struct comedi_device *dev);
#ifdef CONFIG_ISA_DMA_API
static void labpc_drain_dma(struct comedi_device *dev); static void labpc_drain_dma(struct comedi_device *dev);
static void handle_isa_dma(struct comedi_device *dev); static void handle_isa_dma(struct comedi_device *dev);
#endif
static void labpc_drain_dregs(struct comedi_device *dev); static void labpc_drain_dregs(struct comedi_device *dev);
static int labpc_ai_cmdtest(struct comedi_device *dev, static int labpc_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd); struct comedi_subdevice *s, struct comedi_cmd *cmd);
...@@ -238,9 +240,9 @@ static int labpc_eeprom_write_insn(struct comedi_device *dev, ...@@ -238,9 +240,9 @@ static int labpc_eeprom_write_insn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data); unsigned int *data);
static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd);
static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd); static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd);
#ifdef CONFIG_COMEDI_PCI #ifdef CONFIG_COMEDI_PCI
static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd);
static int labpc_find_device(struct comedi_device *dev, int bus, int slot); static int labpc_find_device(struct comedi_device *dev, int bus, int slot);
#endif #endif
static int labpc_dio_mem_callback(int dir, int port, int data, static int labpc_dio_mem_callback(int dir, int port, int data,
...@@ -527,7 +529,10 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, ...@@ -527,7 +529,10 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
{ {
struct comedi_subdevice *s; struct comedi_subdevice *s;
int i; int i;
unsigned long dma_flags, isr_flags; unsigned long isr_flags;
#ifdef CONFIG_ISA_DMA_API
unsigned long dma_flags;
#endif
short lsb, msb; short lsb, msb;
printk(KERN_ERR "comedi%d: ni_labpc: %s, io 0x%lx", dev->minor, printk(KERN_ERR "comedi%d: ni_labpc: %s, io 0x%lx", dev->minor,
...@@ -587,6 +592,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, ...@@ -587,6 +592,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
} }
dev->irq = irq; dev->irq = irq;
#ifdef CONFIG_ISA_DMA_API
/* grab dma channel */ /* grab dma channel */
if (dma_chan > 3) { if (dma_chan > 3) {
printk(KERN_ERR " invalid dma channel %u\n", dma_chan); printk(KERN_ERR " invalid dma channel %u\n", dma_chan);
...@@ -610,6 +616,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, ...@@ -610,6 +616,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); set_dma_mode(devpriv->dma_chan, DMA_MODE_READ);
release_dma_lock(dma_flags); release_dma_lock(dma_flags);
} }
#endif
dev->board_name = thisboard->name; dev->board_name = thisboard->name;
...@@ -724,9 +731,15 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -724,9 +731,15 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* get base address, irq etc. based on bustype */ /* get base address, irq etc. based on bustype */
switch (thisboard->bustype) { switch (thisboard->bustype) {
case isa_bustype: case isa_bustype:
#ifdef CONFIG_ISA_DMA_API
iobase = it->options[0]; iobase = it->options[0];
irq = it->options[1]; irq = it->options[1];
dma_chan = it->options[2]; dma_chan = it->options[2];
#else
printk(KERN_ERR " this driver has not been built with ISA DMA "
"support.\n");
return -EINVAL;
#endif
break; break;
case pci_bustype: case pci_bustype:
#ifdef CONFIG_COMEDI_PCI #ifdef CONFIG_COMEDI_PCI
...@@ -797,10 +810,12 @@ int labpc_common_detach(struct comedi_device *dev) ...@@ -797,10 +810,12 @@ int labpc_common_detach(struct comedi_device *dev)
if (dev->subdevices) if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 2); subdev_8255_cleanup(dev, dev->subdevices + 2);
#ifdef CONFIG_ISA_DMA_API
/* only free stuff if it has been allocated by _attach */ /* only free stuff if it has been allocated by _attach */
kfree(devpriv->dma_buffer); kfree(devpriv->dma_buffer);
if (devpriv->dma_chan) if (devpriv->dma_chan)
free_dma(devpriv->dma_chan); free_dma(devpriv->dma_chan);
#endif
if (dev->irq) if (dev->irq)
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
if (thisboard->bustype == isa_bustype && dev->iobase) if (thisboard->bustype == isa_bustype && dev->iobase)
...@@ -1135,7 +1150,9 @@ static int labpc_ai_cmdtest(struct comedi_device *dev, ...@@ -1135,7 +1150,9 @@ static int labpc_ai_cmdtest(struct comedi_device *dev,
static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{ {
int channel, range, aref; int channel, range, aref;
#ifdef CONFIG_ISA_DMA_API
unsigned long irq_flags; unsigned long irq_flags;
#endif
int ret; int ret;
struct comedi_async *async = s->async; struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd; struct comedi_cmd *cmd = &async->cmd;
...@@ -1182,6 +1199,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -1182,6 +1199,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->write_byte(INIT_A1_BITS, devpriv->write_byte(INIT_A1_BITS,
dev->iobase + COUNTER_A_CONTROL_REG); dev->iobase + COUNTER_A_CONTROL_REG);
#ifdef CONFIG_ISA_DMA_API
/* figure out what method we will use to transfer data */ /* figure out what method we will use to transfer data */
if (devpriv->dma_chan && /* need a dma channel allocated */ if (devpriv->dma_chan && /* need a dma channel allocated */
/* /*
...@@ -1193,7 +1211,9 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -1193,7 +1211,9 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
thisboard->bustype == isa_bustype) { thisboard->bustype == isa_bustype) {
xfer = isa_dma_transfer; xfer = isa_dma_transfer;
/* pc-plus has no fifo-half full interrupt */ /* pc-plus has no fifo-half full interrupt */
} else if (thisboard->register_layout == labpc_1200_layout && } else
#endif
if (thisboard->register_layout == labpc_1200_layout &&
/* wake-end-of-scan should interrupt on fifo not empty */ /* wake-end-of-scan should interrupt on fifo not empty */
(cmd->flags & TRIG_WAKE_EOS) == 0 && (cmd->flags & TRIG_WAKE_EOS) == 0 &&
/* make sure we are taking more than just a few points */ /* make sure we are taking more than just a few points */
...@@ -1317,6 +1337,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -1317,6 +1337,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
labpc_clear_adc_fifo(dev); labpc_clear_adc_fifo(dev);
#ifdef CONFIG_ISA_DMA_API
/* set up dma transfer */ /* set up dma transfer */
if (xfer == isa_dma_transfer) { if (xfer == isa_dma_transfer) {
irq_flags = claim_dma_lock(); irq_flags = claim_dma_lock();
...@@ -1340,6 +1361,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -1340,6 +1361,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->command3_bits |= DMA_EN_BIT | DMATC_INTR_EN_BIT; devpriv->command3_bits |= DMA_EN_BIT | DMATC_INTR_EN_BIT;
} else } else
devpriv->command3_bits &= ~DMA_EN_BIT & ~DMATC_INTR_EN_BIT; devpriv->command3_bits &= ~DMA_EN_BIT & ~DMATC_INTR_EN_BIT;
#endif
/* enable error interrupts */ /* enable error interrupts */
devpriv->command3_bits |= ERR_INTR_EN_BIT; devpriv->command3_bits |= ERR_INTR_EN_BIT;
...@@ -1426,6 +1448,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d) ...@@ -1426,6 +1448,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
#ifdef CONFIG_ISA_DMA_API
if (devpriv->current_transfer == isa_dma_transfer) { if (devpriv->current_transfer == isa_dma_transfer) {
/* /*
* if a dma terminal count of external stop trigger * if a dma terminal count of external stop trigger
...@@ -1437,6 +1460,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d) ...@@ -1437,6 +1460,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
handle_isa_dma(dev); handle_isa_dma(dev);
} }
} else } else
#endif
labpc_drain_fifo(dev); labpc_drain_fifo(dev);
if (devpriv->status1_bits & TIMER_BIT) { if (devpriv->status1_bits & TIMER_BIT) {
...@@ -1509,6 +1533,7 @@ static int labpc_drain_fifo(struct comedi_device *dev) ...@@ -1509,6 +1533,7 @@ static int labpc_drain_fifo(struct comedi_device *dev)
return 0; return 0;
} }
#ifdef CONFIG_ISA_DMA_API
static void labpc_drain_dma(struct comedi_device *dev) static void labpc_drain_dma(struct comedi_device *dev)
{ {
struct comedi_subdevice *s = dev->read_subdev; struct comedi_subdevice *s = dev->read_subdev;
...@@ -1571,13 +1596,16 @@ static void handle_isa_dma(struct comedi_device *dev) ...@@ -1571,13 +1596,16 @@ static void handle_isa_dma(struct comedi_device *dev)
/* clear dma tc interrupt */ /* clear dma tc interrupt */
devpriv->write_byte(0x1, dev->iobase + DMATC_CLEAR_REG); devpriv->write_byte(0x1, dev->iobase + DMATC_CLEAR_REG);
} }
#endif
/* makes sure all data acquired by board is transferred to comedi (used /* makes sure all data acquired by board is transferred to comedi (used
* when acquisition is terminated by stop_src == TRIG_EXT). */ * when acquisition is terminated by stop_src == TRIG_EXT). */
static void labpc_drain_dregs(struct comedi_device *dev) static void labpc_drain_dregs(struct comedi_device *dev)
{ {
#ifdef CONFIG_ISA_DMA_API
if (devpriv->current_transfer == isa_dma_transfer) if (devpriv->current_transfer == isa_dma_transfer)
labpc_drain_dma(dev); labpc_drain_dma(dev);
#endif
labpc_drain_fifo(dev); labpc_drain_fifo(dev);
} }
...@@ -1769,6 +1797,7 @@ static int labpc_eeprom_write_insn(struct comedi_device *dev, ...@@ -1769,6 +1797,7 @@ static int labpc_eeprom_write_insn(struct comedi_device *dev,
return 1; return 1;
} }
#ifdef CONFIG_ISA_DMA_API
/* utility function that suggests a dma transfer size in bytes */ /* utility function that suggests a dma transfer size in bytes */
static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd) static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd)
{ {
...@@ -1792,6 +1821,7 @@ static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd) ...@@ -1792,6 +1821,7 @@ static unsigned int labpc_suggest_transfer_size(struct comedi_cmd cmd)
return size; return size;
} }
#endif
/* figures out what counter values to use based on command */ /* figures out what counter values to use based on command */
static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd) static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
......
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