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

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Sat May 23 05:21:19 2009 +0200

Apply driver API change on testing drivers

---

 ksrc/drivers/comedi/testing/fake.c |   38 ++++++++++++---------------
 ksrc/drivers/comedi/testing/loop.c |   50 ++++++++++++++++--------------------
 2 files changed, 39 insertions(+), 49 deletions(-)

diff --git a/ksrc/drivers/comedi/testing/fake.c 
b/ksrc/drivers/comedi/testing/fake.c
index deba011..4aef348 100644
--- a/ksrc/drivers/comedi/testing/fake.c
+++ b/ksrc/drivers/comedi/testing/fake.c
@@ -147,11 +147,11 @@ static void test_task_proc(void *arg)
 /* --- Comedi Callbacks --- */
 
 /* Command callback */
-int test_cmd(comedi_cxt_t *cxt, int idx_subd)
+int test_cmd(comedi_subd_t *subd, int idx_subd)
 {
-       comedi_dev_t *dev=comedi_get_dev(cxt);
-       comedi_cmd_t *cmd=comedi_get_cmd(dev, 0, idx_subd);
-       tstprv_t *priv=(tstprv_t *)dev->priv;
+       comedi_dev_t *dev = subd->dev;
+       comedi_cmd_t *cmd = comedi_get_cmd(dev, 0, idx_subd);
+       tstprv_t *priv = (tstprv_t *)dev->priv;
 
        comedi_loginfo("test_cmd: begin (subd=%d)\n",idx_subd);
   
@@ -174,15 +174,15 @@ int test_cmd(comedi_cxt_t *cxt, int idx_subd)
 }
 
 /* Test command callback */
-int test_cmdtest(comedi_cxt_t *cxt, comedi_cmd_t *cmd)
+int test_cmdtest(comedi_subd_t *subd, comedi_cmd_t *cmd)
 {
-       if(cmd->scan_begin_src==TRIG_TIMER)
+       if(cmd->scan_begin_src == TRIG_TIMER)
        {
-               if(cmd->scan_begin_arg < 1000)
+               if (cmd->scan_begin_arg < 1000)
                        return -EINVAL;
 
-               if(cmd->convert_src==TRIG_TIMER &&
-                  cmd->scan_begin_arg<(cmd->convert_arg*cmd->nb_chan))
+               if (cmd->convert_src == TRIG_TIMER &&
+                  cmd->scan_begin_arg < (cmd->convert_arg * cmd->nb_chan))
                        return -EINVAL;
        }
 
@@ -190,10 +190,9 @@ int test_cmdtest(comedi_cxt_t *cxt, comedi_cmd_t *cmd)
 }
 
 /* Cancel callback */
-int test_cancel(comedi_cxt_t *cxt, int idx_subd)
+int test_cancel(comedi_subd_t *subd, int idx_subd)
 {
-       comedi_dev_t *dev = comedi_get_dev(cxt);
-       tstprv_t *priv = (tstprv_t *)dev->priv;
+       tstprv_t *priv = (tstprv_t *)subd->dev->priv;
 
        priv->timer_running = 0;
 
@@ -201,10 +200,9 @@ int test_cancel(comedi_cxt_t *cxt, int idx_subd)
 }
 
 /* Read instruction callback */
-int test_ai_insn_read(comedi_cxt_t *cxt, comedi_kinsn_t *insn)
+int test_ai_insn_read(comedi_subd_t *subd, comedi_kinsn_t *insn)
 {
-       comedi_dev_t *dev = comedi_get_dev(cxt);
-       tstprv_t *priv = (tstprv_t *)dev->priv;
+       tstprv_t *priv = (tstprv_t *)subd->dev->priv;
        int i;
 
        for(i = 0; i < insn->data_size / sizeof(sampl_t); i++)
@@ -214,7 +212,7 @@ int test_ai_insn_read(comedi_cxt_t *cxt, comedi_kinsn_t 
*insn)
 }
 
 /* Munge callback */
-void test_ai_munge(comedi_cxt_t *cxt, 
+void test_ai_munge(comedi_dev_t *dev, 
                   int idx_subd, void *buf, unsigned long size)
 {
        int i;
@@ -234,7 +232,7 @@ void setup_test_subd(comedi_subd_t *subd)
        subd->flags |= COMEDI_SUBD_MMAP;
        subd->rng_desc = &test_rngdesc;
        subd->chan_desc = &test_chandesc;
-       subd->do_cmd=test_cmd;
+       subd->do_cmd = test_cmd;
        subd->do_cmdtest = test_cmdtest;
        subd->cancel = test_cancel;
        subd->munge = test_ai_munge;
@@ -243,12 +241,11 @@ void setup_test_subd(comedi_subd_t *subd)
 }
 
 /* Attach callback */
-int test_attach(comedi_cxt_t *cxt,
+int test_attach(comedi_dev_t *dev,
                comedi_lnkdesc_t *arg)
 {
        int ret = 0;  
        comedi_subd_t *subd;
-       comedi_dev_t *dev = comedi_get_dev(cxt);
        tstprv_t *priv = (tstprv_t *)dev->priv;
 
        if(arg->opts!=NULL) {
@@ -284,9 +281,8 @@ int test_attach(comedi_cxt_t *cxt,
 }
 
 /* Detach callback */
-int test_detach(comedi_cxt_t *cxt)
+int test_detach(comedi_dev_t *dev)
 {
-       comedi_dev_t *dev = comedi_get_dev(cxt);
        tstprv_t *priv = (tstprv_t *)dev->priv;
 
        comedi_task_destroy(&priv->timer_task);
diff --git a/ksrc/drivers/comedi/testing/loop.c 
b/ksrc/drivers/comedi/testing/loop.c
index 892d075..264338e 100644
--- a/ksrc/drivers/comedi/testing/loop.c
+++ b/ksrc/drivers/comedi/testing/loop.c
@@ -62,21 +62,21 @@ static void loop_task_proc(void *arg)
        comedi_dev_t *dev = (comedi_dev_t*)arg;
        lpprv_t *priv = (lpprv_t *)dev->priv;
     
-       while(!comedi_check_dev(dev))
+       while (!comedi_check_dev(dev))
                comedi_task_sleep(LOOP_TASK_PERIOD);
 
-       while(1) {
+       while (1) {
        
-               if(priv->loop_running) {
+               if (priv->loop_running) {
                        sampl_t value;
                        int ret=0;
            
-                       while(ret==0) {
+                       while (ret==0) {
                
                                ret = comedi_buf_get(dev, 
                                                     &value, sizeof(sampl_t));
 
-                               if(ret == 0) {
+                               if (ret == 0) {
 
                                        comedi_loginfo("loop_task_proc: "
                                                       "data available\n");
@@ -87,7 +87,7 @@ static void loop_task_proc(void *arg)
                                                           &value, 
                                                           sizeof(sampl_t));
 
-                                       if(ret==0)
+                                       if (ret==0)
                                                comedi_buf_evt(dev, 
                                                               COMEDI_BUF_PUT, 
                                                               0);
@@ -102,10 +102,9 @@ static void loop_task_proc(void *arg)
 /* --- Comedi Callbacks --- */
 
 /* Command callback */
-int loop_cmd(comedi_cxt_t *cxt, int idx_subd)
+int loop_cmd(comedi_subd_t *subd, int idx_subd)
 {
-       comedi_dev_t *dev=comedi_get_dev(cxt);
-       lpprv_t *priv=(lpprv_t *)dev->priv;
+       lpprv_t *priv = (lpprv_t *)subd->dev->priv;
 
        comedi_loginfo("loop_cmd: (subd=%d)\n",idx_subd);
 
@@ -116,10 +115,9 @@ int loop_cmd(comedi_cxt_t *cxt, int idx_subd)
 }
 
 /* Cancel callback */
-int loop_cancel(comedi_cxt_t *cxt, int idx_subd)
+int loop_cancel(comedi_subd_t *subd, int idx_subd)
 {
-       comedi_dev_t *dev=comedi_get_dev(cxt);
-       lpprv_t *priv=(lpprv_t *)dev->priv;
+       lpprv_t *priv=(lpprv_t *)subd->dev->priv;
 
        comedi_loginfo("loop_cancel: (subd=%d)\n",idx_subd);
 
@@ -129,13 +127,12 @@ int loop_cancel(comedi_cxt_t *cxt, int idx_subd)
 }
 
 /* Read instruction callback */
-int loop_insn_read(comedi_cxt_t *cxt, comedi_kinsn_t *insn)
+int loop_insn_read(comedi_subd_t *subd, comedi_kinsn_t *insn)
 {
-       comedi_dev_t *dev = comedi_get_dev(cxt);
-       lpprv_t *priv = (lpprv_t*)dev->priv;
+       lpprv_t *priv = (lpprv_t*)subd->dev->priv;
 
        /* Checks the buffer size */
-       if(insn->data_size!=sizeof(sampl_t))
+       if (insn->data_size!=sizeof(sampl_t))
                return -EINVAL;
 
        /* Sets the memorized value */
@@ -145,13 +142,12 @@ int loop_insn_read(comedi_cxt_t *cxt, comedi_kinsn_t 
*insn)
 }
 
 /* Write instruction callback */
-int loop_insn_write(comedi_cxt_t *cxt, comedi_kinsn_t *insn)
+int loop_insn_write(comedi_subd_t *subd, comedi_kinsn_t *insn)
 {
-       comedi_dev_t *dev = comedi_get_dev(cxt);
-       lpprv_t *priv = (lpprv_t*)dev->priv;
+       lpprv_t *priv = (lpprv_t*)subd->dev->priv;
 
        /* Checks the buffer size */
-       if(insn->data_size!=sizeof(sampl_t))
+       if (insn->data_size!=sizeof(sampl_t))
                return -EINVAL;
 
        /* Retrieves the value to memorize */
@@ -189,32 +185,31 @@ void setup_output_subd(comedi_subd_t *subd)
 }
 
 /* Attach callback */
-int loop_attach(comedi_cxt_t *cxt,
+int loop_attach(comedi_dev_t *dev,
                comedi_lnkdesc_t *arg)
 {
        int ret = 0;
        comedi_subd_t *subd;
-       comedi_dev_t *dev = comedi_get_dev(cxt);
        lpprv_t *priv = (lpprv_t *)dev->priv;
 
        /* Add the fake input subdevice */
        subd = comedi_alloc_subd(0, setup_input_subd); 
-       if(subd == NULL)
+       if (subd == NULL)
                return -ENOMEM;  
 
        ret = comedi_add_subd(dev, subd);
-       if(ret < 0)
+       if (ret < 0)
                /* Let Comedi free the lately allocated subdevice */
                return ret;
 
        /* Add the fake output subdevice */
        subd = comedi_alloc_subd(0, setup_output_subd); 
-       if(subd == NULL)
+       if (subd == NULL)
                /* Let Comedi free the lately allocated subdevice */
                return -ENOMEM;  
 
        ret = comedi_add_subd(dev, subd);
-       if(ret < 0)
+       if (ret < 0)
                /* Let Comedi free the lately allocated subdevices */
                return ret;
 
@@ -230,9 +225,8 @@ int loop_attach(comedi_cxt_t *cxt,
 }
 
 /* Detach callback */
-int loop_detach(comedi_cxt_t *cxt)
+int loop_detach(comedi_dev_t *dev)
 {
-       comedi_dev_t *dev = comedi_get_dev(cxt);
        lpprv_t *priv = (lpprv_t *)dev->priv;
 
        comedi_task_destroy(&priv->loop_task);


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

Reply via email to