Module: xenomai-gch
Branch: for-forge-rtdm-rework
Commit: d64492867f6aa68686ee9bebf21e3daba524ab73
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=d64492867f6aa68686ee9bebf21e3daba524ab73

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

analogy: adapt to RTDM API changes

---

 include/analogy/buffer.h                           |   12 +++--
 include/analogy/context.h                          |    8 +--
 include/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/analogy/buffer.h b/include/analogy/buffer.h
index f40ed4c..fb18689 100644
--- a/include/analogy/buffer.h
+++ b/include/analogy/buffer.h
@@ -104,6 +104,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;
 
@@ -113,10 +114,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);
 
@@ -136,6 +137,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;
 
@@ -145,10 +147,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);
@@ -397,7 +399,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/analogy/context.h b/include/analogy/context.h
index 497a40e..82795cb 100644
--- a/include/analogy/context.h
+++ b/include/analogy/context.h
@@ -31,10 +31,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;
@@ -49,9 +45,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 /* __KERNEL__ && !DOXYGEN_CPP */
diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h
index 5e929d4..1ff7a7b 100644
--- a/include/analogy/subdevice.h
+++ b/include/analogy/subdevice.h
@@ -218,7 +218,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 98daae7..d93fd4c 100644
--- a/kernel/drivers/analogy/buffer.c
+++ b/kernel/drivers/analogy/buffer.c
@@ -173,24 +173,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);
@@ -202,8 +199,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 --- */
@@ -490,6 +485,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;
@@ -517,7 +513,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;
 
@@ -526,7 +522,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,
@@ -538,7 +534,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));
 }
 
@@ -577,7 +573,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
@@ -586,6 +583,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;
@@ -603,7 +601,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;
@@ -643,6 +641,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;
@@ -653,7 +652,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;
@@ -676,6 +675,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;
@@ -684,7 +684,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 */
@@ -693,7 +693,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;
 
@@ -772,7 +772,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;
 
@@ -786,6 +786,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;
@@ -798,7 +799,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;
 
@@ -1046,6 +1047,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);
@@ -1053,7 +1055,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 */
@@ -1068,7 +1070,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;
 
@@ -1128,7 +1130,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 2ce97ac..81ec32a 100644
--- a/kernel/drivers/analogy/command.c
+++ b/kernel/drivers/analogy/command.c
@@ -38,7 +38,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;
@@ -54,7 +54,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 724a931..e56e574 100644
--- a/kernel/drivers/analogy/device.c
+++ b/kernel/drivers/analogy/device.c
@@ -179,11 +179,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: "
@@ -201,7 +202,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);
@@ -226,7 +227,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);
@@ -435,6 +436,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);
 
@@ -450,7 +452,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 0558370..08906a1 100644
--- a/kernel/drivers/analogy/instruction.c
+++ b/kernel/drivers/analogy/instruction.c
@@ -123,10 +123,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;
@@ -145,7 +146,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)
@@ -166,10 +167,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);
 
@@ -289,11 +291,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 */
@@ -329,12 +332,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;
@@ -391,11 +395,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 daa8dae..a2eee49 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 f04c84d..b0cf445 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 b553dfc..443cb20 100644
--- a/kernel/drivers/analogy/rtdm_interface.c
+++ b/kernel/drivers/analogy/rtdm_interface.c
@@ -137,10 +137,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) */
@@ -160,17 +159,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);
@@ -180,59 +174,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);
 }
@@ -244,14 +227,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 2bd3d5e..b768c88 100644
--- a/kernel/drivers/analogy/subdevice.c
+++ b/kernel/drivers/analogy/subdevice.c
@@ -184,6 +184,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;
@@ -207,7 +208,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)
@@ -221,6 +222,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;
 
@@ -230,7 +232,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;
@@ -247,7 +249,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;
@@ -257,6 +259,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;
@@ -270,7 +273,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;
@@ -311,7 +314,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 *
@@ -326,6 +329,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;
@@ -336,7 +340,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;
@@ -368,7 +372,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;
@@ -378,6 +382,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);
@@ -391,7 +396,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;
@@ -439,7 +444,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 a2390aa..114d2f3 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 e97535d..7b67938 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