[Xenomai-git] Alexis Berlemont : analogy: fix a missing setting of the buf field in subdevice (broken)
Module: xenomai-head Branch: master Commit: 96a2611d16cca49a87d5a5bb9d36cd82e741b78a URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=96a2611d16cca49a87d5a5bb9d36cd82e741b78a Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sat Jun 12 01:34:12 2010 +0200 analogy: fix a missing setting of the buf field in subdevice (broken) --- ksrc/drivers/analogy/buffer.c | 15 --- ksrc/drivers/analogy/command.c |7 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index a72b4ad..1134b8e 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -124,6 +124,12 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return -EINVAL; } + if (a4l_reserve_subd(buf_desc-subd) 0) { + __a4l_err(a4l_setup_buffer: subdevice %d already busy\n, + cmd-idx_subd); + return -EBUSY; + } + /* Checks if the transfer system has to work in bulk mode */ if (cmd-flags A4L_CMD_BULK) set_bit(A4L_BUF_BULK_NR, buf_desc-flags); @@ -131,6 +137,9 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) /* Sets the working command */ buf_desc-cur_cmd = cmd; + /* Link the subdevice with the context's buffer */ + buf_desc-subd-buf = buf_desc; + /* Computes the count to reach, if need be */ if (cmd-stop_src == TRIG_COUNT) { for (i = 0; i cmd-nb_chan; i++) { @@ -167,9 +176,6 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) __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); rtdm_free(buf_desc-cur_cmd); @@ -178,6 +184,9 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) a4l_init_buffer(buf_desc); + a4l_release_subd(subd); + subd-buf = NULL; + return err; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index 51aad35..da89c9a 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -354,14 +354,11 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) goto out_ioctl_cmd; } - /* Sets the concerned subdevice as busy */ - ret = a4l_reserve_subd(subd); + /* Gets the transfer system ready */ + ret = a4l_setup_buffer(cxt, cmd_desc); if (ret 0) goto out_ioctl_cmd; - /* Gets the transfer system ready */ - a4l_setup_buffer(cxt, cmd_desc); - /* Eventually launches the command */ ret = subd-do_cmd(subd, cmd_desc); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix a missing setting of the buf field in subdevice (broken)
Module: xenomai-abe Branch: analogy Commit: dc32f61afe3610733a3caca8471769e0c9f83641 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=dc32f61afe3610733a3caca8471769e0c9f83641 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sat Jun 12 01:34:12 2010 +0200 analogy: fix a missing setting of the buf field in subdevice (broken) --- ksrc/drivers/analogy/buffer.c | 15 --- ksrc/drivers/analogy/command.c |7 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index a72b4ad..1134b8e 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -124,6 +124,12 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return -EINVAL; } + if (a4l_reserve_subd(buf_desc-subd) 0) { + __a4l_err(a4l_setup_buffer: subdevice %d already busy\n, + cmd-idx_subd); + return -EBUSY; + } + /* Checks if the transfer system has to work in bulk mode */ if (cmd-flags A4L_CMD_BULK) set_bit(A4L_BUF_BULK_NR, buf_desc-flags); @@ -131,6 +137,9 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) /* Sets the working command */ buf_desc-cur_cmd = cmd; + /* Link the subdevice with the context's buffer */ + buf_desc-subd-buf = buf_desc; + /* Computes the count to reach, if need be */ if (cmd-stop_src == TRIG_COUNT) { for (i = 0; i cmd-nb_chan; i++) { @@ -167,9 +176,6 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) __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); rtdm_free(buf_desc-cur_cmd); @@ -178,6 +184,9 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) a4l_init_buffer(buf_desc); + a4l_release_subd(subd); + subd-buf = NULL; + return err; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index 51aad35..da89c9a 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -354,14 +354,11 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) goto out_ioctl_cmd; } - /* Sets the concerned subdevice as busy */ - ret = a4l_reserve_subd(subd); + /* Gets the transfer system ready */ + ret = a4l_setup_buffer(cxt, cmd_desc); if (ret 0) goto out_ioctl_cmd; - /* Gets the transfer system ready */ - a4l_setup_buffer(cxt, cmd_desc); - /* Eventually launches the command */ ret = subd-do_cmd(subd, cmd_desc); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git