Commit ee34785c authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: pcl816: clarify dma channel request in pcl816_attach()

All the board types can do DMA using DMA channels 3 or 1. Remove the 'DMAbits',
which is a mask of the valid channels, from the boardinfo.

Refactor pcl816_attach() to remove the need for the goto.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 27f3f4d4
...@@ -100,7 +100,6 @@ struct pcl816_board { ...@@ -100,7 +100,6 @@ struct pcl816_board {
int n_dochan; int n_dochan;
const struct comedi_lrange *ai_range_type; const struct comedi_lrange *ai_range_type;
unsigned int IRQbits; unsigned int IRQbits;
unsigned int DMAbits;
int ai_maxdata; int ai_maxdata;
int ao_maxdata; int ao_maxdata;
int ai_chanlist; int ai_chanlist;
...@@ -118,7 +117,6 @@ static const struct pcl816_board boardtypes[] = { ...@@ -118,7 +117,6 @@ static const struct pcl816_board boardtypes[] = {
.n_dochan = 16, .n_dochan = 16,
.ai_range_type = &range_pcl816, .ai_range_type = &range_pcl816,
.IRQbits = 0x00fc, .IRQbits = 0x00fc,
.DMAbits = 0x0a,
.ai_maxdata = 0xffff, .ai_maxdata = 0xffff,
.ao_maxdata = 0xffff, .ao_maxdata = 0xffff,
.ai_chanlist = 1024, .ai_chanlist = 1024,
...@@ -133,7 +131,6 @@ static const struct pcl816_board boardtypes[] = { ...@@ -133,7 +131,6 @@ static const struct pcl816_board boardtypes[] = {
.n_dochan = 16, .n_dochan = 16,
.ai_range_type = &range_pcl816, .ai_range_type = &range_pcl816,
.IRQbits = 0x00fc, .IRQbits = 0x00fc,
.DMAbits = 0x0a,
.ai_maxdata = 0x3fff, .ai_maxdata = 0x3fff,
.ao_maxdata = 0x3fff, .ao_maxdata = 0x3fff,
.ai_chanlist = 1024, .ai_chanlist = 1024,
...@@ -866,7 +863,6 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -866,7 +863,6 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
const struct pcl816_board *board = comedi_board(dev); const struct pcl816_board *board = comedi_board(dev);
struct pcl816_private *devpriv; struct pcl816_private *devpriv;
int ret; int ret;
unsigned int dma;
unsigned long pages; unsigned long pages;
/* int i; */ /* int i; */
struct comedi_subdevice *s; struct comedi_subdevice *s;
...@@ -894,30 +890,17 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -894,30 +890,17 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->irq_blocked = 0; /* number of subdevice which use IRQ */ devpriv->irq_blocked = 0; /* number of subdevice which use IRQ */
devpriv->int816_mode = 0; /* mode of irq */ devpriv->int816_mode = 0; /* mode of irq */
/* grab our DMA */ /* we need an IRQ to do DMA on channel 3 or 1 */
dma = 0; if (dev->irq && (it->options[2] == 3 || it->options[2] == 1)) {
devpriv->dma = dma; ret = request_dma(it->options[2], dev->board_name);
if (!dev->irq)
goto no_dma; /* if we haven't IRQ, we can't use DMA */
if (board->DMAbits != 0) { /* board support DMA */
dma = it->options[2];
if (dma < 1)
goto no_dma; /* DMA disabled */
if (((1 << dma) & board->DMAbits) == 0) {
dev_err(dev->class_dev,
"DMA is out of allowed range, FAIL!\n");
return -EINVAL; /* Bad DMA */
}
ret = request_dma(dma, dev->board_name);
if (ret) { if (ret) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"unable to allocate DMA %u, FAIL!\n", dma); "unable to request DMA channel %d\n",
return -EBUSY; /* DMA isn't free */ it->options[2]);
return -EBUSY;
} }
devpriv->dma = it->options[2];
devpriv->dma = dma;
pages = 2; /* we need 16KB */ pages = 2; /* we need 16KB */
devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages);
...@@ -945,8 +928,6 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -945,8 +928,6 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->hwdmasize[1] = (1 << pages) * PAGE_SIZE; devpriv->hwdmasize[1] = (1 << pages) * PAGE_SIZE;
} }
no_dma:
/* if (board->n_aochan > 0) /* if (board->n_aochan > 0)
subdevs[1] = COMEDI_SUBD_AO; subdevs[1] = COMEDI_SUBD_AO;
if (board->n_dichan > 0) if (board->n_dichan > 0)
......
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