Only the ISA versions of the LabPC boards support DMA. Move the DMA initialization out of the labpc_common_attach() and put it in the ISA specific labpc_attach() function. Remove the 'dma_chan' parameter from labpc_common_attach(). Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/ni_labpc.c | 50 +++++++++++++++------------ drivers/staging/comedi/drivers/ni_labpc.h | 2 +- drivers/staging/comedi/drivers/ni_labpc_cs.c | 2 +- drivers/staging/comedi/drivers/ni_labpc_pci.c | 2 +- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index e8fc6a1..56fb5b2 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -1588,7 +1588,7 @@ static int labpc_eeprom_insn_read(struct comedi_device *dev, } int labpc_common_attach(struct comedi_device *dev, - unsigned int irq, unsigned int dma_chan) + unsigned int irq) { const struct labpc_boardinfo *board = comedi_board(dev); struct labpc_private *devpriv = dev->private; @@ -1626,27 +1626,6 @@ int labpc_common_attach(struct comedi_device *dev, dev->irq = irq; } -#ifdef CONFIG_ISA_DMA_API - if (dev->irq && (dma_chan == 1 || dma_chan == 3)) { - devpriv->dma_buffer = kmalloc(dma_buffer_size, - GFP_KERNEL | GFP_DMA); - if (devpriv->dma_buffer) { - ret = request_dma(dma_chan, dev->board_name); - if (ret == 0) { - unsigned long dma_flags; - - devpriv->dma_chan = dma_chan; - dma_flags = claim_dma_lock(); - disable_dma(devpriv->dma_chan); - set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); - release_dma_lock(dma_flags); - } else { - kfree(devpriv->dma_buffer); - } - } - } -#endif - ret = comedi_alloc_subdevices(dev, 5); if (ret) return ret; @@ -1759,7 +1738,32 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - return labpc_common_attach(dev, irq, dma_chan); + ret = labpc_common_attach(dev, irq); + if (ret) + return ret; + +#ifdef CONFIG_ISA_DMA_API + if (dev->irq && (dma_chan == 1 || dma_chan == 3)) { + devpriv->dma_buffer = kmalloc(dma_buffer_size, + GFP_KERNEL | GFP_DMA); + if (devpriv->dma_buffer) { + ret = request_dma(dma_chan, dev->board_name); + if (ret == 0) { + unsigned long dma_flags; + + devpriv->dma_chan = dma_chan; + dma_flags = claim_dma_lock(); + disable_dma(devpriv->dma_chan); + set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); + release_dma_lock(dma_flags); + } else { + kfree(devpriv->dma_buffer); + } + } + } +#endif + + return 0; } void labpc_detach(struct comedi_device *dev) diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index e214bb9..7f8a828 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -101,7 +101,7 @@ struct labpc_private { }; int labpc_common_attach(struct comedi_device *dev, - unsigned int irq, unsigned int dma); + unsigned int irq); void labpc_common_detach(struct comedi_device *dev); extern const int labpc_1200_ai_gain_bits[]; diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c index f9cb9cf..4b4a72d 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_cs.c +++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c @@ -111,7 +111,7 @@ static int labpc_auto_attach(struct comedi_device *dev, return -ENOMEM; dev->private = devpriv; - return labpc_common_attach(dev, link->irq, 0); + return labpc_common_attach(dev, link->irq); } static void labpc_detach(struct comedi_device *dev) diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c b/drivers/staging/comedi/drivers/ni_labpc_pci.c index 82e381f..13ae267 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_pci.c +++ b/drivers/staging/comedi/drivers/ni_labpc_pci.c @@ -92,7 +92,7 @@ static int labpc_pci_auto_attach(struct comedi_device *dev, return ret; dev->iobase = (unsigned long)devpriv->mite->daq_io_addr; - return labpc_common_attach(dev, mite_irq(devpriv->mite), 0); + return labpc_common_attach(dev, mite_irq(devpriv->mite)); } static void labpc_pci_detach(struct comedi_device *dev) -- 1.8.1.4 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel