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

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Fri Mar 19 01:03:09 2010 +0100

analogy: at close time, cancel any busy subdevice

---

 include/analogy/transfer.h            |    1 +
 ksrc/drivers/analogy/rtdm_interface.c |    5 +++--
 ksrc/drivers/analogy/transfer.c       |   16 ++++++++++++++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/analogy/transfer.h b/include/analogy/transfer.h
index 3d44ac6..e6bdc3c 100644
--- a/include/analogy/transfer.h
+++ b/include/analogy/transfer.h
@@ -87,6 +87,7 @@ int a4l_cleanup_transfer(a4l_cxt_t * cxt);
 int a4l_reserve_transfer(a4l_cxt_t * cxt, int idx_subd);
 int a4l_init_transfer(a4l_cxt_t * cxt, a4l_cmd_t * cmd);
 int a4l_cancel_transfer(a4l_cxt_t * cxt, int idx_subd);
+int a4l_cancel_transfers(a4l_cxt_t * cxt);
 
 ssize_t a4l_put(a4l_cxt_t * cxt, void *buf, size_t nbytes);
 ssize_t a4l_get(a4l_cxt_t * cxt, void *buf, size_t nbytes);
diff --git a/ksrc/drivers/analogy/rtdm_interface.c 
b/ksrc/drivers/analogy/rtdm_interface.c
index 86d3f9d..f769e4a 100644
--- a/ksrc/drivers/analogy/rtdm_interface.c
+++ b/ksrc/drivers/analogy/rtdm_interface.c
@@ -33,6 +33,7 @@
 #include <analogy/context.h>
 #include <analogy/ioctl.h>
 #include <analogy/device.h>
+#include <analogy/transfer.h>
 
 int (*a4l_ioctl_functions[NB_IOCTL_FUNCTIONS]) (a4l_cxt_t *, void *) = {
        a4l_ioctl_devcfg,
@@ -141,9 +142,9 @@ int a4l_rt_close(struct rtdm_dev_context *context,
        a4l_init_cxt(context, user_info, &cxt);
        a4l_set_dev(&cxt);
        __a4l_dbg(1, core_dbg, 
-                 "a4l_rt_close: minor=%d\n", a4l_get_minor(&cxt));
+                 "a4l_rt_close: minor=%d\n", a4l_get_minor(&cxt));     
 
-       return 0;
+       return a4l_cancel_transfers(&cxt);;
 }
 
 ssize_t a4l_rt_read(struct rtdm_dev_context * context,
diff --git a/ksrc/drivers/analogy/transfer.c b/ksrc/drivers/analogy/transfer.c
index 5239d08..f25f912 100644
--- a/ksrc/drivers/analogy/transfer.c
+++ b/ksrc/drivers/analogy/transfer.c
@@ -337,6 +337,22 @@ int a4l_cancel_transfer(a4l_cxt_t * cxt, int idx_subd)
        return ret;
 }
 
+int a4l_cancel_transfers(a4l_cxt_t * cxt)
+{
+       a4l_dev_t *dev = a4l_get_dev(cxt);
+       int i, ret = 0;
+
+       /* The caller of a4l_cancel_transfers is bound not to have
+          checked whether the subdevice was attached; so we do it here */
+       if (!test_bit(A4L_DEV_ATTACHED, &dev->flags))
+               return 0;
+
+       for (i = 0; i < dev->transfer.nb_subd && ret == 0; i++)
+               ret = a4l_cancel_transfer(cxt, i);
+
+       return ret;
+}
+
 /* --- IRQ handling section --- */
 
 int a4l_request_irq(a4l_dev_t * dev,


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

Reply via email to