staging: comedi: COMEDI_BUFINFO: some behavioural changes

From: Ian Abbott
Date: Fri Feb 19 2016 - 11:16:28 EST


These patches change the behavior of the `COMEDI_BUFINFO` ioctl, which
is used to manage buffer positions for a previously set up asynchronous
acquisition command. It is used instead of the read and write file
operations when the buffer has been mmapped.

Patches 1 to 4 are fairly innocuous. Patches 5 to 8 change the error
handling when the asynchronous command is no longer running, allow the
subdevice to become "non-busy" automatically in more cases (causing
subsequent calls to return `-EINVAL`), and report abnormal command
termination with return value `-EPIPE` (which also makes the subdevice
become non-busy).

1) staging: comedi: COMEDI_BUFINFO: get amount freed, not amount
allocated
2) staging: comedi: COMEDI_BUFINFO: force bytes_read or bytes_written to
0
3) staging: comedi: COMEDI_BUFINFO: update buffer before becoming
non-busy
4) staging: comedi: COMEDI_BUFINFO: force bytes_written to 0 if stopped
5) staging: comedi: COMEDI_BUFINFO: return error if no active command
6) staging: comedi: COMEDI_BUFINFO: become non-busy even if bytes_read
is 0
7) staging: comedi: COMEDI_BUFINFO: return -EPIPE for abnormal read
8) staging: comedi: COMEDI_BUFINFO: terminate "write" command when
stopped

drivers/staging/comedi/comedi_fops.c | 84 +++++++++++++++++++-----------------
1 file changed, 44 insertions(+), 40 deletions(-)