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

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Sun May 24 23:38:27 2009 +0200

Simplify the declaration of comedi_get_chan

---

 include/comedi/buffer.h                 |    3 ++-
 ksrc/drivers/comedi/buffer.c            |   29 ++++++++++-------------------
 ksrc/drivers/comedi/driver_facilities.c |   12 ++----------
 3 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/include/comedi/buffer.h b/include/comedi/buffer.h
index bac22b3..3339a64 100644
--- a/include/comedi/buffer.h
+++ b/include/comedi/buffer.h
@@ -48,6 +48,7 @@
 #define COMEDI_BUF_EOA (1 << COMEDI_BUF_EOA_NR)
 
 struct comedi_device;
+struct comedi_subdevice;
 
 /* Buffer descriptor structure */
 struct comedi_buffer {
@@ -336,7 +337,7 @@ comedi_cmd_t *comedi_get_cmd(struct comedi_device *dev, 
unsigned int type,
 
 /* --- Munge related function --- */
 
-int comedi_get_chan(struct comedi_device *dev, unsigned int type, int 
idx_subd);
+int comedi_get_chan(struct comedi_subdevice *subd);
 
 /* --- IOCTL / FOPS functions --- */
 
diff --git a/ksrc/drivers/comedi/buffer.c b/ksrc/drivers/comedi/buffer.c
index 3377af2..7624362 100644
--- a/ksrc/drivers/comedi/buffer.c
+++ b/ksrc/drivers/comedi/buffer.c
@@ -118,31 +118,22 @@ comedi_cmd_t *comedi_get_cmd(comedi_dev_t * dev,
 
 /* --- Munge related function --- */
 
-int comedi_get_chan(comedi_dev_t * dev, unsigned int type, int idx_subd)
+int comedi_get_chan(comedi_subd_t *subd)
 {
-       int idx, i;
-       int tmp_count, tmp_size = 0;
+       comedi_dev_t *dev = subd->dev;
+       int i, tmp_count, tmp_size = 0; 
        comedi_cmd_t *cmd;
 
-       /* 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;
-       else if (type == COMEDI_BUF_GET)
-               idx = dev->transfer->idx_write_subd;
-       else
-               idx = idx_subd;
-
        /* Check that subdevice supports commands */
        if (dev->transfer->bufs == NULL)
                return -EINVAL;
 
        /* Check a command is executed */
-       if (dev->transfer->bufs[idx]->cur_cmd == NULL)
+       if (dev->transfer->bufs[subd->idx]->cur_cmd == NULL)
                return -EINVAL;
 
        /* Retrieve the proper command descriptor */
-       cmd = dev->transfer->bufs[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 */
@@ -151,13 +142,13 @@ int comedi_get_chan(comedi_dev_t * dev, unsigned int 
type, int idx_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[idx]->chan_desc->
-                   chans[CR_CHAN(cmd->chan_descs[i])].nb_bits;
+               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[idx]->mng_count % tmp_size;
+       tmp_count = dev->transfer->bufs[subd->idx]->mng_count % tmp_size;
 
        /* Translation bytes -> bits */
        tmp_count *= 8;
@@ -165,8 +156,8 @@ int comedi_get_chan(comedi_dev_t * dev, unsigned int type, 
int idx_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[idx]->chan_desc->
-                   chans[CR_CHAN(cmd->chan_descs[i])].nb_bits;
+               tmp_count -= dev->transfer->subds[subd->idx]->chan_desc->
+                       chans[CR_CHAN(cmd->chan_descs[i])].nb_bits;
 
        if (tmp_count == 0)
                return i;
diff --git a/ksrc/drivers/comedi/driver_facilities.c 
b/ksrc/drivers/comedi/driver_facilities.c
index 260c909..b8ad1c0 100644
--- a/ksrc/drivers/comedi/driver_facilities.c
+++ b/ksrc/drivers/comedi/driver_facilities.c
@@ -514,20 +514,12 @@ EXPORT_SYMBOL(comedi_get_cmd);
 /**
  * @brief Get the channel index according to its type
  *
- * @param[in] dev Device descriptor structure
- * @param[in] type Buffer transfer type:
- * - COMEDI_BUF_PUT for device -> Comedi buffer -> user-process
- *   transfer.
- * - COMEDI_BUF_GET for user-process -> Comedi_buffer -> device
- *   transfer.
- * @param[in] idx_subd Subdevice key index; this argument is optional:
- * if the "type" is not correct, the last argument is used to select
- * the proper subdevice.
+ * @param[in] subd Subdevice descriptor structure
  *
  * @return the channel index.
  *
  */
-int comedi_get_chan(struct comedi_device *dev, unsigned int type, int 
idx_subd);
+int comedi_get_chan(struct comedi_subdevice *subd);
 EXPORT_SYMBOL(comedi_get_chan);
 
 /** @} */


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

Reply via email to