@@ -276,31 +276,6 @@ struct pci1710_private {
276
276
* internal state */
277
277
};
278
278
279
- static int pci171x_ai_dropout (struct comedi_device * dev ,
280
- struct comedi_subdevice * s ,
281
- unsigned int chan ,
282
- unsigned int val )
283
- {
284
- const struct boardtype * board = dev -> board_ptr ;
285
- struct pci1710_private * devpriv = dev -> private ;
286
-
287
- if (!board -> is_pci1713 ) {
288
- /*
289
- * The upper 4 bits of the 16-bit sample are the channel number
290
- * that the sample was acquired from. Verify that this channel
291
- * number matches the expected channel number.
292
- */
293
- val >>= 12 ;
294
- if (val != devpriv -> act_chanlist [chan ]) {
295
- dev_err (dev -> class_dev ,
296
- "A/D data droput: received from channel %d, expected %d\n" ,
297
- val , devpriv -> act_chanlist [chan ]);
298
- return - ENODATA ;
299
- }
300
- }
301
- return 0 ;
302
- }
303
-
304
279
static int pci171x_ai_check_chanlist (struct comedi_device * dev ,
305
280
struct comedi_subdevice * s ,
306
281
struct comedi_cmd * cmd )
@@ -416,6 +391,35 @@ static int pci171x_ai_eoc(struct comedi_device *dev,
416
391
return - EBUSY ;
417
392
}
418
393
394
+ static int pci171x_ai_read_sample (struct comedi_device * dev ,
395
+ struct comedi_subdevice * s ,
396
+ unsigned int cur_chan ,
397
+ unsigned int * val )
398
+ {
399
+ const struct boardtype * board = dev -> board_ptr ;
400
+ struct pci1710_private * devpriv = dev -> private ;
401
+ unsigned int sample ;
402
+ unsigned int chan ;
403
+
404
+ sample = inw (dev -> iobase + PCI171x_AD_DATA );
405
+ if (!board -> is_pci1713 ) {
406
+ /*
407
+ * The upper 4 bits of the 16-bit sample are the channel number
408
+ * that the sample was acquired from. Verify that this channel
409
+ * number matches the expected channel number.
410
+ */
411
+ chan = sample >> 12 ;
412
+ if (chan != devpriv -> act_chanlist [cur_chan ]) {
413
+ dev_err (dev -> class_dev ,
414
+ "A/D data droput: received from channel %d, expected %d\n" ,
415
+ chan , devpriv -> act_chanlist [cur_chan ]);
416
+ return - ENODATA ;
417
+ }
418
+ }
419
+ * val = sample & s -> maxdata ;
420
+ return 0 ;
421
+ }
422
+
419
423
static int pci171x_ai_insn_read (struct comedi_device * dev ,
420
424
struct comedi_subdevice * s ,
421
425
struct comedi_insn * insn ,
@@ -443,12 +447,11 @@ static int pci171x_ai_insn_read(struct comedi_device *dev,
443
447
if (ret )
444
448
break ;
445
449
446
- val = inw (dev -> iobase + PCI171x_AD_DATA );
447
- ret = pci171x_ai_dropout (dev , s , chan , val );
450
+ ret = pci171x_ai_read_sample (dev , s , chan , & val );
448
451
if (ret )
449
452
break ;
450
453
451
- data [i ] = val & s -> maxdata ;
454
+ data [i ] = val ;
452
455
}
453
456
454
457
outb (0 , dev -> iobase + PCI171x_CLRFIFO );
@@ -677,14 +680,12 @@ static void pci1710_handle_every_sample(struct comedi_device *dev,
677
680
outb (0 , dev -> iobase + PCI171x_CLRINT ); /* clear our INT request */
678
681
679
682
for (; !(inw (dev -> iobase + PCI171x_STATUS ) & Status_FE );) {
680
- val = inw (dev -> iobase + PCI171x_AD_DATA );
681
- ret = pci171x_ai_dropout (dev , s , s -> async -> cur_chan , val );
683
+ ret = pci171x_ai_read_sample (dev , s , s -> async -> cur_chan , & val );
682
684
if (ret ) {
683
685
s -> async -> events |= COMEDI_CB_ERROR ;
684
686
break ;
685
687
}
686
688
687
- val &= s -> maxdata ;
688
689
comedi_buf_write_samples (s , & val , 1 );
689
690
690
691
if (cmd -> stop_src == TRIG_COUNT &&
@@ -707,15 +708,12 @@ static int move_block_from_fifo(struct comedi_device *dev,
707
708
int i ;
708
709
709
710
for (i = 0 ; i < n ; i ++ ) {
710
- val = inw (dev -> iobase + PCI171x_AD_DATA );
711
-
712
- ret = pci171x_ai_dropout (dev , s , s -> async -> cur_chan , val );
711
+ ret = pci171x_ai_read_sample (dev , s , s -> async -> cur_chan , & val );
713
712
if (ret ) {
714
713
s -> async -> events |= COMEDI_CB_ERROR ;
715
714
return ret ;
716
715
}
717
716
718
- val &= s -> maxdata ;
719
717
comedi_buf_write_samples (s , & val , 1 );
720
718
}
721
719
return 0 ;
0 commit comments