Module: xenomai-forge
Branch: master
Commit: 1430693899f8cd5ae2b4fdcecb30e49f49428570
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=1430693899f8cd5ae2b4fdcecb30e49f49428570

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun May 11 22:00:17 2014 +0200

analogy: adapt to RTDM API changes

---

 include/cobalt/kernel/rtdm/analogy/buffer.h        |   12 +++--
 include/cobalt/kernel/rtdm/analogy/context.h       |    8 +--
 include/cobalt/kernel/rtdm/analogy/subdevice.h     |    2 +-
 kernel/drivers/analogy/buffer.c                    |   46 +++++++++---------
 kernel/drivers/analogy/command.c                   |    4 +-
 kernel/drivers/analogy/device.c                    |   10 ++--
 kernel/drivers/analogy/instruction.c               |   17 ++++---
 kernel/drivers/analogy/intel/8255.c                |    3 +-
 kernel/drivers/analogy/intel/parport.c             |    4 +-
 .../analogy/national_instruments/mio_common.c      |   16 ++----
 kernel/drivers/analogy/rtdm_interface.c            |   51 +++++++-------------
 kernel/drivers/analogy/subdevice.c                 |   23 +++++----
 kernel/drivers/analogy/testing/fake.c              |   12 ++---
 kernel/drivers/analogy/testing/loop.c              |    4 +-
 14 files changed, 95 insertions(+), 117 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/analogy/buffer.h 
b/include/cobalt/kernel/rtdm/analogy/buffer.h
index 9c48ac3..5a1e966 100644
--- a/include/cobalt/kernel/rtdm/analogy/buffer.h
+++ b/include/cobalt/kernel/rtdm/analogy/buffer.h
@@ -98,6 +98,7 @@ static inline int __produce(a4l_cxt_t *cxt,
                            a4l_buf_t *buf, void *pin, unsigned long count)
 {
        unsigned long start_ptr = (buf->prd_count % buf->size);
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        unsigned long tmp_cnt = count;
        int ret = 0;
 
@@ -107,10 +108,10 @@ static inline int __produce(a4l_cxt_t *cxt,
                        buf->size - start_ptr : tmp_cnt;
 
                /* Perform the copy */
-               if (cxt == NULL)
+               if (rtdm_fd_is_user(fd) == 0)
                        memcpy(buf->buf + start_ptr, pin, blk_size);
                else
-                       ret = rtdm_safe_copy_from_user(cxt->user_info,
+                       ret = rtdm_safe_copy_from_user(fd,
                                                       buf->buf + start_ptr,
                                                       pin, blk_size);
 
@@ -130,6 +131,7 @@ static inline int __consume(a4l_cxt_t *cxt,
                            a4l_buf_t *buf, void *pout, unsigned long count)
 {
        unsigned long start_ptr = (buf->cns_count % buf->size);
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        unsigned long tmp_cnt = count;
        int ret = 0;
 
@@ -139,10 +141,10 @@ static inline int __consume(a4l_cxt_t *cxt,
                        buf->size - start_ptr : tmp_cnt;
 
                /* Perform the copy */
-               if (cxt == NULL)
+               if (rtdm_fd_is_user(fd) == 0)
                        memcpy(pout, buf->buf + start_ptr, blk_size);
                else
-                       ret = rtdm_safe_copy_to_user(cxt->user_info,
+                       ret = rtdm_safe_copy_to_user(fd,
                                                     pout,
                                                     buf->buf + start_ptr,
                                                     blk_size);
@@ -391,7 +393,7 @@ void a4l_cleanup_buffer(a4l_buf_t * buf_desc);
 
 int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd);
 
-int a4l_cancel_buffer(a4l_cxt_t *cxt);
+void a4l_cancel_buffer(a4l_cxt_t *cxt);
 
 int a4l_buf_prepare_absput(struct a4l_subdevice *subd,
                           unsigned long count);
diff --git a/include/cobalt/kernel/rtdm/analogy/context.h 
b/include/cobalt/kernel/rtdm/analogy/context.h
index a96d931..6cc25bb 100644
--- a/include/cobalt/kernel/rtdm/analogy/context.h
+++ b/include/cobalt/kernel/rtdm/analogy/context.h
@@ -28,10 +28,6 @@ struct a4l_device;
 struct a4l_buffer;
 
 struct a4l_device_context {
-
-       /* Needed to call rtdm_*_copy_from/to_user functions */
-       rtdm_user_info_t *user_info;
-
        /* The adequate device pointer
           (retrieved thanks to minor at open time) */
        struct a4l_device *dev;
@@ -46,9 +42,9 @@ typedef struct a4l_device_context a4l_cxt_t;
 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);
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        /* Get the minor index */
-       return rtdm_cxt->device->device_id;
+       return rtdm_fd_device(fd)->device_id;
 }
 
 #endif /* !_COBALT_RTDM_ANALOGY_CONTEXT_H */
diff --git a/include/cobalt/kernel/rtdm/analogy/subdevice.h 
b/include/cobalt/kernel/rtdm/analogy/subdevice.h
index f42c1d3..e3a27d8 100644
--- a/include/cobalt/kernel/rtdm/analogy/subdevice.h
+++ b/include/cobalt/kernel/rtdm/analogy/subdevice.h
@@ -78,7 +78,7 @@ struct a4l_subdevice {
                                        /**< Callback for command handling */
        int (*do_cmdtest) (struct a4l_subdevice *, a4l_cmd_t *);
                                                       /**< Callback for 
command checking */
-       int (*cancel) (struct a4l_subdevice *);
+       void (*cancel) (struct a4l_subdevice *);
                                         /**< Callback for asynchronous 
transfer cancellation */
        void (*munge) (struct a4l_subdevice *, void *, unsigned long);
                                                                /**< Callback 
for munge operation */
diff --git a/kernel/drivers/analogy/buffer.c b/kernel/drivers/analogy/buffer.c
index aecf403..b5db6b4 100644
--- a/kernel/drivers/analogy/buffer.c
+++ b/kernel/drivers/analogy/buffer.c
@@ -167,24 +167,21 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd)
        return 0;
 }
 
-int a4l_cancel_buffer(a4l_cxt_t *cxt)
+void a4l_cancel_buffer(a4l_cxt_t *cxt)
 {
        a4l_buf_t *buf_desc = cxt->buffer;
        a4l_subd_t *subd = buf_desc->subd;
 
-       int err = 0;
-
        if (!subd || !test_bit(A4L_SUBD_BUSY_NR, &subd->status))
-               return 0;
+               return;
 
        /* If a "cancel" function is registered, call it
           (Note: this function is called before having checked
           if a command is under progress; we consider that
           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: cancel handler failed (err=%d)\n", err);
-       }
+       if (subd->cancel != NULL)
+               subd->cancel(subd);
 
        if (buf_desc->cur_cmd != NULL) {
                a4l_free_cmddesc(buf_desc->cur_cmd);
@@ -196,8 +193,6 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt)
 
        clear_bit(A4L_SUBD_BUSY_NR, &subd->status);
        subd->buf = NULL;
-
-       return err;
 }
 
 /* --- Munge related function --- */
@@ -484,6 +479,7 @@ static struct vm_operations_struct a4l_vm_ops = {
 
 int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        a4l_mmap_t map_cfg;
        a4l_dev_t *dev;
        a4l_buf_t *buf;
@@ -511,7 +507,7 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg)
                return -EBUSY;
        }
 
-       if (rtdm_safe_copy_from_user(cxt->user_info,
+       if (rtdm_safe_copy_from_user(fd,
                                     &map_cfg, arg, sizeof(a4l_mmap_t)) != 0)
                return -EFAULT;
 
@@ -520,7 +516,7 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg)
                return -EFAULT;
 
        /* All the magic is here */
-       ret = rtdm_mmap_to_user(cxt->user_info,
+       ret = rtdm_mmap_to_user(fd,
                                buf->buf,
                                map_cfg.size,
                                PROT_READ | PROT_WRITE,
@@ -532,7 +528,7 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg)
                return ret;
        }
 
-       return rtdm_safe_copy_to_user(cxt->user_info,
+       return rtdm_safe_copy_to_user(fd,
                                      arg, &map_cfg, sizeof(a4l_mmap_t));
 }
 
@@ -571,7 +567,8 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg)
                return -EINVAL;
        }
 
-       return a4l_cancel_buffer(cxt);
+       a4l_cancel_buffer(cxt);
+       return 0;
 }
 
 /* The ioctl BUFCFG is only useful for changing the size of the
@@ -580,6 +577,7 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg)
 
 int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        a4l_dev_t *dev = a4l_get_dev(cxt);
        a4l_buf_t *buf = cxt->buffer;
        a4l_subd_t *subd = buf->subd;
@@ -597,7 +595,7 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg)
                return -EINVAL;
        }
 
-       if (rtdm_safe_copy_from_user(cxt->user_info,
+       if (rtdm_safe_copy_from_user(fd,
                                     &buf_cfg,
                                     arg, sizeof(a4l_bufcfg_t)) != 0)
                return -EFAULT;
@@ -637,6 +635,7 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg)
 
 int a4l_ioctl_bufcfg2(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        a4l_dev_t *dev = a4l_get_dev(cxt);
        a4l_buf_t *buf = cxt->buffer;
        a4l_bufcfg2_t buf_cfg;
@@ -647,7 +646,7 @@ int a4l_ioctl_bufcfg2(a4l_cxt_t * cxt, void *arg)
                return -EINVAL;
        }
 
-       if (rtdm_safe_copy_from_user(cxt->user_info,
+       if (rtdm_safe_copy_from_user(fd,
                                     &buf_cfg,
                                     arg, sizeof(a4l_bufcfg2_t)) != 0)
                return -EFAULT;
@@ -670,6 +669,7 @@ int a4l_ioctl_bufcfg2(a4l_cxt_t * cxt, void *arg)
 
 int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        a4l_dev_t *dev = a4l_get_dev(cxt);
        a4l_buf_t *buf = cxt->buffer;
        a4l_subd_t *subd = buf->subd;
@@ -678,7 +678,7 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg)
        unsigned long tmp_cnt;
        int ret;
 
-       if (!rtdm_in_rt_context() && rtdm_rt_capable(cxt->user_info))
+       if (!rtdm_in_rt_context() && rtdm_rt_capable(fd))
                return -ENOSYS;
 
        /* Basic checking */
@@ -687,7 +687,7 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg)
                return -EINVAL;
        }
 
-       if (rtdm_safe_copy_from_user(cxt->user_info,
+       if (rtdm_safe_copy_from_user(fd,
                                     &info, arg, sizeof(a4l_bufinfo_t)) != 0)
                return -EFAULT;
 
@@ -766,7 +766,7 @@ a4l_ioctl_bufinfo_out:
        info.buf_size = buf->size;
 
        /* Sends the structure back to user space */
-       if (rtdm_safe_copy_to_user(cxt->user_info,
+       if (rtdm_safe_copy_to_user(fd,
                                   arg, &info, sizeof(a4l_bufinfo_t)) != 0)
                return -EFAULT;
 
@@ -780,6 +780,7 @@ major release, this ioctl will vanish. */
 
 int a4l_ioctl_bufinfo2(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        a4l_dev_t *dev = a4l_get_dev(cxt);
        a4l_buf_t *buf = cxt->buffer;
        a4l_bufcfg2_t buf_cfg;
@@ -792,7 +793,7 @@ int a4l_ioctl_bufinfo2(a4l_cxt_t * cxt, void *arg)
 
        buf_cfg.wake_count = buf->wake_count;
 
-       if (rtdm_safe_copy_to_user(cxt->user_info,
+       if (rtdm_safe_copy_to_user(fd,
                                   arg, &buf_cfg, sizeof(a4l_bufcfg2_t)) != 0)
                return -EFAULT;
 
@@ -1040,6 +1041,7 @@ int a4l_select(a4l_cxt_t *cxt,
 
 int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        int ret = 0;
        unsigned long tmp_cnt = 0;
        a4l_dev_t *dev = a4l_get_dev(cxt);
@@ -1047,7 +1049,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg)
        a4l_subd_t *subd = buf->subd;
        a4l_poll_t poll;
 
-       if (!rtdm_in_rt_context() && rtdm_rt_capable(cxt->user_info))
+       if (!rtdm_in_rt_context() && rtdm_rt_capable(fd))
                return -ENOSYS;
 
        /* Basic checking */
@@ -1062,7 +1064,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg)
                return -ENOENT;
        }
 
-       if (rtdm_safe_copy_from_user(cxt->user_info,
+       if (rtdm_safe_copy_from_user(fd,
                                     &poll, arg, sizeof(a4l_poll_t)) != 0)
                return -EFAULT;
 
@@ -1122,7 +1124,7 @@ out_poll:
 
        poll.arg = tmp_cnt;
 
-       ret = rtdm_safe_copy_to_user(cxt->user_info,
+       ret = rtdm_safe_copy_to_user(fd,
                                     arg, &poll, sizeof(a4l_poll_t));
 
        return ret;
diff --git a/kernel/drivers/analogy/command.c b/kernel/drivers/analogy/command.c
index 6cf6d4c..080f8ed 100644
--- a/kernel/drivers/analogy/command.c
+++ b/kernel/drivers/analogy/command.c
@@ -34,7 +34,7 @@ int a4l_fill_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc, void 
*arg)
        int ret = 0;
        unsigned int *tmpchans = NULL;
 
-       ret = rtdm_safe_copy_from_user(cxt->user_info,
+       ret = rtdm_safe_copy_from_user(rtdm_private_to_fd(cxt),
                                       desc, arg, sizeof(a4l_cmd_t));
        if (ret != 0)
                goto out_cmddesc;
@@ -50,7 +50,7 @@ int a4l_fill_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc, void 
*arg)
                goto out_cmddesc;
        }
 
-       ret = rtdm_safe_copy_from_user(cxt->user_info,
+       ret = rtdm_safe_copy_from_user(rtdm_private_to_fd(cxt),
                                       tmpchans,
                                       desc->chan_descs,
                                       desc->nb_chan * sizeof(unsigned long));
diff --git a/kernel/drivers/analogy/device.c b/kernel/drivers/analogy/device.c
index ed3f785..f39e8a3 100644
--- a/kernel/drivers/analogy/device.c
+++ b/kernel/drivers/analogy/device.c
@@ -175,11 +175,12 @@ void a4l_proc_detach(a4l_cxt_t * cxt)
 int a4l_fill_lnkdesc(a4l_cxt_t * cxt,
                     a4l_lnkdesc_t * link_arg, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        int ret;
        char *tmpname = NULL;
        void *tmpopts = NULL;
 
-       ret = rtdm_safe_copy_from_user(cxt->user_info,
+       ret = rtdm_safe_copy_from_user(fd,
                                       link_arg, arg, sizeof(a4l_lnkdesc_t));
        if (ret != 0) {
                __a4l_err("a4l_fill_lnkdesc: "
@@ -197,7 +198,7 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt,
                }
                tmpname[link_arg->bname_size] = 0;
 
-               ret = rtdm_safe_copy_from_user(cxt->user_info,
+               ret = rtdm_safe_copy_from_user(fd,
                                               tmpname,
                                               link_arg->bname,
                                               link_arg->bname_size);
@@ -222,7 +223,7 @@ int a4l_fill_lnkdesc(a4l_cxt_t * cxt,
                        goto out_get_lnkdesc;
                }
 
-               ret = rtdm_safe_copy_from_user(cxt->user_info,
+               ret = rtdm_safe_copy_from_user(fd,
                                               tmpopts,
                                               link_arg->opts,
                                               link_arg->opts_size);
@@ -431,6 +432,7 @@ int a4l_ioctl_devcfg(a4l_cxt_t * cxt, void *arg)
 
 int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        a4l_dvinfo_t info;
        a4l_dev_t *dev = a4l_get_dev(cxt);
 
@@ -446,7 +448,7 @@ int a4l_ioctl_devinfo(a4l_cxt_t * cxt, void *arg)
                   read subdevice and write subdevice */
        }
 
-       if (rtdm_safe_copy_to_user(cxt->user_info,
+       if (rtdm_safe_copy_to_user(fd,
                                   arg, &info, sizeof(a4l_dvinfo_t)) != 0)
                return -EFAULT;
 
diff --git a/kernel/drivers/analogy/instruction.c 
b/kernel/drivers/analogy/instruction.c
index dc739bf..b905190 100644
--- a/kernel/drivers/analogy/instruction.c
+++ b/kernel/drivers/analogy/instruction.c
@@ -119,10 +119,11 @@ int a4l_do_insn_trig(a4l_cxt_t * cxt, a4l_kinsn_t * dsc)
 
 int a4l_fill_insndsc(a4l_cxt_t * cxt, a4l_kinsn_t * dsc, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        int ret = 0;
        void *tmp_data = NULL;
 
-       ret = rtdm_safe_copy_from_user(cxt->user_info,
+       ret = rtdm_safe_copy_from_user(fd,
                                       dsc, arg, sizeof(a4l_insn_t));
        if (ret != 0)
                goto out_insndsc;
@@ -141,7 +142,7 @@ int a4l_fill_insndsc(a4l_cxt_t * cxt, a4l_kinsn_t * dsc, 
void *arg)
                }
 
                if ((dsc->type & A4L_INSN_MASK_WRITE) != 0) {
-                       ret = rtdm_safe_copy_from_user(cxt->user_info,
+                       ret = rtdm_safe_copy_from_user(fd,
                                                       tmp_data, dsc->data,
                                                       dsc->data_size);
                        if (ret < 0)
@@ -162,10 +163,11 @@ out_insndsc:
 
 int a4l_free_insndsc(a4l_cxt_t * cxt, a4l_kinsn_t * dsc)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        int ret = 0;
 
        if ((dsc->type & A4L_INSN_MASK_READ) != 0)
-               ret = rtdm_safe_copy_to_user(cxt->user_info,
+               ret = rtdm_safe_copy_to_user(fd,
                                             dsc->__udata,
                                             dsc->data, dsc->data_size);
 
@@ -285,11 +287,12 @@ out_do_insn:
 
 int a4l_ioctl_insn(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        int ret = 0;
        a4l_kinsn_t insn;
        a4l_dev_t *dev = a4l_get_dev(cxt);
 
-       if (!rtdm_in_rt_context() && rtdm_rt_capable(cxt->user_info))
+       if (!rtdm_in_rt_context() && rtdm_rt_capable(fd))
                return -ENOSYS;
 
        /* Basic checking */
@@ -325,12 +328,13 @@ err_ioctl_insn:
 
 int a4l_fill_ilstdsc(a4l_cxt_t * cxt, a4l_kilst_t * dsc, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        int i, ret = 0;
 
        dsc->insns = NULL;
 
        /* Recovers the structure from user space */
-       ret = rtdm_safe_copy_from_user(cxt->user_info,
+       ret = rtdm_safe_copy_from_user(fd,
                                       dsc, arg, sizeof(a4l_insnlst_t));
        if (ret < 0)
                return ret;
@@ -387,11 +391,12 @@ int a4l_free_ilstdsc(a4l_cxt_t * cxt, a4l_kilst_t * dsc)
    designed for performance issues */
 int a4l_ioctl_insnlist(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        int i, ret = 0;
        a4l_kilst_t ilst;
        a4l_dev_t *dev = a4l_get_dev(cxt);
 
-       if (!rtdm_in_rt_context() && rtdm_rt_capable(cxt->user_info))
+       if (!rtdm_in_rt_context() && rtdm_rt_capable(fd))
                return -ENOSYS;
 
        /* Basic checking */
diff --git a/kernel/drivers/analogy/intel/8255.c 
b/kernel/drivers/analogy/intel/8255.c
index b3378f7..db5657c 100644
--- a/kernel/drivers/analogy/intel/8255.c
+++ b/kernel/drivers/analogy/intel/8255.c
@@ -123,10 +123,9 @@ int subd_8255_cmdtest(a4l_subd_t *subd, a4l_cmd_t *cmd)
        return 0;
 }
 
-int subd_8255_cancel(a4l_subd_t *subd)
+void subd_8255_cancel(a4l_subd_t *subd)
 {
        /* FIXME */
-       return 0;
 }
 
 int subd_8255_insn_bits(a4l_subd_t *subd, a4l_kinsn_t *insn)
diff --git a/kernel/drivers/analogy/intel/parport.c 
b/kernel/drivers/analogy/intel/parport.c
index 89b7bc5..2bab02a 100644
--- a/kernel/drivers/analogy/intel/parport.c
+++ b/kernel/drivers/analogy/intel/parport.c
@@ -235,7 +235,7 @@ static int parport_intr_cmd(a4l_subd_t *subd, a4l_cmd_t 
*cmd)
        return 0;
 }
 
-static int parport_intr_cancel(a4l_subd_t *subd)
+static void parport_intr_cancel(a4l_subd_t *subd)
 {
        a4l_dev_t *dev = subd->dev;
 
@@ -245,8 +245,6 @@ static int parport_intr_cancel(a4l_subd_t *subd)
        outb(devpriv->c_data, devpriv->io_base + PARPORT_C);
 
        devpriv->enable_irq = 0;
-
-       return 0;
 }
 
 static int parport_interrupt(unsigned int irq, void *d)
diff --git a/kernel/drivers/analogy/national_instruments/mio_common.c 
b/kernel/drivers/analogy/national_instruments/mio_common.c
index bd7f441..542c6aa 100644
--- a/kernel/drivers/analogy/national_instruments/mio_common.c
+++ b/kernel/drivers/analogy/national_instruments/mio_common.c
@@ -1531,7 +1531,7 @@ static int ni_cdo_setup_MITE_dma(a4l_subd_t *subd)
 
 #endif /* CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE */
 
-static int ni_ai_reset(a4l_subd_t *subd)
+static void ni_ai_reset(a4l_subd_t *subd)
 {
        a4l_dev_t *dev = subd->dev;
 
@@ -1617,8 +1617,6 @@ static int ni_ai_reset(a4l_subd_t *subd)
                            AI_STOP_Interrupt_Ack, Interrupt_A_Ack_Register);
 
        devpriv->stc_writew(dev, AI_Configuration_End, Joint_Reset_Register);
-
-       return 0;
 }
 
 static int ni_ai_insn_read(a4l_subd_t *subd, a4l_kinsn_t *insn)
@@ -3189,7 +3187,7 @@ int ni_ao_cmdtest(a4l_subd_t *subd, a4l_cmd_t *cmd)
        return 0;
 }
 
-int ni_ao_reset(a4l_subd_t *subd)
+void ni_ao_reset(a4l_subd_t *subd)
 {
        a4l_dev_t *dev = subd->dev;
 
@@ -3225,8 +3223,6 @@ int ni_ao_reset(a4l_subd_t *subd)
                ao_win_out(CLEAR_WG, AO_Misc_611x);
        }
        devpriv->stc_writew(dev, AO_Configuration_End, Joint_Reset_Register);
-
-       return 0;
 }
 
 /* digital io */
@@ -3471,7 +3467,7 @@ int ni_cdio_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd)
        return 0;
 }
 
-int ni_cdio_cancel(a4l_subd_t *subd)
+void ni_cdio_cancel(a4l_subd_t *subd)
 {
        a4l_dev_t *dev = subd->dev;
        ni_writel(CDO_Disarm_Bit | CDO_Error_Interrupt_Enable_Clear_Bit |
@@ -3481,7 +3477,6 @@ int ni_cdio_cancel(a4l_subd_t *subd)
 
        ni_writel(0, M_Offset_CDO_Mask_Enable);
        ni_release_cdo_mite_channel(dev);
-       return 0;
 }
 
 int ni_cdo_inttrig(a4l_subd_t *subd, lsampl_t trignum)
@@ -4521,16 +4516,15 @@ static int ni_gpct_cmdtest(a4l_subd_t *subd, a4l_cmd_t 
*cmd)
        return a4l_ni_tio_cmdtest(counter, cmd);
 }
 
-static int ni_gpct_cancel(a4l_subd_t *subd)
+static void ni_gpct_cancel(a4l_subd_t *subd)
 {
        a4l_dev_t *dev = subd->dev;
        struct ni_gpct *counter = (struct ni_gpct *)subd->priv;
        int retval;
 
-       retval = a4l_ni_tio_cancel(counter);
+       a4l_ni_tio_cancel(counter);
        ni_e_series_enable_second_irq(dev, counter->counter_index, 0);
        ni_release_gpct_mite_channel(dev, counter->counter_index);
-       return retval;
 }
 
 #endif /* CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE */
diff --git a/kernel/drivers/analogy/rtdm_interface.c 
b/kernel/drivers/analogy/rtdm_interface.c
index 9be9560..3465b36 100644
--- a/kernel/drivers/analogy/rtdm_interface.c
+++ b/kernel/drivers/analogy/rtdm_interface.c
@@ -130,10 +130,9 @@ void a4l_cleanup_proc(void)
 
 #endif /* CONFIG_PROC_FS */
 
-int a4l_open(struct rtdm_dev_context *context,
-            rtdm_user_info_t * user_info, int flags)
+int a4l_open(struct rtdm_fd *fd, int flags)
 {
-       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context);
+       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_fd_to_private(fd);
 
        /* Get a pointer on the selected device
           (thanks to minor index) */
@@ -153,17 +152,12 @@ int a4l_open(struct rtdm_dev_context *context,
        return 0;
 }
 
-int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info)
+void a4l_close(struct rtdm_fd *fd)
 {
-       int err;
-       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context);
+       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_fd_to_private(fd);
 
        /* Cancel the maybe occuring asynchronous transfer */
-       err = a4l_cancel_buffer(cxt);
-       if (err < 0) {
-               __a4l_err("close: unable to stop the asynchronous transfer\n");
-               return err;
-       }
+       a4l_cancel_buffer(cxt);
 
        /* Free the buffer which was linked with this context and... */
        a4l_free_buffer(cxt->buffer);
@@ -173,59 +167,48 @@ int a4l_close(struct rtdm_dev_context *context, 
rtdm_user_info_t * user_info)
 
        /* ...free the structure */
        rtdm_free(cxt->buffer);
-
-       return 0;
 }
 
-ssize_t a4l_read(struct rtdm_dev_context * context,
-                rtdm_user_info_t * user_info, void *buf, size_t nbytes)
+ssize_t a4l_read(struct rtdm_fd *fd, void *buf, size_t nbytes)
 {
-       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context);
+       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_fd_to_private(fd);
 
        /* Jump into the RT domain if possible */
-       if (!rtdm_in_rt_context() && rtdm_rt_capable(user_info))
+       if (!rtdm_in_rt_context() && rtdm_rt_capable(fd))
                return -ENOSYS;
 
        if (nbytes == 0)
                return 0;
 
-       cxt->user_info = user_info;
-
        return a4l_read_buffer(cxt, buf, nbytes);
 }
 
-ssize_t a4l_write(struct rtdm_dev_context * context,
-                 rtdm_user_info_t *user_info, const void *buf, size_t nbytes)
+ssize_t a4l_write(struct rtdm_fd *fd, const void *buf, size_t nbytes)
 {
-       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context);
+       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_fd_to_private(fd);
 
        /* Jump into the RT domain if possible */
-       if (!rtdm_in_rt_context() && rtdm_rt_capable(user_info))
+       if (!rtdm_in_rt_context() && rtdm_rt_capable(fd))
                return -ENOSYS;
 
        if (nbytes == 0)
                return 0;
 
-       cxt->user_info = user_info;
-
        return a4l_write_buffer(cxt, buf, nbytes);
 }
 
-int a4l_ioctl(struct rtdm_dev_context *context,
-             rtdm_user_info_t *user_info, unsigned int request, void *arg)
+int a4l_ioctl(struct rtdm_fd *fd, unsigned int request, void *arg)
 {
-       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context);
-
-       cxt->user_info = user_info;
+       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_fd_to_private(fd);
 
        return a4l_ioctl_functions[_IOC_NR(request)] (cxt, arg);
 }
 
-int a4l_rt_select(struct rtdm_dev_context *context,
+int a4l_rt_select(struct rtdm_fd *fd,
                  rtdm_selector_t *selector,
                  enum rtdm_selecttype type, unsigned fd_index)
 {
-       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context);
+       a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_fd_to_private(fd);
 
        return a4l_select(cxt, selector, type, fd_index);
 }
@@ -237,14 +220,14 @@ static struct rtdm_device rtdm_devs[A4L_NB_DEVICES] =
                .context_size =         sizeof(struct a4l_device_context),
                .device_name =          "",
 
-               .open_nrt =             a4l_open,
+               .open =                 a4l_open,
 
                .ops = {
                        .ioctl_rt =     a4l_ioctl,
                        .read_rt =      a4l_read,
                        .write_rt =     a4l_write,
 
-                       .close_nrt =    a4l_close,
+                       .close =        a4l_close,
                        .ioctl_nrt =    a4l_ioctl,
                        .read_nrt =     a4l_read,
                        .write_nrt =    a4l_write,
diff --git a/kernel/drivers/analogy/subdevice.c 
b/kernel/drivers/analogy/subdevice.c
index 50bce74..bbdada2 100644
--- a/kernel/drivers/analogy/subdevice.c
+++ b/kernel/drivers/analogy/subdevice.c
@@ -178,6 +178,7 @@ a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx)
 
 int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        a4l_dev_t *dev = a4l_get_dev(cxt);
        int i, ret = 0;
        a4l_sbinfo_t *subd_info;
@@ -201,7 +202,7 @@ int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg)
                        dev->transfer.subds[i]->chan_desc->length : 0;
        }
 
-       if (rtdm_safe_copy_to_user(cxt->user_info,
+       if (rtdm_safe_copy_to_user(fd,
                                   arg,
                                   subd_info, dev->transfer.nb_subd *
                                   sizeof(a4l_sbinfo_t)) != 0)
@@ -215,6 +216,7 @@ int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg)
 
 int a4l_ioctl_nbchaninfo(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        a4l_dev_t *dev = a4l_get_dev(cxt);
        a4l_chinfo_arg_t inarg;
 
@@ -224,7 +226,7 @@ int a4l_ioctl_nbchaninfo(a4l_cxt_t * cxt, void *arg)
                return -EINVAL;
        }
 
-       if (rtdm_safe_copy_from_user(cxt->user_info,
+       if (rtdm_safe_copy_from_user(fd,
                                     &inarg, arg,
                                     sizeof(a4l_chinfo_arg_t)) != 0)
                return -EFAULT;
@@ -241,7 +243,7 @@ int a4l_ioctl_nbchaninfo(a4l_cxt_t * cxt, void *arg)
                inarg.info = (void *)(unsigned long)
                        dev->transfer.subds[inarg.idx_subd]->chan_desc->length;
 
-       if (rtdm_safe_copy_to_user(cxt->user_info,
+       if (rtdm_safe_copy_to_user(fd,
                                   arg,
                                   &inarg, sizeof(a4l_chinfo_arg_t)) != 0)
                return -EFAULT;
@@ -251,6 +253,7 @@ int a4l_ioctl_nbchaninfo(a4l_cxt_t * cxt, void *arg)
 
 int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        int i, ret = 0;
        a4l_dev_t *dev = a4l_get_dev(cxt);
        a4l_chinfo_t *chan_info;
@@ -264,7 +267,7 @@ int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg)
                return -EINVAL;
        }
 
-       if (rtdm_safe_copy_from_user(cxt->user_info,
+       if (rtdm_safe_copy_from_user(fd,
                                     &inarg, arg,
                                     sizeof(a4l_chinfo_arg_t)) != 0)
                return -EFAULT;
@@ -305,7 +308,7 @@ int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg)
                        chan_info[i].chan_flags |= A4L_CHAN_GLOBAL;
        }
 
-       if (rtdm_safe_copy_to_user(cxt->user_info,
+       if (rtdm_safe_copy_to_user(fd,
                                   inarg.info,
                                   chan_info,
                                   chan_desc->length *
@@ -320,6 +323,7 @@ int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg)
 int a4l_ioctl_nbrnginfo(a4l_cxt_t * cxt, void *arg)
 {
        int i;
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        a4l_dev_t *dev = a4l_get_dev(cxt);
        a4l_rnginfo_arg_t inarg;
        a4l_rngdesc_t *rng_desc;
@@ -330,7 +334,7 @@ int a4l_ioctl_nbrnginfo(a4l_cxt_t * cxt, void *arg)
                return -EINVAL;
        }
 
-       if (rtdm_safe_copy_from_user(cxt->user_info,
+       if (rtdm_safe_copy_from_user(fd,
                                     &inarg,
                                     arg, sizeof(a4l_rnginfo_arg_t)) != 0)
                return -EFAULT;
@@ -362,7 +366,7 @@ int a4l_ioctl_nbrnginfo(a4l_cxt_t * cxt, void *arg)
                inarg.info = (void *)0;
 
 
-       if (rtdm_safe_copy_to_user(cxt->user_info,
+       if (rtdm_safe_copy_to_user(fd,
                                   arg,
                                   &inarg, sizeof(a4l_rnginfo_arg_t)) != 0)
                return -EFAULT;
@@ -372,6 +376,7 @@ int a4l_ioctl_nbrnginfo(a4l_cxt_t * cxt, void *arg)
 
 int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg)
 {
+       struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
        int i, ret = 0;
        unsigned int tmp;
        a4l_dev_t *dev = a4l_get_dev(cxt);
@@ -385,7 +390,7 @@ int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg)
                return -EINVAL;
        }
 
-       if (rtdm_safe_copy_from_user(cxt->user_info,
+       if (rtdm_safe_copy_from_user(fd,
                                     &inarg,
                                     arg, sizeof(a4l_rnginfo_arg_t)) != 0)
                return -EFAULT;
@@ -433,7 +438,7 @@ int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg)
                        rng_info[i].flags |= A4L_RNG_GLOBAL;
        }
 
-       if (rtdm_safe_copy_to_user(cxt->user_info,
+       if (rtdm_safe_copy_to_user(fd,
                                   inarg.info,
                                   rng_info,
                                   rng_desc->rngtabs[tmp]->length *
diff --git a/kernel/drivers/analogy/testing/fake.c 
b/kernel/drivers/analogy/testing/fake.c
index 795a87f..4a1bb43 100644
--- a/kernel/drivers/analogy/testing/fake.c
+++ b/kernel/drivers/analogy/testing/fake.c
@@ -298,13 +298,11 @@ static int ai_cmdtest(a4l_subd_t *subd, a4l_cmd_t *cmd)
        return 0;
 }
 
-static int ai_cancel(a4l_subd_t *subd)
+static void ai_cancel(a4l_subd_t *subd)
 {
        struct fake_priv *priv = (struct fake_priv *)subd->dev->priv;
 
        priv->ai_running = 0;
-
-       return 0;
 }
 
 static void ai_munge(a4l_subd_t *subd, void *buf, unsigned long size)
@@ -332,7 +330,7 @@ int ao_trigger(a4l_subd_t *subd, lsampl_t trignum)
        return 0;
 }
 
-int ao_cancel(a4l_subd_t *subd)
+void ao_cancel(a4l_subd_t *subd)
 {
        struct fake_priv *priv = (struct fake_priv *)subd->dev->priv;
        struct ao_ai2_priv *ao_priv = (struct ao_ai2_priv *)subd->priv;
@@ -352,8 +350,6 @@ int ao_cancel(a4l_subd_t *subd)
                ao_priv->count = 0;
                a4l_buf_evt(ai2_subd, A4L_BUF_EOA);
        }
-
-       return 0;
 }
 
 /* --- Asynchronous 2nd AI functions --- */
@@ -367,7 +363,7 @@ int ai2_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd)
        return 0;
 }
 
-int ai2_cancel(a4l_subd_t *subd)
+void ai2_cancel(a4l_subd_t *subd)
 {
        struct fake_priv *priv = (struct fake_priv *)subd->dev->priv;
        struct ao_ai2_priv *ai2_priv = *((struct ao_ai2_priv **)subd->priv);
@@ -388,8 +384,6 @@ int ai2_cancel(a4l_subd_t *subd)
                ai2_priv->count = 0;
                a4l_buf_evt(ao_subd, A4L_BUF_EOA);
        }
-
-       return 0;
 }
 
 
diff --git a/kernel/drivers/analogy/testing/loop.c 
b/kernel/drivers/analogy/testing/loop.c
index 0e6125c..58bb7ef 100644
--- a/kernel/drivers/analogy/testing/loop.c
+++ b/kernel/drivers/analogy/testing/loop.c
@@ -134,15 +134,13 @@ int loop_trigger(a4l_subd_t *subd, lsampl_t trignum)
 }
 
 /* Cancel callback */
-int loop_cancel(a4l_subd_t *subd)
+void loop_cancel(a4l_subd_t *subd)
 {
        lpprv_t *priv = (lpprv_t *)subd->dev->priv;
 
        a4l_info(subd->dev, "loop_cancel: (subd=%d)\n", subd->idx);
 
        priv->loop_running = 0;
-
-       return 0;
 }
 
 /* Read instruction callback */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to