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

Author: Alexis Berlemont <berlemont.h...@free.fr>
Date:   Sun Jun 14 22:41:16 2009 +0200

Review comedi_get_cmd's arguments: the subdevice descriptor should be
enough.

---

 include/comedi/buffer.h                            |    3 +--
 ksrc/drivers/comedi/buffer.c                       |   20 +++-----------------
 ksrc/drivers/comedi/driver_facilities.c            |   13 ++-----------
 .../comedi/national_instruments/mio_common.c       |    6 +++---
 ksrc/drivers/comedi/subdevice.c                    |    2 +-
 ksrc/drivers/comedi/testing/fake.c                 |    3 ++-
 6 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/include/comedi/buffer.h b/include/comedi/buffer.h
index 3874f3e..1044aeb 100644
--- a/include/comedi/buffer.h
+++ b/include/comedi/buffer.h
@@ -332,8 +332,7 @@ unsigned long comedi_buf_count(struct comedi_device *dev, 
unsigned int type);
 
 /* --- Current Command management function --- */
 
-comedi_cmd_t *comedi_get_cmd(struct comedi_device *dev, unsigned int type,
-                            int idx_subd);
+comedi_cmd_t *comedi_get_cmd(struct comedi_subdevice *subd);
 
 /* --- Munge related function --- */
 
diff --git a/ksrc/drivers/comedi/buffer.c b/ksrc/drivers/comedi/buffer.c
index 98b12c5..07e983e 100644
--- a/ksrc/drivers/comedi/buffer.c
+++ b/ksrc/drivers/comedi/buffer.c
@@ -96,24 +96,10 @@ int comedi_alloc_buffer(comedi_buf_t * buf_desc)
 
 /* --- Current Command management function --- */
 
-comedi_cmd_t *comedi_get_cmd(comedi_dev_t * dev,
-                            unsigned int type, int idx_subd)
+comedi_cmd_t *comedi_get_cmd(comedi_subd_t *subd)
 {
-       int idx;
-
-       /* 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;
-
-       if (dev->transfer.bufs != NULL)
-               return dev->transfer.bufs[idx]->cur_cmd;
-       else
-               return NULL;
+       comedi_dev_t *dev = subd->dev;
+       return dev->transfer.bufs[subd->idx]->cur_cmd;
 }
 
 /* --- Munge related function --- */
diff --git a/ksrc/drivers/comedi/driver_facilities.c 
b/ksrc/drivers/comedi/driver_facilities.c
index 1e42c12..0702a37 100644
--- a/ksrc/drivers/comedi/driver_facilities.c
+++ b/ksrc/drivers/comedi/driver_facilities.c
@@ -500,21 +500,12 @@ EXPORT_SYMBOL(comedi_buf_count);
 /**
  * @brief Get the current Comedi command descriptor
  *
- * @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 command descriptor.
  *
  */
-comedi_cmd_t *comedi_get_cmd(comedi_dev_t * dev,
-                            unsigned int type, int idx_subd);
+comedi_cmd_t *comedi_get_cmd(comedi_subd_t * subd);
 EXPORT_SYMBOL(comedi_get_cmd);
 
 
diff --git a/ksrc/drivers/comedi/national_instruments/mio_common.c 
b/ksrc/drivers/comedi/national_instruments/mio_common.c
index c97e4b6..5f3131b 100644
--- a/ksrc/drivers/comedi/national_instruments/mio_common.c
+++ b/ksrc/drivers/comedi/national_instruments/mio_common.c
@@ -1282,7 +1282,7 @@ static void get_last_sample_6143(comedi_dev_t *dev)
 static void ni_ai_munge16(comedi_subd_t *subd, void *buf, unsigned long size)
 {
        comedi_dev_t *dev = subd->dev;
-       comedi_cmd_t *cmd = comedi_get_cmd(dev, 0, subd->idx);
+       comedi_cmd_t *cmd = comedi_get_cmd(subd);
        int chan_idx = comedi_get_chan(subd);
        unsigned int i;
        sampl_t *array = buf;
@@ -1300,7 +1300,7 @@ static void ni_ai_munge16(comedi_subd_t *subd, void *buf, 
unsigned long size)
 static void ni_ai_munge32(comedi_subd_t *subd, void *buf, unsigned long size)
 {
        comedi_dev_t *dev = subd->dev;
-       comedi_cmd_t *cmd = comedi_get_cmd(dev, 0, subd->idx);
+       comedi_cmd_t *cmd = comedi_get_cmd(subd);
        int chan_idx = comedi_get_chan(subd);
        unsigned int i;
        lsampl_t *larray = buf;
@@ -2497,7 +2497,7 @@ int ni_ai_insn_config(comedi_subd_t *subd, comedi_kinsn_t 
*insn)
 static void ni_ao_munge(comedi_subd_t *subd, void *buf, unsigned long size)
 {
        comedi_dev_t *dev = subd->dev;
-       comedi_cmd_t *cmd = comedi_get_cmd(dev, 0, subd->idx);
+       comedi_cmd_t *cmd = comedi_get_cmd(subd);
        int chan_idx = comedi_get_chan(subd);
        sampl_t *array = buf;
        unsigned int i, range, offset;
diff --git a/ksrc/drivers/comedi/subdevice.c b/ksrc/drivers/comedi/subdevice.c
index b908dbe..3705d28 100644
--- a/ksrc/drivers/comedi/subdevice.c
+++ b/ksrc/drivers/comedi/subdevice.c
@@ -162,7 +162,7 @@ comedi_subd_t *comedi_get_subd(comedi_dev_t *dev, int idx)
 
        list_for_each(this, &dev->subdvsq) {
                if(idx == i++)
-                       subd = list_entry(this, comedi_subd_t, list);           
+                       subd = list_entry(this, comedi_subd_t, list);
        }
 
        return subd;
diff --git a/ksrc/drivers/comedi/testing/fake.c 
b/ksrc/drivers/comedi/testing/fake.c
index 9c936be..05e1900 100644
--- a/ksrc/drivers/comedi/testing/fake.c
+++ b/ksrc/drivers/comedi/testing/fake.c
@@ -98,6 +98,7 @@ static sampl_t test_output(tstprv_t *priv)
 static void test_task_proc(void *arg)
 {
        comedi_dev_t *dev = (comedi_dev_t*)arg;
+       comedi_subd_t *subd = comedi_get_subd(dev, 0);
        tstprv_t *priv = (tstprv_t *)dev->priv;
        comedi_cmd_t *cmd = NULL;
        u64 now_ns, elapsed_ns=0;
@@ -110,7 +111,7 @@ static void test_task_proc(void *arg)
                {
                        int i = 0;
 
-                       cmd = comedi_get_cmd(dev, COMEDI_BUF_PUT, 0);    
+                       cmd = comedi_get_cmd(subd);    
 
                        now_ns = comedi_get_time();
                        elapsed_ns += now_ns - priv->last_ns + 
priv->reminder_ns;


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

Reply via email to