[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-head Branch: master Commit: c8f4e5434c2310d870ceb8f53cf74c73c0610762 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=c8f4e5434c2310d870ceb8f53cf74c73c0610762 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc-subd == NULL) { __a4l_err(a4l_setup_buffer: subdevice index out of range (%d)\n, cmd-idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a cancel function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the cancel function can be used as as to (re)initialize some component) */ if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { - __a4l_err(a4l_cancel: - subdevice %d cancel handler failed (err=%d)\n, - idx_subd, err); + __a4l_err(a4l_cancel: cancel handler failed (err=%d)\n, err); } a4l_release_subd(subd); + subd-buf = NULL; if (buf_desc-cur_cmd != NULL) { a4l_free_cmddesc(buf_desc-cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits - bytes */ tmp_size /= 8; - tmp_count = dev-transfer.bufs[subd-idx]-mng_count % tmp_size; + tmp_count = subd-buf-mng_count % tmp_size; /* Translation bytes - bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd-buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd-buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd-buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd-buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd-buf; int err; - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd-buf) count) + if (__count_to_put(buf) count) return -EAGAIN; - err = __produce(NULL, subd-buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err 0) return err; - err = __put(subd-buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_WRITE) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd)) return -EINVAL; -
[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-abe Branch: analogy Commit: 6202b8111b40c04b1d8eb5c1be65bddd27a39836 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=6202b8111b40c04b1d8eb5c1be65bddd27a39836 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc-subd == NULL) { __a4l_err(a4l_setup_buffer: subdevice index out of range (%d)\n, cmd-idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a cancel function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the cancel function can be used as as to (re)initialize some component) */ if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { - __a4l_err(a4l_cancel: - subdevice %d cancel handler failed (err=%d)\n, - idx_subd, err); + __a4l_err(a4l_cancel: cancel handler failed (err=%d)\n, err); } a4l_release_subd(subd); + subd-buf = NULL; if (buf_desc-cur_cmd != NULL) { a4l_free_cmddesc(buf_desc-cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits - bytes */ tmp_size /= 8; - tmp_count = dev-transfer.bufs[subd-idx]-mng_count % tmp_size; + tmp_count = subd-buf-mng_count % tmp_size; /* Translation bytes - bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd-buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd-buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd-buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd-buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd-buf; int err; - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd-buf) count) + if (__count_to_put(buf) count) return -EAGAIN; - err = __produce(NULL, subd-buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err 0) return err; - err = __put(subd-buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_WRITE) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd)) return -EINVAL; -
[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-abe Branch: experimental Commit: ffd039850b41cb751eb5c7212c81add2bfdd44da URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=ffd039850b41cb751eb5c7212c81add2bfdd44da Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc-subd == NULL) { __a4l_err(a4l_setup_buffer: subdevice index out of range (%d)\n, cmd-idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a cancel function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the cancel function can be used as as to (re)initialize some component) */ if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { - __a4l_err(a4l_cancel: - subdevice %d cancel handler failed (err=%d)\n, - idx_subd, err); + __a4l_err(a4l_cancel: cancel handler failed (err=%d)\n, err); } a4l_release_subd(subd); + subd-buf = NULL; if (buf_desc-cur_cmd != NULL) { a4l_free_cmddesc(buf_desc-cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits - bytes */ tmp_size /= 8; - tmp_count = dev-transfer.bufs[subd-idx]-mng_count % tmp_size; + tmp_count = subd-buf-mng_count % tmp_size; /* Translation bytes - bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd-buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd-buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd-buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd-buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd-buf; int err; - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd-buf) count) + if (__count_to_put(buf) count) return -EAGAIN; - err = __produce(NULL, subd-buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err 0) return err; - err = __put(subd-buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_WRITE) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd)) return -EINVAL; -
[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-abe Branch: analogy Commit: ffd039850b41cb751eb5c7212c81add2bfdd44da URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=ffd039850b41cb751eb5c7212c81add2bfdd44da Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc-subd == NULL) { __a4l_err(a4l_setup_buffer: subdevice index out of range (%d)\n, cmd-idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a cancel function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the cancel function can be used as as to (re)initialize some component) */ if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { - __a4l_err(a4l_cancel: - subdevice %d cancel handler failed (err=%d)\n, - idx_subd, err); + __a4l_err(a4l_cancel: cancel handler failed (err=%d)\n, err); } a4l_release_subd(subd); + subd-buf = NULL; if (buf_desc-cur_cmd != NULL) { a4l_free_cmddesc(buf_desc-cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits - bytes */ tmp_size /= 8; - tmp_count = dev-transfer.bufs[subd-idx]-mng_count % tmp_size; + tmp_count = subd-buf-mng_count % tmp_size; /* Translation bytes - bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd-buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd-buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd-buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd-buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd-buf; int err; - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd-buf) count) + if (__count_to_put(buf) count) return -EAGAIN; - err = __produce(NULL, subd-buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err 0) return err; - err = __put(subd-buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_WRITE) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd)) return -EINVAL; -
[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-abe Branch: experimental Commit: fb45b3be3a82e54c2b7bd8d3574298fd3184108c URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=fb45b3be3a82e54c2b7bd8d3574298fd3184108c Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc-subd == NULL) { __a4l_err(a4l_setup_buffer: subdevice index out of range (%d)\n, cmd-idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a cancel function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the cancel function can be used as as to (re)initialize some component) */ if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { - __a4l_err(a4l_cancel: - subdevice %d cancel handler failed (err=%d)\n, - idx_subd, err); + __a4l_err(a4l_cancel: cancel handler failed (err=%d)\n, err); } a4l_release_subd(subd); + subd-buf = NULL; if (buf_desc-cur_cmd != NULL) { a4l_free_cmddesc(buf_desc-cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits - bytes */ tmp_size /= 8; - tmp_count = dev-transfer.bufs[subd-idx]-mng_count % tmp_size; + tmp_count = subd-buf-mng_count % tmp_size; /* Translation bytes - bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd-buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd-buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd-buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd-buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd-buf; int err; - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd-buf) count) + if (__count_to_put(buf) count) return -EAGAIN; - err = __produce(NULL, subd-buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err 0) return err; - err = __put(subd-buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_WRITE) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd)) return -EINVAL; -
[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-abe Branch: experimental Commit: 01b05464428575b33c0dfa17c033fd7cb2620577 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=01b05464428575b33c0dfa17c033fd7cb2620577 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc-subd == NULL) { __a4l_err(a4l_setup_buffer: subdevice index out of range (%d)\n, cmd-idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a cancel function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the cancel function can be used as as to (re)initialize some component) */ if (subd-cancel != NULL (err = subd-cancel(subd)) 0) { - __a4l_err(a4l_cancel: - subdevice %d cancel handler failed (err=%d)\n, - idx_subd, err); + __a4l_err(a4l_cancel: cancel handler failed (err=%d)\n, err); } a4l_release_subd(subd); + subd-buf = NULL; if (buf_desc-cur_cmd != NULL) { a4l_free_cmddesc(buf_desc-cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits - bytes */ tmp_size /= 8; - tmp_count = dev-transfer.bufs[subd-idx]-mng_count % tmp_size; + tmp_count = subd-buf-mng_count % tmp_size; /* Translation bytes - bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd-buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd-buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd-buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd-buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd-buf; int err; - if ((subd-flags A4L_SUBD_MASK_READ) == 0 || !subd-buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd-buf) count) + if (__count_to_put(buf) count) return -EAGAIN; - err = __produce(NULL, subd-buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err 0) return err; - err = __put(subd-buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd-flags A4L_SUBD_MASK_WRITE) == 0 || !subd-buf) + a4l_buf_t *buf = subd-buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd)) return -EINVAL; -