Module: xenomai-rpm
Branch: for-upstream
Commit: 2cc55b9a5b99977f8902c48ef8a6dacb6f7a5018
URL:    
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=2cc55b9a5b99977f8902c48ef8a6dacb6f7a5018

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Mar  5 12:14:20 2010 +0100

nucleus/intr: fix error code from xnintr_detach()

It does not make sense to return -EPERM upon a request to detach an
already detached IRQ descriptor. Such value is likely to be
misinterpreted downstream, which usually reserves it for
security/access issues. Prefer -EINVAL instead.

Fix the documentation for xnintr_irq_attach/detach as well.

---

 ksrc/nucleus/intr.c      |   22 +++++++++++++---------
 ksrc/skins/native/intr.c |    2 +-
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/ksrc/nucleus/intr.c b/ksrc/nucleus/intr.c
index 2d149b5..a6de4ea 100644
--- a/ksrc/nucleus/intr.c
+++ b/ksrc/nucleus/intr.c
@@ -679,9 +679,12 @@ EXPORT_SYMBOL_GPL(xnintr_destroy);
  * interrupt object descriptor for further retrieval by the ISR/ISR
  * handlers.
  *
- * @return 0 is returned on success. Otherwise, -EINVAL is returned if
- * a low-level error occurred while attaching the interrupt. -EBUSY is
- * specifically returned if the interrupt object was already attached.
+ * @return 0 is returned on success. Otherwise:
+ *
+ * - -EINVAL is returned if a low-level error occurred while attaching
+ * the interrupt.
+ *
+ * - -EBUSY is returned if the interrupt object was already attached.
  *
  * @note The caller <b>must not</b> hold nklock when invoking this service,
  * this would cause deadlocks.
@@ -722,7 +725,7 @@ int xnintr_attach(xnintr_t *intr, void *cookie)
        }
 
        if (__testbits(intr->flags, XN_ISR_ATTACHED)) {
-               ret = -EPERM;
+               ret = -EBUSY;
                goto out;
        }
 
@@ -752,10 +755,11 @@ EXPORT_SYMBOL_GPL(xnintr_attach);
  * @param intr The descriptor address of the interrupt object to
  * detach.
  *
- * @return 0 is returned on success. Otherwise, -EINVAL is returned if
- * a low-level error occurred while detaching the interrupt. Detaching
- * a non-attached interrupt object leads to a null-effect and returns
- * 0.
+ * @return 0 is returned on success. Otherwise:
+ *
+ * - -EINVAL is returned if a low-level error occurred while detaching
+ * the interrupt, or if the interrupt object was not attached. In both
+ * cases, no action is performed.
  *
  * @note The caller <b>must not</b> hold nklock when invoking this service,
  * this would cause deadlocks.
@@ -784,7 +788,7 @@ int xnintr_detach(xnintr_t *intr)
        }
 
        if (!__testbits(intr->flags, XN_ISR_ATTACHED)) {
-               ret = -EPERM;
+               ret = -EINVAL;
                goto out;
        }
 
diff --git a/ksrc/skins/native/intr.c b/ksrc/skins/native/intr.c
index 8abcd27..a69bd46 100644
--- a/ksrc/skins/native/intr.c
+++ b/ksrc/skins/native/intr.c
@@ -311,7 +311,7 @@ int rt_intr_create(RT_INTR *intr,
  *
  * @return 0 is returned upon success. Otherwise:
  *
- * - -EINVAL is returned if @a intr is not a interrupt object
+ * - -EINVAL is returned if @a intr is not a valid interrupt object
  * descriptor.
  *
  * - -EIDRM is returned if @a intr is a deleted interrupt object


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

Reply via email to