added some memory barriers on read/writes to comedi's buffer
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 6 Mar 2004 19:08:26 +0000 (19:08 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 6 Mar 2004 19:08:26 +0000 (19:08 +0000)
comedi/drivers.c

index 1ccf1e25ec3216a31f43c74aa3c284865193888b..c41eb2c6cb58e33e2dd50daefdc49141b56a87f4 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/vmalloc.h>
 
 #include <asm/io.h>
+#include <asm/system.h>
 
 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;