Module: xenomai-3
Branch: master
Commit: 367718865e1556a38a01c8ddfefd84348cdfd42b
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=367718865e1556a38a01c8ddfefd84348cdfd42b

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Apr 24 11:40:14 2015 +0200

drivers/udd: fix the IRQ enable/disable API

Since requests for enabling or disabling interrupt lines can now
operate in sync mode, there is no point in keeping the post_ hint into
the names of the corresponding routines.

udd_post_irq_enable => udd_enable_irq
udd_post_irq_disable => udd_disable_irq

In addition, those services now go through the RTDM layer for applying
the requested change, instead of taking sideways by calling the I-pipe
API directly, which is wrong (we shall NOT bypass
xnintr_enable/disable due to locking requirements in the Cobalt core).

---

 include/cobalt/kernel/rtdm/udd.h |    6 ++--
 include/rtdm/uapi/udd.h          |    4 +--
 kernel/drivers/udd/udd.c         |   58 ++++++++++++++++++++++----------------
 3 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/udd.h b/include/cobalt/kernel/rtdm/udd.h
index 67ca6ed..3838f6b 100644
--- a/include/cobalt/kernel/rtdm/udd.h
+++ b/include/cobalt/kernel/rtdm/udd.h
@@ -324,9 +324,11 @@ struct udd_device *udd_get_device(struct rtdm_fd *fd);
 
 void udd_notify_event(struct udd_device *udd);
 
-void udd_post_irq_enable(int irq, rtdm_event_t *done);
+void udd_enable_irq(struct udd_device *udd,
+                   rtdm_event_t *done);
 
-void udd_post_irq_disable(int irq, rtdm_event_t *done);
+void udd_disable_irq(struct udd_device *udd,
+                    rtdm_event_t *done);
 
 /** @} */
 
diff --git a/include/rtdm/uapi/udd.h b/include/rtdm/uapi/udd.h
index 5ac9b92..50672ee 100644
--- a/include/rtdm/uapi/udd.h
+++ b/include/rtdm/uapi/udd.h
@@ -67,14 +67,14 @@ struct udd_signotify {
  * Enable the interrupt line. The UDD-class mini-driver should handle
  * this request when received through its ->ioctl() handler if
  * provided. Otherwise, the UDD core enables the interrupt line in the
- * interrupt controller.
+ * interrupt controller before returning to the caller.
  */
 #define UDD_RTIOC_IRQEN                _IO(RTDM_CLASS_UDD, 0)
 /**
  * Disable the interrupt line. The UDD-class mini-driver should handle
  * this request when received through its ->ioctl() handler if
  * provided. Otherwise, the UDD core disables the interrupt line in
- * the interrupt controller.
+ * the interrupt controller before returning to the caller.
  */
 #define UDD_RTIOC_IRQDIS       _IO(RTDM_CLASS_UDD, 1)
 /**
diff --git a/kernel/drivers/udd/udd.c b/kernel/drivers/udd/udd.c
index aaae6f7..9858328 100644
--- a/kernel/drivers/udd/udd.c
+++ b/kernel/drivers/udd/udd.c
@@ -97,9 +97,9 @@ static int udd_ioctl_rt(struct rtdm_fd *fd,
                        return -EIO;
                rtdm_event_init(&done, 0);
                if (request == UDD_RTIOC_IRQEN)
-                       udd_post_irq_enable(udd->irq, &done);
+                       udd_enable_irq(udd, &done);
                else
-                       udd_post_irq_disable(udd->irq, &done);
+                       udd_disable_irq(udd, &done);
                ret = rtdm_event_wait(&done);
                if (ret != -EIDRM)
                        rtdm_event_destroy(&done);
@@ -517,7 +517,7 @@ EXPORT_SYMBOL_GPL(udd_notify_event);
 
 struct irqswitch_work {
        struct ipipe_work_header work; /* Must be first. */
-       int irq;
+       rtdm_irq_t *irqh;
        int enabled;
        rtdm_event_t *done;
 };
@@ -532,22 +532,22 @@ static void lostage_irqswitch_line(struct 
ipipe_work_header *work)
         */
        rq = container_of(work, struct irqswitch_work, work);
        if (rq->enabled)
-               ipipe_enable_irq(rq->irq);
+               rtdm_irq_enable(rq->irqh);
        else
-               ipipe_disable_irq(rq->irq);
+               rtdm_irq_disable(rq->irqh);
 
        if (rq->done)
                rtdm_event_signal(rq->done);
 }
 
-static void switch_irq_line(int irq, int enable, rtdm_event_t *done)
+static void switch_irq_line(rtdm_irq_t *irqh, int enable, rtdm_event_t *done)
 {
        struct irqswitch_work switchwork = {
                .work = {
                        .size = sizeof(switchwork),
                        .handler = lostage_irqswitch_line,
                },
-               .irq = irq,
+               .irqh = irqh,
                .enabled = enable,
                .done = done,
        };
@@ -562,15 +562,16 @@ static void switch_irq_line(int irq, int enable, 
rtdm_event_t *done)
 }
 
 /**
- * @brief Post a request for enabling an IRQ line
+ * @brief Enable the device IRQ line
  *
  * This service issues a request to the regular kernel for enabling
- * the IRQ line mentioned. If the caller runs in primary mode, the
- * request is scheduled but deferred until the current CPU leaves the
- * real-time domain (see note). Otherwise, the request is immediately
- * handled.
+ * the IRQ line registered by the driver. If the caller runs in
+ * primary mode, the request is scheduled but deferred until the
+ * current CPU leaves the real-time domain (see note). Otherwise, the
+ * request is immediately handled.
  *
- * @param irq IRQ line to enable.
+ * @param irq IRQ line to enable. If no IRQ was registered by the
+ * driver at the UDD core, this routine has no effect.
  *
  * @param done Optional event to signal upon completion. If non-NULL,
  * @a done will be posted by a call to rtdm_event_signal() after the
@@ -584,22 +585,26 @@ static void switch_irq_line(int irq, int enable, 
rtdm_event_t *done)
  * caller can wait for the request to complete, by sleeping on
  * rtdm_event_wait().
  */
-void udd_post_irq_enable(int irq, rtdm_event_t *done)
+void udd_enable_irq(struct udd_device *udd, rtdm_event_t *done)
 {
-       switch_irq_line(irq, 1, done);
+       struct udd_reserved *ur = &udd->__reserved;
+
+       if (udd->irq != UDD_IRQ_NONE && udd->irq != UDD_IRQ_CUSTOM)
+               switch_irq_line(&ur->irqh, 1, done);
 }
-EXPORT_SYMBOL_GPL(udd_post_irq_enable);
+EXPORT_SYMBOL_GPL(udd_enable_irq);
 
 /**
- * @brief Post a request for disabling an IRQ line
+ * @brief Disable the device IRQ line
  *
  * This service issues a request to the regular kernel for disabling
- * the IRQ line mentioned. If the caller runs in primary mode, the
- * request is scheduled but deferred until the current CPU leaves the
- * real-time domain (see note). Otherwise, the request is immediately
- * handled.
+ * the IRQ line registered by the driver. If the caller runs in
+ * primary mode, the request is scheduled but deferred until the
+ * current CPU leaves the real-time domain (see note). Otherwise, the
+ * request is immediately handled.
  *
- * @param irq IRQ line to disable.
+ * @param irq IRQ line to disable. If no IRQ was registered by the
+ * driver at the UDD core, this routine has no effect.
  *
  * @param done Optional event to signal upon completion. If non-NULL,
  * @a done will be posted by a call to rtdm_event_signal() after the
@@ -613,11 +618,14 @@ EXPORT_SYMBOL_GPL(udd_post_irq_enable);
  * caller can wait for the request to complete, by sleeping on
  * rtdm_event_wait().
  */
-void udd_post_irq_disable(int irq, rtdm_event_t *done)
+void udd_disable_irq(struct udd_device *udd, rtdm_event_t *done)
 {
-       switch_irq_line(irq, 0, done);
+       struct udd_reserved *ur = &udd->__reserved;
+
+       if (udd->irq != UDD_IRQ_NONE && udd->irq != UDD_IRQ_CUSTOM)
+               switch_irq_line(&ur->irqh, 0, done);
 }
-EXPORT_SYMBOL_GPL(udd_post_irq_disable);
+EXPORT_SYMBOL_GPL(udd_disable_irq);
 
 /**
  * @brief RTDM file descriptor to target UDD device


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to