Module: xenomai-abe
Branch: experimental
Commit: 49f6c9e388da86c0a38ba4293d60245c9c7044b5
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=49f6c9e388da86c0a38ba4293d60245c9c7044b5

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Mon May 24 16:46:31 2010 +0200

analogy: declare the reserve / release functions at the subd level (broken)

---

 include/analogy/subdevice.h        |    2 ++
 ksrc/drivers/analogy/command.c     |   33 ++++++++++++---------------------
 ksrc/drivers/analogy/instruction.c |    2 +-
 ksrc/drivers/analogy/subdevice.c   |   15 +++++++++++++++
 4 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h
index 0f9e1c5..ded82f3 100644
--- a/include/analogy/subdevice.h
+++ b/include/analogy/subdevice.h
@@ -290,6 +290,8 @@ a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx);
 a4l_subd_t * a4l_alloc_subd(int sizeof_priv,
                            void (*setup)(a4l_subd_t *));
 int a4l_add_subd(struct a4l_device *dev, a4l_subd_t * subd);
+int a4l_reserve_subd(a4l_subd_t *subd);
+void a4l_release_subd(a4l_subd_t *subd);
 int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg);
 int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg);
 int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg);
diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c
index b300d9a..94d6137 100644
--- a/ksrc/drivers/analogy/command.c
+++ b/ksrc/drivers/analogy/command.c
@@ -90,11 +90,8 @@ void a4l_free_cmddesc(a4l_cmd_t * desc)
 
 int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc)
 {
-       int ret = 0;
        a4l_dev_t *dev = a4l_get_dev(cxt);
-
-       __a4l_dbg(1, core_dbg, 
-                    "a4l_check_cmddesc: minor=%d\n", a4l_get_minor(cxt));
+       a4l_subd_t *subd;
 
        if (desc->idx_subd >= dev->transfer.nb_subd) {
                __a4l_err("a4l_check_cmddesc: "
@@ -103,25 +100,23 @@ int a4l_check_cmddesc(a4l_cxt_t * cxt, a4l_cmd_t * desc)
                return -EINVAL;
        }
 
-       if ((dev->transfer.subds[desc->idx_subd]->flags & A4L_SUBD_TYPES) == 
-           A4L_SUBD_UNUSED) {
+       subd = dev->transfer.subds[desc->idx_subd];
+
+       if ((subd->flags & A4L_SUBD_TYPES) == A4L_SUBD_UNUSED) {
                __a4l_err("a4l_check_cmddesc: "
                          "subdevice type incoherent\n");
                return -EIO;
        }
 
-       if (!(dev->transfer.subds[desc->idx_subd]->flags & A4L_SUBD_CMD)) {
+       if (!(subd->flags & A4L_SUBD_CMD)) {
                __a4l_err("a4l_check_cmddesc: operation not supported, "
                          "synchronous only subdevice\n");
                return -EIO;
        }
 
-       if (test_bit(A4L_TSF_BUSY, &(dev->transfer.status[desc->idx_subd])))
-               return -EBUSY;
-
-       if (ret != 0) {
+       if (test_bit(A4L_SUBD_BUSY, &subd->status)) {
                __a4l_err("a4l_check_cmddesc: subdevice busy\n");
-               return ret;
+               return -EBUSY;
        }
 
        return a4l_check_chanlist(dev->transfer.subds[desc->idx_subd],
@@ -299,17 +294,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg)
 {
        int ret = 0, simul_flag = 0;
        a4l_cmd_t *cmd_desc = NULL;
-       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));
+       a4l_subd_t *subd;
 
        /* The command launching cannot be done in real-time because
           of some possible buffer allocations in the drivers */
-       if (rtdm_in_rt_context()) {
+       if (rtdm_in_rt_context())
                return -ENOSYS;
-       }
 
        /* Basically check the device */
        if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) {
@@ -373,13 +364,13 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg)
 
        /* Eventually launches the command */
        ret = subd->do_cmd(subd, cmd_desc);
-
+       
        if (ret != 0) {
-               a4l_cancel_transfer(cxt, cmd_desc->idx_subd);
+               a4l_cancel_buffer(cxt);
                goto out_ioctl_cmd;
        }
 
-      out_ioctl_cmd:
+out_ioctl_cmd:
        if (ret != 0 || simul_flag == 1) {
                a4l_free_cmddesc(cmd_desc);
                rtdm_free(cmd_desc);
diff --git a/ksrc/drivers/analogy/instruction.c 
b/ksrc/drivers/analogy/instruction.c
index 941fa69..413c0d2 100644
--- a/ksrc/drivers/analogy/instruction.c
+++ b/ksrc/drivers/analogy/instruction.c
@@ -281,7 +281,7 @@ int a4l_do_insn(a4l_cxt_t * cxt, a4l_kinsn_t * dsc)
 out_do_insn:
 
        /* Releases the subdevice from its reserved state */
-       a4l_cancel_transfer(cxt, dsc->idx_subd);
+       a4l_release_subd(subd);
 
        return ret;
 }
diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c
index 1278081..506b742 100644
--- a/ksrc/drivers/analogy/subdevice.c
+++ b/ksrc/drivers/analogy/subdevice.c
@@ -180,6 +180,21 @@ a4l_subd_t *a4l_get_subd(a4l_dev_t *dev, int idx)
        return subd;
 }
 
+int a4l_reserve_subd(a4l_subd_t *subd)
+{
+        if (test_and_set_bit(A4L_SUBD_BUSY, &subd->status)) {
+                __a4l_err("a4l_reserve_subd: subdevice currently busy\n");
+                return -EBUSY;
+        }
+
+        return 0;
+}
+
+void a4l_release_subd(a4l_subd_t *subd)
+{
+       clear_bit(A4L_SUBD_BUSY, &subd->status));
+}
+
 /* --- IOCTL / FOPS functions --- */
 
 int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg)


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

Reply via email to