The function comedi_mark_buffer_written() is used on a subdevice that has a Comedi output command in progress. It should only be used if you are using a mmap() (as opposed to calling write() on the device file) to write data to Comedi's buffer, since Comedi will automatically keep track of how many bytes have been transferred via write() calls. This function is used to indicate that the next num_bytes bytes in the buffer are valid and may be sent to the device. If there is an error, -1 is returned.