Skip to content

Commit 48e08de

Browse files
bigguinessgregkh
authored andcommitted
staging: comedi: amplc_pci230: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer. The async events will set properly by the core. A dev_warn() message will also be output by the core if the buffer overflows. Remove the unnecessary events and dev_err() message in the driver. The core will also add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove the unnecessary event in the driver. Signed-off-by: H Hartley Sweeten <[email protected]> Reviewed-by: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 27913fa commit 48e08de

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

drivers/staging/comedi/drivers/amplc_pci230.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,7 @@ static void pci230_handle_ai(struct comedi_device *dev,
20532053
unsigned int i;
20542054
unsigned int todo;
20552055
unsigned int fifoamount;
2056+
unsigned short val;
20562057

20572058
/* Determine number of samples to read. */
20582059
if (cmd->stop_src != TRIG_COUNT) {
@@ -2099,12 +2100,10 @@ static void pci230_handle_ai(struct comedi_device *dev,
20992100
fifoamount = 1;
21002101
}
21012102
}
2102-
/* Read sample and store in Comedi's circular buffer. */
2103-
if (comedi_buf_put(s, pci230_ai_read(dev)) == 0) {
2104-
events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
2105-
dev_err(dev->class_dev, "AI buffer overflow\n");
2106-
break;
2107-
}
2103+
2104+
val = pci230_ai_read(dev);
2105+
comedi_buf_write_samples(s, &val, 1);
2106+
21082107
fifoamount--;
21092108
devpriv->ai_scan_pos++;
21102109
if (devpriv->ai_scan_pos == scanlen) {
@@ -2117,9 +2116,6 @@ static void pci230_handle_ai(struct comedi_device *dev,
21172116
if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) {
21182117
/* End of acquisition. */
21192118
events |= COMEDI_CB_EOA;
2120-
} else {
2121-
/* More samples required, tell Comedi to block. */
2122-
events |= COMEDI_CB_BLOCK;
21232119
}
21242120
async->events |= events;
21252121
if (!(async->events & COMEDI_CB_CANCEL_MASK)) {

0 commit comments

Comments
 (0)