Module: xenomai-2.5 Branch: master Commit: 58ebd5b7efe0cc0ac1e82991d12125ce34dfeee3 URL: http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=58ebd5b7efe0cc0ac1e82991d12125ce34dfeee3
Author: Alexis Berlemont <alexis.berlem...@gmail.com> Date: Sun Jun 6 16:21:44 2010 +0200 analogy: fix the declaration of the structure a4l_context (broken) In the structure a4l_context, replace the field buffer by a pointer to the structure a4l_buffer (a4l_buf_t -> a4l_buf_t *). That fixes a bug in the headers dependencies. --- include/analogy/context.h | 3 ++- ksrc/drivers/analogy/buffer.c | 12 ++++++------ ksrc/drivers/analogy/rtdm_interface.c | 14 ++++++++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index 2442b6c..3e61697 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -42,8 +42,9 @@ struct a4l_device_context { /* The buffer structure contains everything to transfer data from asynchronous acquisition operations on a specific subdevice */ - struct buffer buffer; + struct a4l_buffer *buffer; }; +typedef struct a4l_device_context a4l_cxt_t; static inline int a4l_get_minor(a4l_cxt_t *cxt) { diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index d3db892..1b413cc 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -493,10 +493,10 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) subd = dev->transfer.subds[idx_subd]; - if (subd != cxt->buffer.subd) { + if (subd != cxt->buffer->subd) { __a4l_err("a4l_ioctl_cancel: " "current context works on another subdevice " - "(%d!=%d)\n", cxt->buffer.subd->idx, subd->idx); + "(%d!=%d)\n", cxt->buffer->subd->idx, subd->idx); return -EINVAL; } @@ -658,7 +658,7 @@ a4l_ioctl_bufinfo_out: ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_buf_t *subd = buf->subd; ssize_t count = 0; @@ -758,7 +758,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_subd_t *subd = buf->subd; ssize_t count = 0; @@ -849,7 +849,7 @@ int a4l_select(a4l_cxt_t *cxt, enum rtdm_selecttype type, unsigned fd_index) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_subd_t *subd = buf->subd; /* Basic checkings */ @@ -894,7 +894,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) int ret = 0; unsigned long tmp_cnt = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_buf_t *subd = buf->subd; a4l_poll_t poll; diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index 6525425..8cfdf04 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -131,14 +131,15 @@ int a4l_open(struct rtdm_dev_context *context, a4l_set_dev(cxt); /* Initialize the buffer structure */ - a4l_init_buffer(&cxt->buffer); + cxt->buffer = rtdm_malloc(sizeof(a4l_buf_t)); + a4l_init_buffer(cxt->buffer); /* Allocate the asynchronous buffer NOTE: it should be interesting to allocate the buffer only on demand especially if the system is short of memory NOTE2: the default buffer size could be configured via kernel config*/ - a4l_alloc_buffer(&cxt->buffer, A4L_DEFAULT_BFSIZE); + a4l_alloc_buffer(cxt->buffer, A4L_DEFAULT_BFSIZE); return 0; } @@ -149,15 +150,20 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Cancel the maybe occuring asynchronous transfer */ - err = a4l_cancel_buffer(&cxt->buffer); + err = a4l_cancel_buffer(cxt->buffer); if (err < 0) { __a4l_err("close: unable to stop the asynchronous transfer\n"); return err; } /* Free the buffer which was linked with this context */ - err = a4l_free_buffer(&cxt->buffer); + err = a4l_free_buffer(cxt->buffer); + if (err < 0) + goto out; + rtdm_free(cxt->buffer); + +out: return err; } _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git