Module: xenomai-abe
Branch: analogy
Commit: 99a8b1a36361ca433d33d6d465cfb12ada674d32
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=99a8b1a36361ca433d33d6d465cfb12ada674d32

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Mon May 17 23:31:20 2010 +0200

analogy: replace transfer setup functions with buffer setup ones (broken)

---

 ksrc/drivers/analogy/buffer.c      |    3 +
 ksrc/drivers/analogy/command.c     |   19 +++----
 ksrc/drivers/analogy/instruction.c |    2 +-
 ksrc/drivers/analogy/transfer.c    |   98 +++--------------------------------
 4 files changed, 22 insertions(+), 100 deletions(-)

diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c
index a27a1d6..92f1f4e 100644
--- a/ksrc/drivers/analogy/buffer.c
+++ b/ksrc/drivers/analogy/buffer.c
@@ -145,6 +145,9 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd)
                }
                buf_desc->end_count *= cmd->stop_arg;
        }
+
+       __a4l_dbg(1, core_dbg,
+                 "a4l_setup_buffer: end_count=%lu\n", buf_desc->end_count);
        
        return 0;
 }
diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c
index a6c1dec..b300d9a 100644
--- a/ksrc/drivers/analogy/command.c
+++ b/ksrc/drivers/analogy/command.c
@@ -299,7 +299,8 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg)
 {
        int ret = 0, simul_flag = 0;
        a4l_cmd_t *cmd_desc = NULL;
-       a4l_dev_t *dev = a4l_get_dev(cxt);
+       a4l_subd_t *subd;
+       a4l_dev_t *dev = a4l_get_dev(cxt);      
 
        __a4l_dbg(1, core_dbg, 
                  "a4l_ioctl_cmd: minor=%d\n", a4l_get_minor(cxt));
@@ -344,11 +345,11 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg)
        __a4l_dbg(1, core_dbg, 
                  "a4l_ioctl_cmd: 1st cmd checks passed\n");
 
+       subd = dev->transfer.subds[cmd_desc->idx_subd];
+
        /* 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], 
-                                  cmd_desc);
+       if (subd->do_cmdtest != NULL)
+               ret = subd->do_cmdtest(subd, cmd_desc);
        if (ret != 0) {
                __a4l_err("a4l_ioctl_cmd: driver's cmd_test failed\n");
                goto out_ioctl_cmd;
@@ -363,17 +364,15 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg)
        }
 
        /* Sets the concerned subdevice as busy */
-       ret = a4l_reserve_transfer(cxt, cmd_desc->idx_subd);
+       ret = a4l_reserve_subd(subd);
        if (ret < 0)
                goto out_ioctl_cmd;
 
        /* Gets the transfer system ready */
-       a4l_init_transfer(cxt, cmd_desc);
+       a4l_setup_buffer(cxt, cmd_desc);
 
        /* Eventually launches the command */
-       ret = dev->transfer.subds[cmd_desc->idx_subd]->
-               do_cmd(dev->transfer.subds[cmd_desc->idx_subd], 
-                      cmd_desc);
+       ret = subd->do_cmd(subd, cmd_desc);
 
        if (ret != 0) {
                a4l_cancel_transfer(cxt, cmd_desc->idx_subd);
diff --git a/ksrc/drivers/analogy/instruction.c 
b/ksrc/drivers/analogy/instruction.c
index 64c7a04..941fa69 100644
--- a/ksrc/drivers/analogy/instruction.c
+++ b/ksrc/drivers/analogy/instruction.c
@@ -266,7 +266,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc)
 
        /* Prevents the subdevice from being used during 
           the following operations */
-       ret = a4l_reserve_transfer(cxt, dsc->idx_subd);
+       ret = a4l_reserve_subd(subd);
        if (ret < 0)
                goto out_do_insn;
 
diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c
index b1e511d..9fc279a 100644
--- a/ksrc/drivers/analogy/transfer.c
+++ b/ksrc/drivers/analogy/transfer.c
@@ -39,10 +39,6 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt)
        a4l_trf_t *tsf;
        int i, err = 0;
 
-       __a4l_dbg(1, core_dbg, 
-                 "a4l_precleanup_transfer: minor=%d\n", 
-                 a4l_get_minor(cxt));
-
        dev = a4l_get_dev(cxt);
        tsf = &dev->transfer;
 
@@ -55,6 +51,10 @@ int a4l_precleanup_transfer(a4l_cxt_t * cxt)
        for (i = 0; i < tsf->nb_subd; i++) {
                unsigned long *status = &tsf->subds[i]->status;
 
+               __a4l_dbg(1, core_dbg, 
+                         "a4l_precleanup_transfer: "
+                         "subd[%d]->status=0x%08x\n", *status);
+
                if (test_and_set_bit(A4L_SUBD_BUSY, status)) {
                        __a4l_err("a4l_precleanup_transfer: "
                                  "device busy, acquisition occuring\n");
@@ -70,7 +70,7 @@ out_error:
        for (i = 0; i < tsf->nb_subd; i++) {
                unsigned long *status = &tsf->subds[i]->status;
 
-               if (test_bit(A4L_TSF_CLEAN, status)){
+               if (test_bit(A4L_SUBD_CLEAN, status)){
                        clear_bit(A4L_SUBD_BUSY, status);
                        clear_bit(A4L_SUBD_CLEAN, status);
                }
@@ -85,10 +85,6 @@ int a4l_cleanup_transfer(a4l_cxt_t * cxt)
        a4l_trf_t *tsf;
        int i;
 
-       __a4l_dbg(1, core_dbg, 
-                 "a4l_cleanup_transfer: minor=%d\n", 
-                 a4l_get_minor(cxt));
-
        dev = a4l_get_dev(cxt);
        tsf = &dev->transfer;
 
@@ -105,10 +101,6 @@ void a4l_presetup_transfer(a4l_cxt_t *cxt)
        a4l_dev_t *dev = NULL;
        a4l_trf_t *tsf;
 
-       __a4l_dbg(1, core_dbg, 
-                 "a4l_presetup_transfer: minor=%d\n",
-                 a4l_get_minor(cxt));
-
        dev = a4l_get_dev(cxt);
        tsf = &dev->transfer;
 
@@ -124,14 +116,9 @@ int a4l_setup_transfer(a4l_cxt_t * cxt)
 {
        a4l_dev_t *dev = NULL;
        a4l_trf_t *tsf;
-       a4l_subd_t *subd;
        struct list_head *this;
        int i = 0, ret = 0;
 
-       __a4l_dbg(1, core_dbg, 
-                 "a4l_setup_transfer: minor=%d\n",
-                 a4l_get_minor(cxt));
-
        dev = a4l_get_dev(cxt);
        tsf = &dev->transfer;
 
@@ -141,6 +128,9 @@ int a4l_setup_transfer(a4l_cxt_t * cxt)
                tsf->nb_subd++;
        }
 
+       __a4l_dbg(1, core_dbg, 
+                 "a4l_setup_transfer: nb_subd=%d\n", tsf->nb_subd);
+
        /* Allocates a suitable tab for the subdevices */
        tsf->subds = rtdm_malloc(tsf->nb_subd * sizeof(a4l_subd_t *));
        if (tsf->subds == NULL) {
@@ -151,15 +141,7 @@ int a4l_setup_transfer(a4l_cxt_t * cxt)
 
        /* Recovers the subdevices pointers */
        list_for_each(this, &dev->subdvsq) {
-               subd = list_entry(this, a4l_subd_t, list);
-
-               if (subd->flags & A4L_SUBD_AI)
-                       tsf->idx_read_subd = i;
-
-               if (subd->flags & A4L_SUBD_AO)
-                       tsf->idx_write_subd = i;
-
-               tsf->subds[i++] = subd;
+               tsf->subds[i++] = list_entry(this, a4l_subd_t, list);
        }
 
 out_setup_tsf:
@@ -170,68 +152,6 @@ out_setup_tsf:
        return ret;
 }
 
-int a4l_reserve_transfer(a4l_cxt_t * cxt, int idx_subd)
-{
-       a4l_dev_t *dev = a4l_get_dev(cxt);
-
-       __a4l_dbg(1, core_dbg,
-                 "a4l_reserve_transfer: minor=%d idx=%d\n",
-                 a4l_get_minor(cxt), idx_subd);
-
-       if (test_and_set_bit(A4L_TSF_BUSY,
-                            &(dev->transfer.status[idx_subd]))) {
-               __a4l_err("a4l_reserve_transfer: device currently busy\n");
-               return -EBUSY;
-       }
-
-       return 0;
-}
-
-int a4l_init_transfer(a4l_cxt_t * cxt, a4l_cmd_t * cmd)
-{
-       int i;
-       a4l_dev_t *dev = a4l_get_dev(cxt);
-
-       __a4l_dbg(1, core_dbg,
-                 "a4l_init_transfer: minor=%d idx=%d\n",
-                 a4l_get_minor(cxt), cmd->idx_subd);
-
-       /* Checks if the transfer system has to work in bulk mode */
-       if (cmd->flags & A4L_CMD_BULK)
-               set_bit(A4L_TSF_BULK,
-                       &(dev->transfer.status[cmd->idx_subd]));
-
-       /* Sets the working command */
-       dev->transfer.bufs[cmd->idx_subd]->cur_cmd = cmd;
-
-       /* Initializes the counts */
-       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]->mng_count = 0;
-
-       /* Flush pending events */
-       dev->transfer.bufs[cmd->idx_subd]->evt_flags = 0;
-       a4l_flush_sync(&dev->transfer.bufs[cmd->idx_subd]->sync);
-
-       /* Computes the count to reach, if need be */
-       if (cmd->stop_src == TRIG_COUNT) {
-               for (i = 0; i < cmd->nb_chan; i++) {
-                       a4l_chan_t *chft;
-                       chft = a4l_get_chfeat(dev->transfer.
-                                             subds[cmd->idx_subd],
-                                             CR_CHAN(cmd->chan_descs[i]));
-                       dev->transfer.bufs[cmd->idx_subd]->end_count +=
-                               chft->nb_bits / 8;
-               }
-               dev->transfer.bufs[cmd->idx_subd]->end_count *= cmd->stop_arg;
-       }
-
-       /* Always returning 0 is here useless... for the moment */
-       return 0;
-}
-
 int a4l_cancel_transfer(a4l_cxt_t * cxt, int idx_subd)
 {
        int ret = 0;


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

Reply via email to