From 914b1daabace88feffa2a5d1a1e249eb518de075 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sat, 6 Mar 2004 19:08:26 +0000 Subject: [PATCH] added some memory barriers on read/writes to comedi's buffer --- comedi/drivers.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/comedi/drivers.c b/comedi/drivers.c index 1ccf1e25..c41eb2c6 100644 --- a/comedi/drivers.c +++ b/comedi/drivers.c @@ -38,6 +38,7 @@ #include #include +#include static int postconfig(comedi_device *dev); static int insn_rw_emulate_bits(comedi_device *dev,comedi_subdevice *s, @@ -566,7 +567,7 @@ void comedi_buf_memcpy_to( comedi_async *async, unsigned int offset, const void unsigned int write_ptr = async->buf_write_ptr + offset; if( write_ptr >= async->prealloc_bufsz ) - write_ptr -= async->prealloc_bufsz; + write_ptr %= async->prealloc_bufsz; while( num_bytes ) { @@ -584,6 +585,7 @@ void comedi_buf_memcpy_to( comedi_async *async, unsigned int offset, const void write_ptr = 0; } + mb(); } void comedi_buf_memcpy_from(comedi_async *async, unsigned int offset, @@ -593,8 +595,9 @@ void comedi_buf_memcpy_from(comedi_async *async, unsigned int offset, unsigned int read_ptr = async->buf_read_ptr + offset; if( read_ptr >= async->prealloc_bufsz ) - read_ptr -= async->prealloc_bufsz; + read_ptr %= async->prealloc_bufsz; + mb(); while( nbytes ) { unsigned int block_size; -- 2.26.2