Module: xenomai-forge
Branch: next
Commit: 34bc10e3faefa086d2214fb424a4cba2805b440d
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=34bc10e3faefa086d2214fb424a4cba2805b440d

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Aug 21 16:21:07 2014 +0200

drivers/udd: allow mini-drivers to set device flags

---

 include/cobalt/kernel/rtdm/udd.h |    5 +++++
 kernel/drivers/udd/udd.c         |    7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/cobalt/kernel/rtdm/udd.h b/include/cobalt/kernel/rtdm/udd.h
index 1222f9a..d21efc2 100644
--- a/include/cobalt/kernel/rtdm/udd.h
+++ b/include/cobalt/kernel/rtdm/udd.h
@@ -192,6 +192,11 @@ struct udd_device {
        /** Name of the device managed by the mini-driver. */
        const char *device_name;
        /**
+        * Additional device flags (e.g. RTDM_EXCLUSIVE,
+        * RTDM_MINOR. RTDM_NAMED_DEVICE may be omitted).
+        */
+       int device_flags;
+       /**
         * Textual description of the device managed by the
         * mini-driver.
         */
diff --git a/kernel/drivers/udd/udd.c b/kernel/drivers/udd/udd.c
index 6cffa1a..4bcec17 100644
--- a/kernel/drivers/udd/udd.c
+++ b/kernel/drivers/udd/udd.c
@@ -329,6 +329,8 @@ static inline int register_mapper(struct udd_device *udd)
  * - -EINVAL, if udd_device.irq is different from UDD_IRQ_CUSTOM and
  * UDD_IRQ_NONE but invalid, causing rtdm_irq_request() to fail.
  *
+ * - -EINVAL, if udd_device.device_flags contains invalid flags.
+ *
  * - -ENXIO can be received if this service is called while the Cobalt
  * kernel is disabled.
  *
@@ -343,6 +345,9 @@ int udd_register_device(struct udd_device *udd)
        if (!realtime_core_enabled())
                return -ENXIO;
 
+       if (udd->device_flags & RTDM_PROTOCOL_DEVICE)
+               return -EINVAL;
+
        if (udd->irq != UDD_IRQ_NONE && udd->ops.interrupt == NULL)
                return -EINVAL;
 
@@ -354,7 +359,7 @@ int udd_register_device(struct udd_device *udd)
 
        memset(dev, 0, sizeof(*dev));
        dev->struct_version = RTDM_DEVICE_STRUCT_VER;
-       dev->device_flags = RTDM_NAMED_DEVICE;
+       dev->device_flags = RTDM_NAMED_DEVICE|udd->device_flags;
        dev->context_size = sizeof(struct udd_context);
        dev->ops = (struct rtdm_fd_ops){
                .open = udd_open,


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

Reply via email to