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

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Wed Jun 10 00:47:19 2009 +0200

Fix obvious bug in IRQ registering procedure

---

 include/comedi/device.h                            |    4 +-
 ksrc/drivers/comedi/buffer.c                       |  148 ++++++++++----------
 ksrc/drivers/comedi/command.c                      |   24 ++--
 ksrc/drivers/comedi/device.c                       |   16 ++-
 ksrc/drivers/comedi/instruction.c                  |   10 +-
 .../comedi/national_instruments/mio_common.c       |    2 +-
 ksrc/drivers/comedi/subdevice.c                    |   32 ++--
 ksrc/drivers/comedi/transfer.c                     |   81 +++++------
 8 files changed, 156 insertions(+), 161 deletions(-)

diff --git a/include/comedi/device.h b/include/comedi/device.h
index 9c4d86f..4d396c9 100644
--- a/include/comedi/device.h
+++ b/include/comedi/device.h
@@ -50,8 +50,8 @@ struct comedi_device {
        /* Hidden description stuff */
        struct list_head subdvsq;
 
-       /* TODO: transfer should not be a pointer */
-       comedi_trf_t *transfer;
+       /* Context-dependent stuff */
+       comedi_trf_t transfer;
 
        /* Private data useful for drivers functioning */
        void *priv;
diff --git a/ksrc/drivers/comedi/buffer.c b/ksrc/drivers/comedi/buffer.c
index 2647d1c..98b12c5 100644
--- a/ksrc/drivers/comedi/buffer.c
+++ b/ksrc/drivers/comedi/buffer.c
@@ -104,14 +104,14 @@ comedi_cmd_t *comedi_get_cmd(comedi_dev_t * dev,
        /* If the field type is properly set, 
           it is used instead of idx_subd */
        if (type == COMEDI_BUF_PUT)
-               idx = dev->transfer->idx_read_subd;
+               idx = dev->transfer.idx_read_subd;
        else if (type == COMEDI_BUF_GET)
-               idx = dev->transfer->idx_write_subd;
+               idx = dev->transfer.idx_write_subd;
        else
                idx = idx_subd;
 
-       if (dev->transfer->bufs != NULL)
-               return dev->transfer->bufs[idx]->cur_cmd;
+       if (dev->transfer.bufs != NULL)
+               return dev->transfer.bufs[idx]->cur_cmd;
        else
                return NULL;
 }
@@ -125,15 +125,15 @@ int comedi_get_chan(comedi_subd_t *subd)
        comedi_cmd_t *cmd;
 
        /* Check that subdevice supports commands */
-       if (dev->transfer->bufs == NULL)
+       if (dev->transfer.bufs == NULL)
                return -EINVAL;
 
        /* Check a command is executed */
-       if (dev->transfer->bufs[subd->idx]->cur_cmd == NULL)
+       if (dev->transfer.bufs[subd->idx]->cur_cmd == NULL)
                return -EINVAL;
 
        /* Retrieve the proper command descriptor */
-       cmd = dev->transfer->bufs[subd->idx]->cur_cmd;
+       cmd = dev->transfer.bufs[subd->idx]->cur_cmd;
 
        /* There is no need to check the channel idx, 
           it has already been controlled in command_test */
@@ -142,13 +142,13 @@ int comedi_get_chan(comedi_subd_t *subd)
           so, we have to compute the global size of the channels
           in this command... */
        for (i = 0; i < cmd->nb_chan; i++)
-               tmp_size += dev->transfer->subds[subd->idx]->chan_desc->
+               tmp_size += dev->transfer.subds[subd->idx]->chan_desc->
                        chans[CR_CHAN(cmd->chan_descs[i])].nb_bits;
 
        /* Translation bits -> bytes */
        tmp_size /= 8;
 
-       tmp_count = dev->transfer->bufs[subd->idx]->mng_count % tmp_size;
+       tmp_count = dev->transfer.bufs[subd->idx]->mng_count % tmp_size;
 
        /* Translation bytes -> bits */
        tmp_count *= 8;
@@ -156,7 +156,7 @@ int comedi_get_chan(comedi_subd_t *subd)
        /* ...and find the channel the last munged sample 
           was related with */
        for (i = 0; tmp_count > 0 && i < cmd->nb_chan; i++)
-               tmp_count -= dev->transfer->subds[subd->idx]->chan_desc->
+               tmp_count -= dev->transfer.subds[subd->idx]->chan_desc->
                        chans[CR_CHAN(cmd->chan_descs[i])].nb_bits;
 
        if (tmp_count == 0)
@@ -169,7 +169,7 @@ int comedi_get_chan(comedi_subd_t *subd)
 
 int comedi_buf_prepare_absput(comedi_dev_t * dev, unsigned long count)
 {
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_read_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_read_subd];
 
        return __pre_abs_put(buf, count);
 }
@@ -177,21 +177,21 @@ int comedi_buf_prepare_absput(comedi_dev_t * dev, 
unsigned long count)
 int comedi_buf_commit_absput(comedi_dev_t * dev, unsigned long count)
 {
 
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_read_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_read_subd];
 
        return __abs_put(buf, count);
 }
 
 int comedi_buf_prepare_put(comedi_dev_t * dev, unsigned long count)
 {
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_read_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_read_subd];
 
        return __pre_put(buf, count);
 }
 
 int comedi_buf_commit_put(comedi_dev_t * dev, unsigned long count)
 {
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_read_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_read_subd];
 
        return __put(buf, count);
 }
@@ -199,7 +199,7 @@ int comedi_buf_commit_put(comedi_dev_t * dev, unsigned long 
count)
 int comedi_buf_put(comedi_dev_t * dev, void *bufdata, unsigned long count)
 {
        int ret;
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_read_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_read_subd];
 
        if (__count_to_put(buf) < count)
                return -EAGAIN;
@@ -214,28 +214,28 @@ int comedi_buf_put(comedi_dev_t * dev, void *bufdata, 
unsigned long count)
 
 int comedi_buf_prepare_absget(comedi_dev_t * dev, unsigned long count)
 {
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_write_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_write_subd];
 
        return __pre_abs_get(buf, count);
 }
 
 int comedi_buf_commit_absget(comedi_dev_t * dev, unsigned long count)
 {
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_write_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_write_subd];
 
        return __abs_get(buf, count);
 }
 
 int comedi_buf_prepare_get(comedi_dev_t * dev, unsigned long count)
 {
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_write_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_write_subd];
 
        return __pre_get(buf, count);
 }
 
 int comedi_buf_commit_get(comedi_dev_t * dev, unsigned long count)
 {
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_write_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_write_subd];
 
        return __get(buf, count);
 }
@@ -243,7 +243,7 @@ int comedi_buf_commit_get(comedi_dev_t * dev, unsigned long 
count)
 int comedi_buf_get(comedi_dev_t * dev, void *bufdata, unsigned long count)
 {
        int ret;
-       comedi_buf_t *buf = dev->transfer->bufs[dev->transfer->idx_write_subd];
+       comedi_buf_t *buf = dev->transfer.bufs[dev->transfer.idx_write_subd];
 
        if (__count_to_get(buf) < count)
                return -EAGAIN;
@@ -265,16 +265,16 @@ int comedi_buf_evt(comedi_dev_t * dev, unsigned int type, 
unsigned long evts)
 
        /* Retrieves the subdevice's index */
        if (type == COMEDI_BUF_PUT)
-               idx_subd = dev->transfer->idx_read_subd;
+               idx_subd = dev->transfer.idx_read_subd;
        else if (type == COMEDI_BUF_GET)
-               idx_subd = dev->transfer->idx_write_subd;
+               idx_subd = dev->transfer.idx_write_subd;
        else
                return -EINVAL;
 
-       buf = dev->transfer->bufs[idx_subd];
+       buf = dev->transfer.bufs[idx_subd];
 
        /* Basic checking */
-       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer->status[idx_subd])))
+       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer.status[idx_subd])))
                return -ENOENT;
 
        /* Even if it is a little more complex,
@@ -297,10 +297,10 @@ unsigned long comedi_buf_count(comedi_dev_t * dev, 
unsigned int type)
        comedi_buf_t *buf;
 
        if (type == COMEDI_BUF_PUT) {
-               buf = dev->transfer->bufs[dev->transfer->idx_read_subd];
+               buf = dev->transfer.bufs[dev->transfer.idx_read_subd];
                ret = __count_to_put(buf);
        } else if (type == COMEDI_BUF_GET) {
-               buf = dev->transfer->bufs[dev->transfer->idx_write_subd];
+               buf = dev->transfer.bufs[dev->transfer.idx_write_subd];
                ret = __count_to_get(buf);
        }
 
@@ -350,30 +350,30 @@ int comedi_ioctl_mmap(comedi_cxt_t * cxt, void *arg)
                return -EFAULT;
 
        /* Checks the subdevice */
-       if (map_cfg.idx_subd >= dev->transfer->nb_subd ||
-           (dev->transfer->subds[map_cfg.idx_subd]->flags & COMEDI_SUBD_CMD) ==
+       if (map_cfg.idx_subd >= dev->transfer.nb_subd ||
+           (dev->transfer.subds[map_cfg.idx_subd]->flags & COMEDI_SUBD_CMD) ==
            0
-           || (dev->transfer->subds[map_cfg.idx_subd]->
+           || (dev->transfer.subds[map_cfg.idx_subd]->
                flags & COMEDI_SUBD_MMAP) == 0)
                return -EINVAL;
 
        /* Checks the buffer is not already mapped */
        if (test_bit(COMEDI_TSF_MMAP,
-                    &(dev->transfer->status[map_cfg.idx_subd])))
+                    &(dev->transfer.status[map_cfg.idx_subd])))
                return -EBUSY;
 
        /* Basically checks the size to be mapped */
        if ((map_cfg.size & ~(PAGE_MASK)) != 0 ||
-           map_cfg.size > dev->transfer->bufs[map_cfg.idx_subd]->size)
+           map_cfg.size > dev->transfer.bufs[map_cfg.idx_subd]->size)
                return -EFAULT;
 
        ret = rtdm_mmap_to_user(cxt->rtdm_usrinf,
-                               dev->transfer->bufs[map_cfg.idx_subd]->buf,
+                               dev->transfer.bufs[map_cfg.idx_subd]->buf,
                                map_cfg.size,
                                PROT_READ | PROT_WRITE,
                                &map_cfg.ptr,
                                &comedi_vm_ops,
-                               &(dev->transfer->status[map_cfg.idx_subd]));
+                               &(dev->transfer.status[map_cfg.idx_subd]));
 
        if (ret < 0)
                return ret;
@@ -404,7 +404,7 @@ int comedi_ioctl_bufcfg(comedi_cxt_t * cxt, void *arg)
                                  &buf_cfg, arg, sizeof(comedi_bufcfg_t)) != 0)
                return -EFAULT;
 
-       if (buf_cfg.idx_subd >= dev->transfer->nb_subd)
+       if (buf_cfg.idx_subd >= dev->transfer.nb_subd)
                return -EINVAL;
 
        if (buf_cfg.buf_size > COMEDI_BUF_MAXSIZE)
@@ -413,19 +413,19 @@ int comedi_ioctl_bufcfg(comedi_cxt_t * cxt, void *arg)
        /* If a transfer is occuring or if the buffer is mmapped,
           no buffer size change is allowed */
        if (test_bit(COMEDI_TSF_BUSY,
-                    &(dev->transfer->status[buf_cfg.idx_subd])))
+                    &(dev->transfer.status[buf_cfg.idx_subd])))
                return -EBUSY;
 
        if (test_bit(COMEDI_TSF_MMAP,
-                    &(dev->transfer->status[buf_cfg.idx_subd])))
+                    &(dev->transfer.status[buf_cfg.idx_subd])))
                return -EPERM;
 
        /* Performs the re-allocation */
-       comedi_free_buffer(dev->transfer->bufs[buf_cfg.idx_subd]);
+       comedi_free_buffer(dev->transfer.bufs[buf_cfg.idx_subd]);
 
-       dev->transfer->bufs[buf_cfg.idx_subd]->size = buf_cfg.buf_size;
+       dev->transfer.bufs[buf_cfg.idx_subd]->size = buf_cfg.buf_size;
 
-       return comedi_alloc_buffer(dev->transfer->bufs[buf_cfg.idx_subd]);
+       return comedi_alloc_buffer(dev->transfer.bufs[buf_cfg.idx_subd]);
 }
 
 int comedi_ioctl_bufinfo(comedi_cxt_t * cxt, void *arg)
@@ -447,17 +447,17 @@ int comedi_ioctl_bufinfo(comedi_cxt_t * cxt, void *arg)
                                  &info, arg, sizeof(comedi_bufinfo_t)) != 0)
                return -EFAULT;
 
-       if (info.idx_subd > dev->transfer->nb_subd)
+       if (info.idx_subd > dev->transfer.nb_subd)
                return -EINVAL;
 
-       if ((dev->transfer->subds[info.idx_subd]->flags & COMEDI_SUBD_CMD) == 0)
+       if ((dev->transfer.subds[info.idx_subd]->flags & COMEDI_SUBD_CMD) == 0)
                return -EINVAL;
 
-       buf = dev->transfer->bufs[info.idx_subd];
+       buf = dev->transfer.bufs[info.idx_subd];
 
        ret = __handle_event(buf);
 
-       if (info.idx_subd == dev->transfer->idx_read_subd) {
+       if (info.idx_subd == dev->transfer.idx_read_subd) {
 
                /* Updates consume count if rw_count is not null */
                if (info.rw_count != 0)
@@ -474,7 +474,7 @@ int comedi_ioctl_bufinfo(comedi_cxt_t * cxt, void *arg)
                        comedi_cancel_transfer(cxt, info.idx_subd);
                        return ret;
                }
-       } else if (info.idx_subd == dev->transfer->idx_write_subd) {
+       } else if (info.idx_subd == dev->transfer.idx_write_subd) {
 
                if (ret < 0) {
                        comedi_cancel_transfer(cxt, info.idx_subd);
@@ -504,9 +504,9 @@ int comedi_ioctl_bufinfo(comedi_cxt_t * cxt, void *arg)
                return -EINVAL;
 
        /* Performs the munge if need be */
-       if (dev->transfer->subds[info.idx_subd]->munge != NULL) {
-               __munge(dev->transfer->subds[info.idx_subd],
-                       dev->transfer->subds[info.idx_subd]->munge,
+       if (dev->transfer.subds[info.idx_subd]->munge != NULL) {
+               __munge(dev->transfer.subds[info.idx_subd],
+                       dev->transfer.subds[info.idx_subd]->munge,
                        buf, tmp_cnt);
 
                /* Updates munge count */
@@ -526,19 +526,19 @@ int comedi_ioctl_bufinfo(comedi_cxt_t * cxt, void *arg)
 ssize_t comedi_read(comedi_cxt_t * cxt, void *bufdata, size_t nbytes)
 {
        comedi_dev_t *dev = comedi_get_dev(cxt);
-       int idx_subd = dev->transfer->idx_read_subd;
-       comedi_buf_t *buf = dev->transfer->bufs[idx_subd];
+       int idx_subd = dev->transfer.idx_read_subd;
+       comedi_buf_t *buf = dev->transfer.bufs[idx_subd];
        ssize_t count = 0;
 
        /* Basic checkings */
        if (!test_bit(COMEDI_DEV_ATTACHED, &dev->flags))
                return -EINVAL;
 
-       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer->status[idx_subd])))
+       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer.status[idx_subd])))
                return -ENOENT;
 
        /* Checks the subdevice capabilities */
-       if ((dev->transfer->subds[idx_subd]->flags & COMEDI_SUBD_CMD) == 0)
+       if ((dev->transfer.subds[idx_subd]->flags & COMEDI_SUBD_CMD) == 0)
                return -EINVAL;
 
        while (count < nbytes) {
@@ -564,9 +564,9 @@ ssize_t comedi_read(comedi_cxt_t * cxt, void *bufdata, 
size_t nbytes)
                if (tmp_cnt > 0) {
 
                        /* Performs the munge if need be */
-                       if (dev->transfer->subds[idx_subd]->munge != NULL) {
-                               __munge(dev->transfer->subds[idx_subd],
-                                       dev->transfer->subds[idx_subd]->munge,
+                       if (dev->transfer.subds[idx_subd]->munge != NULL) {
+                               __munge(dev->transfer.subds[idx_subd],
+                                       dev->transfer.subds[idx_subd]->munge,
                                        buf, tmp_cnt);
 
                                /* Updates munge count */
@@ -590,7 +590,7 @@ ssize_t comedi_read(comedi_cxt_t * cxt, void *bufdata, 
size_t nbytes)
                        /* If the driver does not work in bulk mode,
                           we must leave this function */
                        if (!test_bit(COMEDI_TSF_BULK,
-                                     &(dev->transfer->status[idx_subd])))
+                                     &(dev->transfer.status[idx_subd])))
                                goto out_comedi_read;
                }
                /* If the acquisition is not over, we must not
@@ -615,19 +615,19 @@ ssize_t comedi_write(comedi_cxt_t *cxt,
                     const void *bufdata, size_t nbytes)
 {
        comedi_dev_t *dev = comedi_get_dev(cxt);
-       int idx_subd = dev->transfer->idx_write_subd;
-       comedi_buf_t *buf = dev->transfer->bufs[idx_subd];
+       int idx_subd = dev->transfer.idx_write_subd;
+       comedi_buf_t *buf = dev->transfer.bufs[idx_subd];
        ssize_t count = 0;
 
        /* Basic checkings */
        if (!test_bit(COMEDI_DEV_ATTACHED, &dev->flags))
                return -EINVAL;
 
-       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer->status[idx_subd])))
+       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer.status[idx_subd])))
                return -ENOENT;
 
        /* Checks the subdevice capabilities */
-       if ((dev->transfer->subds[idx_subd]->flags & COMEDI_SUBD_CMD) == 0)
+       if ((dev->transfer.subds[idx_subd]->flags & COMEDI_SUBD_CMD) == 0)
                return -EINVAL;
 
        while (count < nbytes) {
@@ -661,9 +661,9 @@ ssize_t comedi_write(comedi_cxt_t *cxt,
                        }
 
                        /* Performs the munge if need be */
-                       if (dev->transfer->subds[idx_subd]->munge != NULL) {
-                               __munge(dev->transfer->subds[idx_subd],
-                                       dev->transfer->subds[idx_subd]->munge,
+                       if (dev->transfer.subds[idx_subd]->munge != NULL) {
+                               __munge(dev->transfer.subds[idx_subd],
+                                       dev->transfer.subds[idx_subd]->munge,
                                        buf, tmp_cnt);
 
                                /* Updates munge count */
@@ -679,7 +679,7 @@ ssize_t comedi_write(comedi_cxt_t *cxt,
                        /* If the driver does not work in bulk mode,
                           we must leave this function */
                        if (!test_bit(COMEDI_TSF_BULK,
-                                     &(dev->transfer->status[idx_subd])))
+                                     &(dev->transfer.status[idx_subd])))
                                goto out_comedi_write;
                } else {
                        /* The buffer is full, we have to wait for a slot to 
free */
@@ -704,9 +704,9 @@ int comedi_select(comedi_cxt_t *cxt,
 {
        comedi_dev_t *dev = comedi_get_dev(cxt);
        int idx_subd = (type == RTDM_SELECTTYPE_READ) ? 
-               dev->transfer->idx_read_subd :
-               dev->transfer->idx_write_subd;
-       comedi_buf_t *buf = dev->transfer->bufs[idx_subd];
+               dev->transfer.idx_read_subd :
+               dev->transfer.idx_write_subd;
+       comedi_buf_t *buf = dev->transfer.bufs[idx_subd];
 
        /* Checks the RTDM select type 
           (RTDM_SELECTTYPE_EXCEPT is not supported) */
@@ -718,11 +718,11 @@ int comedi_select(comedi_cxt_t *cxt,
        if (!test_bit(COMEDI_DEV_ATTACHED, &dev->flags))
                return -EINVAL;
 
-       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer->status[idx_subd])))
+       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer.status[idx_subd])))
                return -ENOENT; 
 
        /* Checks the subdevice capabilities */
-       if ((dev->transfer->subds[idx_subd]->flags & COMEDI_SUBD_CMD) == 0)
+       if ((dev->transfer.subds[idx_subd]->flags & COMEDI_SUBD_CMD) == 0)
                return -EINVAL;
 
        /* Performs a bind on the Comedi synchronization element */
@@ -745,24 +745,24 @@ int comedi_ioctl_poll(comedi_cxt_t * cxt, void *arg)
                return -EFAULT;
 
        /* Checks the subdevice capabilities */
-       if ((dev->transfer->subds[poll.idx_subd]->flags &
+       if ((dev->transfer.subds[poll.idx_subd]->flags &
             COMEDI_SUBD_CMD) == 0 ||
-           (dev->transfer->subds[poll.idx_subd]->flags &
+           (dev->transfer.subds[poll.idx_subd]->flags &
             COMEDI_SUBD_MASK_SPECIAL) != 0)
                return -EINVAL;
 
        /* Checks a transfer is occuring */
-       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer->status[poll.idx_subd])))
+       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer.status[poll.idx_subd])))
                return -EINVAL;
 
-       buf = dev->transfer->bufs[poll.idx_subd];
+       buf = dev->transfer.bufs[poll.idx_subd];
 
        /* Checks the buffer events */
        ret = __handle_event(buf);
 
        /* Retrieves the data amount to compute 
           according to the subdevice type */
-       if ((dev->transfer->subds[poll.idx_subd]->flags &
+       if ((dev->transfer.subds[poll.idx_subd]->flags &
             COMEDI_SUBD_MASK_READ) != 0) {
 
                tmp_cnt = __count_to_get(buf);
@@ -799,7 +799,7 @@ int comedi_ioctl_poll(comedi_cxt_t * cxt, void *arg)
 
        if (ret == 0) {
                /* Retrieves the count once more */
-               if ((dev->transfer->subds[poll.idx_subd]->flags &
+               if ((dev->transfer.subds[poll.idx_subd]->flags &
                     COMEDI_SUBD_MASK_READ) != 0)
                        tmp_cnt = __count_to_get(buf);
                else
diff --git a/ksrc/drivers/comedi/command.c b/ksrc/drivers/comedi/command.c
index 9d25971..d205db3 100644
--- a/ksrc/drivers/comedi/command.c
+++ b/ksrc/drivers/comedi/command.c
@@ -95,25 +95,25 @@ int comedi_check_cmddesc(comedi_cxt_t * cxt, comedi_cmd_t * 
desc)
        __comedi_info("comedi_check_cmddesc: minor=%d\n",
                       comedi_get_minor(cxt));
 
-       if (desc->idx_subd >= dev->transfer->nb_subd) {
+       if (desc->idx_subd >= dev->transfer.nb_subd) {
                __comedi_err("comedi_check_cmddesc: "
                             "subdevice index out of range (%u >= %u)\n",
-                            desc->idx_subd, dev->transfer->nb_subd);
+                            desc->idx_subd, dev->transfer.nb_subd);
                return -EINVAL;
        }
 
-       if (dev->transfer->subds[desc->idx_subd]->flags & COMEDI_SUBD_UNUSED) {
+       if (dev->transfer.subds[desc->idx_subd]->flags & COMEDI_SUBD_UNUSED) {
                __comedi_err("comedi_check_cmddesc: "
                             "subdevice type incoherent\n");
                return -EIO;
        }
 
-       if (!(dev->transfer->subds[desc->idx_subd]->flags & COMEDI_SUBD_CMD)) {
+       if (!(dev->transfer.subds[desc->idx_subd]->flags & COMEDI_SUBD_CMD)) {
                __comedi_err("comedi_check_cmddesc: operation not supported\n");
                return -EIO;
        }
 
-       if (test_bit(COMEDI_TSF_BUSY, &(dev->transfer->status[desc->idx_subd])))
+       if (test_bit(COMEDI_TSF_BUSY, &(dev->transfer.status[desc->idx_subd])))
                return -EBUSY;
 
        if (ret != 0) {
@@ -121,7 +121,7 @@ int comedi_check_cmddesc(comedi_cxt_t * cxt, comedi_cmd_t * 
desc)
                return ret;
        }
 
-       return comedi_check_chanlist(dev->transfer->subds[desc->idx_subd],
+       return comedi_check_chanlist(dev->transfer.subds[desc->idx_subd],
                                     desc->nb_chan, desc->chan_descs);
 }
 
@@ -203,7 +203,7 @@ int comedi_check_specific_cmdcnt(comedi_cxt_t * cxt, 
comedi_cmd_t * desc)
 {
        unsigned int tmp1, tmp2;
        comedi_dev_t *dev = comedi_get_dev(cxt);
-       comedi_cmd_t *cmd_mask = dev->transfer->subds[desc->idx_subd]->cmd_mask;
+       comedi_cmd_t *cmd_mask = dev->transfer.subds[desc->idx_subd]->cmd_mask;
 
        if (cmd_mask == NULL)
                return 0;
@@ -280,9 +280,9 @@ int comedi_ioctl_cmd(comedi_cxt_t * cxt, void *arg)
                goto out_ioctl_cmd;
 
        /* Tests the command with the cmdtest function */
-       if (dev->transfer->subds[cmd_desc->idx_subd]->do_cmdtest != NULL)
-               ret = dev->transfer->subds[cmd_desc->idx_subd]->
-                       do_cmdtest(dev->transfer->subds[cmd_desc->idx_subd], 
+       if (dev->transfer.subds[cmd_desc->idx_subd]->do_cmdtest != NULL)
+               ret = dev->transfer.subds[cmd_desc->idx_subd]->
+                       do_cmdtest(dev->transfer.subds[cmd_desc->idx_subd], 
                                   cmd_desc);
        if (ret != 0)
                goto out_ioctl_cmd;
@@ -301,8 +301,8 @@ int comedi_ioctl_cmd(comedi_cxt_t * cxt, void *arg)
        comedi_init_transfer(cxt, cmd_desc);
 
        /* Eventually launches the command */
-       ret = dev->transfer->subds[cmd_desc->idx_subd]->
-               do_cmd(dev->transfer->subds[cmd_desc->idx_subd], 
+       ret = dev->transfer.subds[cmd_desc->idx_subd]->
+               do_cmd(dev->transfer.subds[cmd_desc->idx_subd], 
                       cmd_desc);
 
        if (ret != 0) {
diff --git a/ksrc/drivers/comedi/device.c b/ksrc/drivers/comedi/device.c
index cb413a0..05102f7 100644
--- a/ksrc/drivers/comedi/device.c
+++ b/ksrc/drivers/comedi/device.c
@@ -39,9 +39,13 @@ static comedi_dev_t comedi_devs[COMEDI_NB_DEVICES];
 void comedi_init_devs(void)
 {
        int i;
-       memset(comedi_devs, 0, COMEDI_NB_DEVICES * sizeof(comedi_dev_t));
-       for (i = 0; i < COMEDI_NB_DEVICES; i++)
+       memset(comedi_devs, 0, COMEDI_NB_DEVICES * sizeof(comedi_dev_t));       
+       for (i = 0; i < COMEDI_NB_DEVICES; i++) {               
                comedi_lock_init(&comedi_devs[i].lock);
+               comedi_devs[i].transfer.irq = COMEDI_IRQ_UNUSED;
+               comedi_devs[i].transfer.idx_read_subd = COMEDI_IDX_UNUSED;
+               comedi_devs[i].transfer.idx_write_subd = COMEDI_IDX_UNUSED;
+       }
 }
 
 int comedi_check_cleanup_devs(void)
@@ -140,7 +144,7 @@ int comedi_proc_attach(comedi_cxt_t * cxt)
        }
 
        entry->nlink = 1;
-       entry->data = dev->transfer;
+       entry->data = &dev->transfer;
        entry->write_proc = NULL;
        entry->read_proc = comedi_rdproc_transfer;
        wrap_proc_dir_entry_owner(entry);
@@ -466,9 +470,9 @@ int comedi_ioctl_devinfo(comedi_cxt_t * cxt, void *arg)
                    COMEDI_NAMELEN : strlen(dev->driver->board_name);
 
                memcpy(info.board_name, dev->driver->board_name, len);
-               info.nb_subd = dev->transfer->nb_subd;
-               info.idx_read_subd = dev->transfer->idx_read_subd;
-               info.idx_write_subd = dev->transfer->idx_write_subd;
+               info.nb_subd = dev->transfer.nb_subd;
+               info.idx_read_subd = dev->transfer.idx_read_subd;
+               info.idx_write_subd = dev->transfer.idx_write_subd;
        }
 
        if (comedi_copy_to_user(cxt, arg, &info, sizeof(comedi_dvinfo_t)) != 0)
diff --git a/ksrc/drivers/comedi/instruction.c 
b/ksrc/drivers/comedi/instruction.c
index e5c739d..987c545 100644
--- a/ksrc/drivers/comedi/instruction.c
+++ b/ksrc/drivers/comedi/instruction.c
@@ -85,10 +85,10 @@ int comedi_do_insn_trig(comedi_cxt_t * cxt, comedi_kinsn_t 
* dsc)
        if (dsc->data_size != 1)
                return -EINVAL;
 
-       if (dsc->idx_subd >= dev->transfer->nb_subd)
+       if (dsc->idx_subd >= dev->transfer.nb_subd)
                return -EINVAL;
 
-       subd = dev->transfer->subds[dsc->idx_subd];
+       subd = dev->transfer.subds[dsc->idx_subd];
 
        /* Checks that the concerned subdevice is trigger-compliant */
        if ((subd->flags & COMEDI_SUBD_CMD) == 0 || subd->trigger == NULL)
@@ -182,11 +182,11 @@ int comedi_do_insn(comedi_cxt_t * cxt, comedi_kinsn_t * 
dsc)
        comedi_dev_t *dev = comedi_get_dev(cxt);
 
        /* Checks the subdevice index */
-       if (dsc->idx_subd >= dev->transfer->nb_subd)
+       if (dsc->idx_subd >= dev->transfer.nb_subd)
                return -EINVAL;
 
        /* Recovers pointers on the proper subdevice */
-       subd = dev->transfer->subds[dsc->idx_subd];
+       subd = dev->transfer.subds[dsc->idx_subd];
 
        /* Checks the subdevice's characteristics */
        if (((subd->flags & COMEDI_SUBD_UNUSED) != 0) ||
@@ -194,7 +194,7 @@ int comedi_do_insn(comedi_cxt_t * cxt, comedi_kinsn_t * dsc)
                return -EINVAL;
 
        /* Checks the channel descriptor */
-       ret = comedi_check_chanlist(dev->transfer->subds[dsc->idx_subd],
+       ret = comedi_check_chanlist(dev->transfer.subds[dsc->idx_subd],
                                    1, &dsc->chan_desc);
        if (ret < 0)
                return ret;
diff --git a/ksrc/drivers/comedi/national_instruments/mio_common.c 
b/ksrc/drivers/comedi/national_instruments/mio_common.c
index 3173e7c..b4cab85 100644
--- a/ksrc/drivers/comedi/national_instruments/mio_common.c
+++ b/ksrc/drivers/comedi/national_instruments/mio_common.c
@@ -3577,7 +3577,7 @@ void mio_common_detach(comedi_dev_t * dev)
 
 static void init_ao_67xx(comedi_dev_t * dev)
 {
-       comedi_subd_t *subd = dev->transfer->subds[NI_AO_SUBDEV];
+       comedi_subd_t *subd = dev->transfer.subds[NI_AO_SUBDEV];
        int i;
 
        for (i = 0; i < subd->chan_desc->length; i++)
diff --git a/ksrc/drivers/comedi/subdevice.c b/ksrc/drivers/comedi/subdevice.c
index 2a4ee9e..b908dbe 100644
--- a/ksrc/drivers/comedi/subdevice.c
+++ b/ksrc/drivers/comedi/subdevice.c
@@ -181,20 +181,20 @@ int comedi_ioctl_subdinfo(comedi_cxt_t * cxt, void *arg)
                return -EINVAL;
 
        subd_info =
-           comedi_kmalloc(dev->transfer->nb_subd * sizeof(comedi_sbinfo_t));
+           comedi_kmalloc(dev->transfer.nb_subd * sizeof(comedi_sbinfo_t));
        if (subd_info == NULL)
                return -ENOMEM;
 
-       for (i = 0; i < dev->transfer->nb_subd; i++) {
-               subd_info[i].flags = dev->transfer->subds[i]->flags;
-               subd_info[i].status = dev->transfer->status[i];
+       for (i = 0; i < dev->transfer.nb_subd; i++) {
+               subd_info[i].flags = dev->transfer.subds[i]->flags;
+               subd_info[i].status = dev->transfer.status[i];
                subd_info[i].nb_chan =
-                   dev->transfer->subds[i]->chan_desc->length;
+                   dev->transfer.subds[i]->chan_desc->length;
        }
 
        if (comedi_copy_to_user(cxt,
                                arg,
-                               subd_info, dev->transfer->nb_subd *
+                               subd_info, dev->transfer.nb_subd *
                                sizeof(comedi_sbinfo_t)) != 0)
                ret = -EFAULT;
 
@@ -218,11 +218,11 @@ int comedi_ioctl_nbchaninfo(comedi_cxt_t * cxt, void *arg)
                                  sizeof(comedi_chinfo_arg_t)) != 0)
                return -EFAULT;
 
-       if (inarg.idx_subd >= dev->transfer->nb_subd)
+       if (inarg.idx_subd >= dev->transfer.nb_subd)
                return -EINVAL;
 
        inarg.info =
-           (void *)(unsigned long)dev->transfer->subds[inarg.idx_subd]->
+           (void *)(unsigned long)dev->transfer.subds[inarg.idx_subd]->
            chan_desc->length;
 
        if (comedi_copy_to_user(cxt,
@@ -250,11 +250,11 @@ int comedi_ioctl_chaninfo(comedi_cxt_t * cxt, void *arg)
                                  sizeof(comedi_chinfo_arg_t)) != 0)
                return -EFAULT;
 
-       if (inarg.idx_subd >= dev->transfer->nb_subd)
+       if (inarg.idx_subd >= dev->transfer.nb_subd)
                return -EINVAL;
 
-       chan_desc = dev->transfer->subds[inarg.idx_subd]->chan_desc;
-       rng_desc = dev->transfer->subds[inarg.idx_subd]->rng_desc;
+       chan_desc = dev->transfer.subds[inarg.idx_subd]->chan_desc;
+       rng_desc = dev->transfer.subds[inarg.idx_subd]->rng_desc;
 
        chan_info = comedi_kmalloc(chan_desc->length * sizeof(comedi_chinfo_t));
        if (chan_info == NULL)
@@ -304,10 +304,10 @@ int comedi_ioctl_nbrnginfo(comedi_cxt_t * cxt, void *arg)
                return -EFAULT;
 
        if (inarg.idx_chan >=
-           dev->transfer->subds[inarg.idx_subd]->chan_desc->length)
+           dev->transfer.subds[inarg.idx_subd]->chan_desc->length)
                return -EINVAL;
 
-       rng_desc = dev->transfer->subds[inarg.idx_subd]->rng_desc;
+       rng_desc = dev->transfer.subds[inarg.idx_subd]->rng_desc;
        i = (rng_desc->mode != COMEDI_RNG_GLOBAL_RNGDESC) ? inarg.idx_chan : 0;
        inarg.info = (void *)(unsigned long)rng_desc->rngtabs[i]->length;
 
@@ -336,16 +336,16 @@ int comedi_ioctl_rnginfo(comedi_cxt_t * cxt, void *arg)
                                  arg, sizeof(comedi_rnginfo_arg_t)) != 0)
                return -EFAULT;
 
-       if (inarg.idx_subd >= dev->transfer->nb_subd)
+       if (inarg.idx_subd >= dev->transfer.nb_subd)
                return -EINVAL;
 
        if (inarg.idx_chan >=
-           dev->transfer->subds[inarg.idx_subd]->chan_desc->length)
+           dev->transfer.subds[inarg.idx_subd]->chan_desc->length)
                return -EINVAL;
 
        /* If the range descriptor is global, 
           we take the first instance */
-       rng_desc = dev->transfer->subds[inarg.idx_subd]->rng_desc;
+       rng_desc = dev->transfer.subds[inarg.idx_subd]->rng_desc;
        tmp = (rng_desc->mode != COMEDI_RNG_GLOBAL_RNGDESC) ?
            inarg.idx_chan : 0;
 
diff --git a/ksrc/drivers/comedi/transfer.c b/ksrc/drivers/comedi/transfer.c
index c0d7faf..d1bcc8e 100644
--- a/ksrc/drivers/comedi/transfer.c
+++ b/ksrc/drivers/comedi/transfer.c
@@ -43,7 +43,7 @@ int comedi_cleanup_transfer(comedi_cxt_t * cxt)
                       comedi_get_minor(cxt));
 
        dev = comedi_get_dev(cxt);
-       tsf = dev->transfer;
+       tsf = &dev->transfer;
 
        if (tsf == NULL)
                return -ENODEV;
@@ -76,9 +76,6 @@ int comedi_cleanup_transfer(comedi_cxt_t * cxt)
                comedi_kfree(tsf->subds);
        }
 
-       comedi_kfree(tsf);
-       dev->transfer = NULL;
-
        return 0;
 }
 
@@ -94,13 +91,9 @@ int comedi_setup_transfer(comedi_cxt_t * cxt)
                       comedi_get_minor(cxt));
 
        dev = comedi_get_dev(cxt);
+       tsf = &dev->transfer;
 
-       /* Allocates the main structure */
-       tsf = comedi_kmalloc(sizeof(comedi_trf_t));
-       if (tsf == NULL) {
-               __comedi_err("comedi_setup_transfer: call1(alloc) failed \n");
-               return -ENOMEM;
-       }
+       /* Clear the structure */
        memset(tsf, 0, sizeof(comedi_trf_t));
 
        /* We consider 0 can be valid index */
@@ -111,8 +104,6 @@ int comedi_setup_transfer(comedi_cxt_t * cxt)
           the IRQ number must be initialized with another value */
        tsf->irq_desc.irq = COMEDI_IRQ_UNUSED;
 
-       dev->transfer = tsf;
-
        /* Recovers the subdevices count 
           (as they are registered in a linked list */
        list_for_each(this, &dev->subdvsq) {
@@ -190,7 +181,7 @@ int comedi_reserve_transfer(comedi_cxt_t * cxt, int 
idx_subd)
                       comedi_get_minor(cxt), idx_subd);
 
        if (test_and_set_bit(COMEDI_TSF_BUSY,
-                            &(dev->transfer->status[idx_subd])))
+                            &(dev->transfer.status[idx_subd])))
                return -EBUSY;
 
        return 0;
@@ -207,31 +198,31 @@ int comedi_init_transfer(comedi_cxt_t * cxt, comedi_cmd_t 
* cmd)
        /* Checks if the transfer system has to work in bulk mode */
        if (cmd->flags & COMEDI_CMD_BULK)
                set_bit(COMEDI_TSF_BULK,
-                       &(dev->transfer->status[cmd->idx_subd]));
+                       &(dev->transfer.status[cmd->idx_subd]));
 
        /* Sets the working command */
-       dev->transfer->bufs[cmd->idx_subd]->cur_cmd = cmd;
+       dev->transfer.bufs[cmd->idx_subd]->cur_cmd = cmd;
 
        /* Initializes the counts and the flag variable */
-       dev->transfer->bufs[cmd->idx_subd]->end_count = 0;
-       dev->transfer->bufs[cmd->idx_subd]->prd_count = 0;
-       dev->transfer->bufs[cmd->idx_subd]->cns_count = 0;
-       dev->transfer->bufs[cmd->idx_subd]->tmp_count = 0;
-       dev->transfer->bufs[cmd->idx_subd]->evt_flags = 0;
-       dev->transfer->bufs[cmd->idx_subd]->mng_count = 0;
+       dev->transfer.bufs[cmd->idx_subd]->end_count = 0;
+       dev->transfer.bufs[cmd->idx_subd]->prd_count = 0;
+       dev->transfer.bufs[cmd->idx_subd]->cns_count = 0;
+       dev->transfer.bufs[cmd->idx_subd]->tmp_count = 0;
+       dev->transfer.bufs[cmd->idx_subd]->evt_flags = 0;
+       dev->transfer.bufs[cmd->idx_subd]->mng_count = 0;
 
        /* Computes the count to reach, if need be */
        if (cmd->stop_src == TRIG_COUNT) {
                for (i = 0; i < cmd->nb_chan; i++) {
                        comedi_chan_t *chft;
                        chft =
-                           comedi_get_chfeat(dev->transfer->
+                           comedi_get_chfeat(dev->transfer.
                                              subds[cmd->idx_subd],
                                              CR_CHAN(cmd->chan_descs[i]));
-                       dev->transfer->bufs[cmd->idx_subd]->end_count +=
+                       dev->transfer.bufs[cmd->idx_subd]->end_count +=
                            chft->nb_bits / 8;
                }
-               dev->transfer->bufs[cmd->idx_subd]->end_count *= cmd->stop_arg;
+               dev->transfer.bufs[cmd->idx_subd]->end_count *= cmd->stop_arg;
        }
 
        /* Always returning 0 is here useless... for the moment */
@@ -245,11 +236,11 @@ int comedi_cancel_transfer(comedi_cxt_t * cxt, int 
idx_subd)
        comedi_dev_t *dev = comedi_get_dev(cxt);
 
        /* Basic checking */
-       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer->status[idx_subd])))
+       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer.status[idx_subd])))
                return 0;
 
        /* Retrieves the proper subdevice pointer */
-       subd = dev->transfer->subds[idx_subd];
+       subd = dev->transfer.subds[idx_subd];
 
        /* If a "cancel" function is registered, call it
           (Note: this function is called before having checked 
@@ -263,20 +254,20 @@ int comedi_cancel_transfer(comedi_cxt_t * cxt, int 
idx_subd)
        }
 
        /* Clears the "busy" flag */
-       clear_bit(COMEDI_TSF_BUSY, &(dev->transfer->status[idx_subd]));
+       clear_bit(COMEDI_TSF_BUSY, &(dev->transfer.status[idx_subd]));
 
        /* If the subdevice is command capable and 
           if there is a command is under progress, 
           disable it and free it... */
-       if (dev->transfer->bufs != NULL &&
-           dev->transfer->bufs[idx_subd]->cur_cmd != NULL) {
+       if (dev->transfer.bufs != NULL &&
+           dev->transfer.bufs[idx_subd]->cur_cmd != NULL) {
 
-               comedi_free_cmddesc(dev->transfer->bufs[idx_subd]->cur_cmd);
-               comedi_kfree(dev->transfer->bufs[idx_subd]->cur_cmd);
-               dev->transfer->bufs[idx_subd]->cur_cmd = NULL;
+               comedi_free_cmddesc(dev->transfer.bufs[idx_subd]->cur_cmd);
+               comedi_kfree(dev->transfer.bufs[idx_subd]->cur_cmd);
+               dev->transfer.bufs[idx_subd]->cur_cmd = NULL;
 
                /* ...we must also clean the events flags */
-               dev->transfer->bufs[idx_subd]->evt_flags = 0;
+               dev->transfer.bufs[idx_subd]->evt_flags = 0;
        }
 
        return ret;
@@ -292,7 +283,7 @@ int comedi_request_irq(comedi_dev_t * dev,
        int ret;
        unsigned long __flags;
 
-       if (dev->transfer->irq_desc.irq != COMEDI_IRQ_UNUSED)
+       if (dev->transfer.irq_desc.irq != COMEDI_IRQ_UNUSED)
                return -EBUSY;
 
        /* A spinlock is used so as to prevent race conditions 
@@ -300,11 +291,11 @@ int comedi_request_irq(comedi_dev_t * dev,
           (even if such a case is bound not to happen) */
        comedi_lock_irqsave(&dev->lock, __flags);
 
-       ret = __comedi_request_irq(&dev->transfer->irq_desc,
+       ret = __comedi_request_irq(&dev->transfer.irq_desc,
                                   irq, handler, flags, cookie);
 
        if (ret != 0)
-               dev->transfer->irq_desc.irq = COMEDI_IRQ_UNUSED;
+               dev->transfer.irq_desc.irq = COMEDI_IRQ_UNUSED;
 
        comedi_unlock_irqrestore(&dev->lock, __flags);
 
@@ -316,22 +307,22 @@ int comedi_free_irq(comedi_dev_t * dev, unsigned int irq)
 
        int ret = 0;
 
-       if (dev->transfer->irq_desc.irq != irq)
+       if (dev->transfer.irq_desc.irq != irq)
                return -EINVAL;
 
        /* There is less need to use a spinlock 
           than for comedi_request_irq() */
-       ret = __comedi_free_irq(&dev->transfer->irq_desc);
+       ret = __comedi_free_irq(&dev->transfer.irq_desc);
 
        if (ret == 0)
-               dev->transfer->irq_desc.irq = COMEDI_IRQ_UNUSED;
+               dev->transfer.irq_desc.irq = COMEDI_IRQ_UNUSED;
 
        return 0;
 }
 
 unsigned int comedi_get_irq(comedi_dev_t * dev)
 {
-       return dev->transfer->irq_desc.irq;
+       return dev->transfer.irq_desc.irq;
 }
 
 /* --- Proc section --- */
@@ -426,18 +417,18 @@ int comedi_ioctl_cancel(comedi_cxt_t * cxt, void *arg)
        comedi_dev_t *dev = comedi_get_dev(cxt);
        comedi_subd_t *subd;
 
-       if (idx_subd >= dev->transfer->nb_subd)
+       if (idx_subd >= dev->transfer.nb_subd)
                return -EINVAL;
 
-       if (dev->transfer->subds[idx_subd]->flags & COMEDI_SUBD_UNUSED)
+       if (dev->transfer.subds[idx_subd]->flags & COMEDI_SUBD_UNUSED)
                return -EIO;
 
-       if (!(dev->transfer->subds[idx_subd]->flags & COMEDI_SUBD_CMD))
+       if (!(dev->transfer.subds[idx_subd]->flags & COMEDI_SUBD_CMD))
                return -EIO;
 
-       subd = dev->transfer->subds[idx_subd];
+       subd = dev->transfer.subds[idx_subd];
 
-       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer->status[idx_subd])))
+       if (!test_bit(COMEDI_TSF_BUSY, &(dev->transfer.status[idx_subd])))
                return -EINVAL;
 
        return comedi_cancel_transfer(cxt, idx_subd);


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to