[Xenomai-git] Alexis Berlemont : analogy: update a4l_set_dev and remove useless info traces (broken)
Module: xenomai-abe Branch: experimental Commit: a17da6d3a6f517501e4279d4e72674271ad827ae URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a17da6d3a6f517501e4279d4e72674271ad827ae Author: Alexis Berlemont Date: Mon May 24 23:34:19 2010 +0200 analogy: update a4l_set_dev and remove useless info traces (broken) --- include/analogy/device.h |2 +- ksrc/drivers/analogy/device.c | 39 +-- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 51b99b5..6930a38 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -91,7 +91,7 @@ int a4l_rdproc_devs(char *page, off_t off, int count, int *eof, void *data); /* --- Context related function / macro --- */ -void a4l_set_dev(struct rtdm_dev_context *context); +void a4l_set_dev(a4l_cxt_t *cxt); #define a4l_get_dev(x) ((x)->dev) /* --- Upper layer functions --- */ diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index 4a3c879..a2d23c8 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -43,8 +43,6 @@ void a4l_init_devs(void) for (i = 0; i < A4L_NB_DEVICES; i++) { a4l_lock_init(&a4l_devs[i].lock); a4l_devs[i].transfer.irq_desc.irq = A4L_IRQ_UNUSED; - a4l_devs[i].transfer.idx_read_subd = A4L_IDX_UNUSED; - a4l_devs[i].transfer.idx_write_subd = A4L_IDX_UNUSED; } } @@ -59,13 +57,10 @@ int a4l_check_cleanup_devs(void) return ret; } -void a4l_set_dev(struct rtdm_dev_context *context) +void a4l_set_dev(a4l_cxt_t *cxt) { - /* Get the context's private structure */ - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; - /* Retrive the minor index */ - static int minor = context->device->device_id; - + /* Retrieve the minor index */ + static int minor = a4l_get_minor(cxt); /* Fill the dev fields accordingly */ cxt->dev = &(a4l_devs[minor]); } @@ -208,9 +203,6 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt, char *tmpname = NULL; void *tmpopts = NULL; - __a4l_dbg(1, core_dbg, - "a4l_fill_lnkdesc: minor=%d\n", a4l_get_minor(cxt)); - ret = rtdm_safe_copy_from_user(cxt->user_info, link_arg, arg, sizeof(a4l_lnkdesc_t)); if (ret != 0) { @@ -285,9 +277,6 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt, void a4l_free_lnkdesc(a4l_cxt_t * cxt, a4l_lnkdesc_t * link_arg) { - __a4l_dbg(1, core_dbg, - "a4l_free_lnkdesc: minor=%d\n", a4l_get_minor(cxt)); - if (link_arg->bname != NULL) rtdm_free(link_arg->bname); @@ -301,9 +290,6 @@ int a4l_assign_driver(a4l_cxt_t * cxt, int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - "a4l_assign_driver: minor=%d\n", a4l_get_minor(cxt)); - dev->driver = drv; if (drv->privdata_size == 0) @@ -355,9 +341,6 @@ int a4l_release_driver(a4l_cxt_t * cxt) int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - "a4l_release_driver: minor=%d\n", a4l_get_minor(cxt)); - if ((ret = dev->driver->detach(dev)) != 0) goto out_release_driver; @@ -388,9 +371,6 @@ int a4l_device_attach(a4l_cxt_t * cxt, void *arg) a4l_lnkdesc_t link_arg; a4l_drv_t *drv = NULL; - __a4l_dbg(1, core_dbg, - "a4l_device_attach: minor=%d\n", a4l_get_minor(cxt)); - if ((ret = a4l_fill_lnkdesc(cxt, &link_arg, arg)) != 0) goto out_attach; @@ -412,9 +392,6 @@ int a4l_device_detach(a4l_cxt_t * cxt) { a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - "a4l_device_detach: minor=%d\n", a4l_get_minor(cxt)); - if (dev->driver == NULL) { __a4l_err("a4l_device_detach: " "incoherent state, driver not reachable\n"); @@ -430,9 +407,6 @@ int a4l_ioctl_devcfg(a4l_cxt_t * cxt, void *arg) { int ret = 0; - __a4l_dbg(1, core_dbg, - "a4l_ioctl_devcfg: minor=%d\n", a4l_get_minor(cxt)); - if (rtdm_in_rt_context()) return -ENOSYS; @@ -487,9 +461,6 @@ int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg) a4l_dvinfo_t info; a4l_dev_t *dev = a4l_get_dev(cxt); - __a4l_dbg(1, core_dbg, - "a4l_ioctl_devinfo: minor=%d\n", a4l_get_minor(cxt)); - memset(&info, 0, sizeof(a4l_dvinfo_t)); if (test_bit(A4L_DEV_ATTACHED, &dev->flags)) { @@ -498,8 +469,8 @@ int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg) memcpy(info.board_name, dev->driver->board_name, len); info.nb_subd = dev->transfer.nb_subd; - info.idx_read_subd = dev->transfer.idx_rea
[Xenomai-git] Alexis Berlemont : analogy: declare the reserve / release functions at the subd level (broken)
Module: xenomai-abe Branch: experimental Commit: afe94634dc91fe6462c21ab86cbb4166a05a1ccf URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=afe94634dc91fe6462c21ab86cbb4166a05a1ccf Author: Alexis Berlemont Date: Mon May 24 16:46:31 2010 +0200 analogy: declare the reserve / release functions at the subd level (broken) --- include/analogy/subdevice.h|2 ++ ksrc/drivers/analogy/command.c | 33 - ksrc/drivers/analogy/instruction.c |2 +- ksrc/drivers/analogy/subdevice.c | 15 +++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 0f9e1c5..ded82f3 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -290,6 +290,8 @@ a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); int a4l_add_subd(struct a4l_device *dev, a4l_subd_t * subd); +int a4l_reserve_subd(a4l_subd_t *subd); +void a4l_release_subd(a4l_subd_t *subd); int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg); diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index b300d9a..94d6137 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -90,11 +90,8 @@ void a4l_free_cmddesc(a4l_cmd_t * desc) int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc) { - int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - - __a4l_dbg(1, core_dbg, -"a4l_check_cmddesc: minor=%d\n", a4l_get_minor(cxt)); + a4l_subd_t *subd; if (desc->idx_subd >= dev->transfer.nb_subd) { __a4l_err("a4l_check_cmddesc: " @@ -103,25 +100,23 @@ int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc) return -EINVAL; } - if ((dev->transfer.subds[desc->idx_subd]->flags & A4L_SUBD_TYPES) == - A4L_SUBD_UNUSED) { + subd = dev->transfer.subds[desc->idx_subd]; + + if ((subd->flags & A4L_SUBD_TYPES) == A4L_SUBD_UNUSED) { __a4l_err("a4l_check_cmddesc: " "subdevice type incoherent\n"); return -EIO; } - if (!(dev->transfer.subds[desc->idx_subd]->flags & A4L_SUBD_CMD)) { + if (!(subd->flags & A4L_SUBD_CMD)) { __a4l_err("a4l_check_cmddesc: operation not supported, " "synchronous only subdevice\n"); return -EIO; } - if (test_bit(A4L_TSF_BUSY, &(dev->transfer.status[desc->idx_subd]))) - return -EBUSY; - - if (ret != 0) { + if (test_bit(A4L_SUBD_BUSY, &subd->status)) { __a4l_err("a4l_check_cmddesc: subdevice busy\n"); - return ret; + return -EBUSY; } return a4l_check_chanlist(dev->transfer.subds[desc->idx_subd], @@ -299,17 +294,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) { int ret = 0, simul_flag = 0; a4l_cmd_t *cmd_desc = NULL; - a4l_subd_t *subd; a4l_dev_t *dev = a4l_get_dev(cxt); - - __a4l_dbg(1, core_dbg, - "a4l_ioctl_cmd: minor=%d\n", a4l_get_minor(cxt)); + a4l_subd_t *subd; /* The command launching cannot be done in real-time because of some possible buffer allocations in the drivers */ - if (rtdm_in_rt_context()) { + if (rtdm_in_rt_context()) return -ENOSYS; - } /* Basically check the device */ if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { @@ -373,13 +364,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) /* Eventually launches the command */ ret = subd->do_cmd(subd, cmd_desc); - + if (ret != 0) { - a4l_cancel_transfer(cxt, cmd_desc->idx_subd); + a4l_cancel_buffer(cxt); goto out_ioctl_cmd; } - out_ioctl_cmd: +out_ioctl_cmd: if (ret != 0 || simul_flag == 1) { a4l_free_cmddesc(cmd_desc); rtdm_free(cmd_desc); diff --git a/ksrc/drivers/analogy/instruction.c b/ksrc/drivers/analogy/instruction.c index 941fa69..413c0d2 100644 --- a/ksrc/drivers/analogy/instruction.c +++ b/ksrc/drivers/analogy/instruction.c @@ -281,7 +281,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc) out_do_insn: /* Releases the subdevice from its reserved state */ - a4l_cancel_transfer(cxt, dsc->idx_subd); + a4l_release_subd(subd); return ret; } diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c index 1278081..506b742 100644 --- a/ksrc/drivers/analogy/subdevice.c +++ b/ksrc/drivers/analogy/subdevice.c @@ -180,6 +180,21 @@ a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx) ret
[Xenomai-git] Alexis Berlemont : analogy: use rtdm_context_to_private (broken)
Module: xenomai-abe Branch: experimental Commit: 6a69aa21530e0d14103d45e2994f77f47fa2d948 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=6a69aa21530e0d14103d45e2994f77f47fa2d948 Author: Alexis Berlemont Date: Mon May 24 23:35:47 2010 +0200 analogy: use rtdm_context_to_private (broken) --- ksrc/drivers/analogy/rtdm_interface.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index d37ce4c..6525425 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -124,11 +124,11 @@ void a4l_cleanup_proc(void) int a4l_open(struct rtdm_dev_context *context, rtdm_user_info_t * user_info, int flags) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Get a pointer on the selected device (thanks to minor index) */ - a4l_set_dev(context); + a4l_set_dev(cxt); /* Initialize the buffer structure */ a4l_init_buffer(&cxt->buffer); @@ -146,7 +146,7 @@ int a4l_open(struct rtdm_dev_context *context, int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) { int err; - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Cancel the maybe occuring asynchronous transfer */ err = a4l_cancel_buffer(&cxt->buffer); @@ -164,7 +164,7 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) ssize_t a4l_read(struct rtdm_dev_context * context, rtdm_user_info_t * user_info, void *buf, size_t nbytes) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() && rtdm_rt_capable(user_info)) @@ -181,7 +181,7 @@ ssize_t a4l_read(struct rtdm_dev_context * context, ssize_t a4l_write(struct rtdm_dev_context * context, rtdm_user_info_t *user_info, const void *buf, size_t nbytes) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Jump into the RT domain if possible */ if (!rtdm_in_rt_context() && rtdm_rt_capable(user_info)) @@ -198,7 +198,7 @@ ssize_t a4l_write(struct rtdm_dev_context * context, int a4l_ioctl(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, unsigned int request, void *arg) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); cxt->user_info = user_info; @@ -209,7 +209,7 @@ int a4l_rt_select(struct rtdm_dev_context *context, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index) { - a4l_cxt_t *cxt = (a4l_cxt_t *)context->dev_private; + a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); return a4l_select(cxt, selector, type, fd_index); } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: cosmetic changes (broken)
Module: xenomai-abe Branch: experimental Commit: 4bb2c8a308c3f38472e11d927b85356fd5a7f349 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=4bb2c8a308c3f38472e11d927b85356fd5a7f349 Author: Alexis Berlemont Date: Mon May 24 16:44:03 2010 +0200 analogy: cosmetic changes (broken) --- ksrc/drivers/analogy/buffer.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 011753a..0ca1b4c 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -35,7 +35,7 @@ /* --- Initialization functions (init, alloc, free) --- */ -void a4l_free_buffer(a4l_buf_t * buf_desc) +void a4l_free_buffer(a4l_buf_t *buf_desc) { if (buf_desc->pg_list != NULL) { rtdm_free(buf_desc->pg_list); @@ -52,7 +52,7 @@ void a4l_free_buffer(a4l_buf_t * buf_desc) } } -int a4l_alloc_buffer(a4l_buf_t * buf_desc, int buf_size) +int a4l_alloc_buffer(a4l_buf_t *buf_desc, int buf_size) { int ret = 0; char *vaddr, *vabase; @@ -91,7 +91,7 @@ out_virt_contig_alloc: return ret; } -void a4l_init_buffer(a4l_buf_t * buf_desc) +void a4l_init_buffer(a4l_buf_t *buf_desc) { /* No command to process yet */ buf_desc->cur_cmd = NULL; ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: update a4l_get_minor function (broken)
Module: xenomai-abe Branch: experimental Commit: 1765c03f850e3bec3b400d74f1641e571ec5c837 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=1765c03f850e3bec3b400d74f1641e571ec5c837 Author: Alexis Berlemont Date: Mon May 24 23:33:13 2010 +0200 analogy: update a4l_get_minor function (broken) --- include/analogy/context.h | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index e0cf01c..2442b6c 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -25,6 +25,8 @@ #if defined(__KERNEL__) && !defined(DOXYGEN_CPP) +#include + struct a4l_device; struct a4l_buffer; @@ -43,6 +45,14 @@ struct a4l_device_context { struct buffer buffer; }; +static inline int a4l_get_minor(a4l_cxt_t *cxt) +{ + /* Get a pointer on the container structure */ + struct rtdm_dev_context * rtdm_cxt = rtdm_private_to_context(cxt); + /* Get the minor index */ + return rtdm_cxt->device->device_id; +} + #endif /* __KERNEL__ && !DOXYGEN_CPP */ #endif /* __ANALOGY_CONTEXT__ */ ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git