Skip to content

Commit d1d24cb

Browse files
bigguinessgregkh
authored andcommitted
staging: comedi: das6402: read analog input samples in interrupt handler
Currently the interrupt handler just clears the interrupt. Add the code necessary to read the analog input samples when running an async command. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3e0a738 commit d1d24cb

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

Diff for: drivers/staging/comedi/drivers/das6402.c

+35-7
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,46 @@ static void das6402_enable_counter(struct comedi_device *dev, bool load)
193193
}
194194
}
195195

196+
static unsigned int das6402_ai_read_sample(struct comedi_device *dev,
197+
struct comedi_subdevice *s)
198+
{
199+
unsigned int val;
200+
201+
val = inw(dev->iobase + DAS6402_AI_DATA_REG);
202+
if (s->maxdata == 0x0fff)
203+
val >>= 4;
204+
return val;
205+
}
206+
196207
static irqreturn_t das6402_interrupt(int irq, void *d)
197208
{
198209
struct comedi_device *dev = d;
210+
struct comedi_subdevice *s = dev->read_subdev;
211+
struct comedi_async *async = s->async;
212+
struct comedi_cmd *cmd = &async->cmd;
213+
unsigned int status;
214+
215+
status = inb(dev->iobase + DAS6402_STATUS_REG);
216+
if ((status & DAS6402_STATUS_INT) == 0)
217+
return IRQ_NONE;
218+
219+
if (status & DAS6402_STATUS_FFULL) {
220+
async->events |= COMEDI_CB_OVERFLOW;
221+
} else if (status & DAS6402_STATUS_FFNE) {
222+
unsigned int val;
223+
224+
val = das6402_ai_read_sample(dev, s);
225+
comedi_buf_write_samples(s, &val, 1);
226+
227+
if (cmd->stop_src == TRIG_COUNT &&
228+
async->scans_done >= cmd->stop_arg)
229+
async->events |= COMEDI_CB_EOA;
230+
}
199231

200232
das6402_clear_all_interrupts(dev);
201233

234+
comedi_handle_events(dev, s);
235+
202236
return IRQ_HANDLED;
203237
}
204238

@@ -367,7 +401,6 @@ static int das6402_ai_insn_read(struct comedi_device *dev,
367401
{
368402
unsigned int chan = CR_CHAN(insn->chanspec);
369403
unsigned int aref = CR_AREF(insn->chanspec);
370-
unsigned int val;
371404
int ret;
372405
int i;
373406

@@ -391,12 +424,7 @@ static int das6402_ai_insn_read(struct comedi_device *dev,
391424
if (ret)
392425
break;
393426

394-
val = inw(dev->iobase + DAS6402_AI_DATA_REG);
395-
396-
if (s->maxdata == 0x0fff)
397-
val >>= 4;
398-
399-
data[i] = val;
427+
data[i] = das6402_ai_read_sample(dev, s);
400428
}
401429

402430
das6402_ai_clear_eoc(dev);

0 commit comments

Comments
 (0)