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

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Tue May 18 23:53:11 2010 +0200

analogy: rewrite the cancel ioctl handler (broken)

---

 ksrc/drivers/analogy/buffer.c   |   38 ++++++++++++++++++++++++++++++++-
 ksrc/drivers/analogy/transfer.c |   45 ---------------------------------------
 2 files changed, 37 insertions(+), 46 deletions(-)

diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c
index cb4beb7..bc162d3 100644
--- a/ksrc/drivers/analogy/buffer.c
+++ b/ksrc/drivers/analogy/buffer.c
@@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt)
        
        int err = 0;
        
-       if (!subd !! !a4l_check_subd(subd))
+       if (!subd || !a4l_check_subd(subd))
                return 0;
 
        /* If a "cancel" function is registered, call it
@@ -547,6 +547,42 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg)
 
 /* --- IOCTL / FOPS functions --- */
 
+int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg)
+{
+       unsigned int idx_subd = (unsigned long)arg;
+       a4l_dev_t *dev = a4l_get_dev(cxt);
+       a4l_subd_t *subd;
+
+       /* Basically check the device */
+       if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) {
+               __a4l_err("a4l_ioctl_cancel: operation not supported on "
+                         "an unattached device\n");
+               return -EINVAL;
+       }
+
+       if (cxt->buffer->subd == NULL) {
+               __a4l_err("a4l_ioctl_cancel: "
+                         "no acquisition to cancel on this context\n");
+               return -EINVAL;
+       }
+       
+       if (idx_subd >= dev->transfer.nb_subd) {
+               __a4l_err("a4l_ioctl_cancel: bad subdevice index\n");
+               return -EINVAL;
+       }
+
+       subd = dev->transfer.subds[idx_subd];
+       
+       if (subd != cxt->buffer.subd) {
+               __a4l_err("a4l_ioctl_cancel: "
+                         "current context works on another subdevice "
+                         "(%d!=%d)\n", cxt->buffer.subd->idx, subd->idx);
+               return -EINVAL;         
+       }
+
+       return a4l_cancel_buffer(cxt);
+}
+
 int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg)
 {
        a4l_dev_t *dev = a4l_get_dev(cxt);
diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c
index aa0ae82..945402f 100644
--- a/ksrc/drivers/analogy/transfer.c
+++ b/ksrc/drivers/analogy/transfer.c
@@ -290,49 +290,4 @@ int a4l_rdproc_transfer(char *page,
 
 #endif /* CONFIG_PROC_FS */
 
-/* --- IOCTL / FOPS functions --- */
-
-int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg)
-{
-       unsigned int idx_subd = (unsigned long)arg;
-       a4l_dev_t *dev = a4l_get_dev(cxt);
-       a4l_subd_t *subd;
-
-       __a4l_dbg(1, core_dbg, 
-                 "a4l_ioctl_cancel: minor=%d\n", a4l_get_minor(cxt));
-
-       /* Basically check the device */
-       if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) {
-               __a4l_err("a4l_ioctl_cancel: operation not supported on "
-                         "an unattached device\n");
-               return -EINVAL;
-       }
-
-       if (idx_subd >= dev->transfer.nb_subd) {
-               __a4l_err("a4l_ioctl_cancel: bad subdevice index\n");
-               return -EINVAL;
-       }
-
-       if ((dev->transfer.subds[idx_subd]->flags & A4L_SUBD_TYPES) == 
-           A4L_SUBD_UNUSED) {
-               __a4l_err("a4l_ioctl_cancel: non functional subdevice\n");
-               return -EIO;
-       }
-
-       if (!(dev->transfer.subds[idx_subd]->flags & A4L_SUBD_CMD)) {
-               __a4l_err("a4l_ioctl_cancel: operation not supported, "
-                         "synchronous only subdevice\n");
-               return -EIO;
-       }
-
-       subd = dev->transfer.subds[idx_subd];
-
-       if (!test_bit(A4L_TSF_BUSY, &(dev->transfer.status[idx_subd]))) {
-               __a4l_err("a4l_ioctl_cancel: subdevice currently idle\n");
-               return -EINVAL;
-       }
-
-       return a4l_cancel_transfer(cxt, idx_subd);
-}
-
 #endif /* !DOXYGEN_CPP */


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

Reply via email to