Module: xenomai-abe Branch: analogy Commit: 317a146af94aba329306c558a2c4e7c1b38f3806 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=317a146af94aba329306c558a2c4e7c1b38f3806
Author: Alexis Berlemont <alexis.berlem...@gmail.com> Date: Mon Mar 22 01:00:01 2010 +0100 analogy: fix buffer checkings so as to allow infinite acquisitions With unlimited acquisitions (cmd.stop_src == TRIG_NONE), the field end_count displayed by the buffer descriptor is set to 0. Many checkings in buffer.h did not properly handle this case. --- include/analogy/buffer.h | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 0ab93ba..007f01e 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -201,7 +201,6 @@ static inline int __pre_put(a4l_buf_t * buf, unsigned long count) static inline int __pre_abs_get(a4l_buf_t * buf, unsigned long count) { - /* The first time, we expect the buffer to be properly filled before the trigger occurence; by the way, we need tmp_count to have been initialized and tmp_count is updated right here */ @@ -213,7 +212,7 @@ static inline int __pre_abs_get(a4l_buf_t * buf, unsigned long count) last time, the DMA channel can easily overtake the tmp frontier because no more data were sent from user space; therefore no useless alarm should be sent */ - if ((long)(count - buf->end_count) > 0) + if (buf->end_count != 0 && (long)(count - buf->end_count) > 0) goto out; /* Once the exception are passed, we check that the DMA @@ -253,7 +252,7 @@ static inline int __abs_put(a4l_buf_t * buf, unsigned long count) if ((old / buf->size) != (count / buf->size)) set_bit(A4L_BUF_EOBUF_NR, &buf->evt_flags); - if ((long)(count - buf->end_count) >= 0) + if (buf->end_count != 0 && (long)(count - buf->end_count) >= 0) set_bit(A4L_BUF_EOA_NR, &buf->evt_flags); return 0; @@ -276,7 +275,7 @@ static inline int __abs_get(a4l_buf_t * buf, unsigned long count) if ((old / buf->size) != count / buf->size) set_bit(A4L_BUF_EOBUF_NR, &buf->evt_flags); - if ((long)(count - buf->end_count) >= 0) + if (buf->end_count != 0 && (long)(count - buf->end_count) >= 0) set_bit(A4L_BUF_EOA_NR, &buf->evt_flags); return 0; @@ -303,7 +302,9 @@ static inline unsigned long __count_to_get(a4l_buf_t * buf) { unsigned long ret; - if (buf->end_count != 0 && (long)(buf->end_count - buf->prd_count) > 0) + /* If the acquisition is unlimited (end_count == 0), we must + not take into account end_count */ + if (buf->end_count == 0 || (long)(buf->end_count - buf->prd_count) > 0) ret = buf->prd_count; else ret = buf->end_count; _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git