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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Sep 18 21:02:09 2014 +0200

cobalt/rtdm: drop poll_delay from rtdm_dev_unregister()

Sleep indefinitely on a plain waitqueue instead of polling, until the
device becomes idle. For this reason, the routine loses its return
value as well, as drivers are most often not willing to deal with
receiving a device busy condition from a module exit routine (which is
the place devices should be unregistered from).

Drivers which really want to deal with such condition should simply
use module refcounting in their own code.

---

 include/cobalt/kernel/rtdm/driver.h     |    5 +-
 include/cobalt/kernel/rtdm/udd.h        |    3 +-
 kernel/cobalt/posix/io.c                |   12 ++--
 kernel/cobalt/posix/memory.c            |   10 ++--
 kernel/cobalt/rtdm/core.c               |    2 +-
 kernel/cobalt/rtdm/device.c             |   93 ++++++++++++++-----------------
 kernel/cobalt/rtdm/internal.h           |   28 ++++++----
 kernel/cobalt/trace/cobalt-rtdm.h       |   10 ++--
 kernel/drivers/analogy/rtdm_interface.c |    4 +-
 kernel/drivers/can/rtcan_raw.c          |    2 +-
 kernel/drivers/ipc/rtipc.c              |    2 +-
 kernel/drivers/serial/16550A.c          |    2 +-
 kernel/drivers/serial/mpc52xx_uart.c    |    2 +-
 kernel/drivers/serial/rt_imx_uart.c     |    2 +-
 kernel/drivers/testing/rtdmtest.c       |    4 +-
 kernel/drivers/testing/switchtest.c     |    2 +-
 kernel/drivers/testing/timerbench.c     |    2 +-
 kernel/drivers/udd/udd.c                |   46 +++++++--------
 18 files changed, 112 insertions(+), 119 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 765f557..da5bcbd 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -29,6 +29,7 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/cdev.h>
+#include <linux/wait.h>
 #include <xenomai/version.h>
 #include <cobalt/kernel/heap.h>
 #include <cobalt/kernel/sched.h>
@@ -348,6 +349,7 @@ struct rtdm_device {
                atomic_t refcount;
                struct rtdm_dev_context *exclusive_context;
                struct rtdm_fd_ops ops;
+               wait_queue_head_t putwq;
        };
 };
 
@@ -357,8 +359,7 @@ struct rtdm_device {
 
 int rtdm_dev_register(struct rtdm_device *device);
 
-int rtdm_dev_unregister(struct rtdm_device *device,
-                       unsigned int poll_delay);
+void rtdm_dev_unregister(struct rtdm_device *device);
 
 /* --- inter-driver API --- */
 
diff --git a/include/cobalt/kernel/rtdm/udd.h b/include/cobalt/kernel/rtdm/udd.h
index 8fc4715..a78e428 100644
--- a/include/cobalt/kernel/rtdm/udd.h
+++ b/include/cobalt/kernel/rtdm/udd.h
@@ -294,8 +294,7 @@ struct udd_device {
 
 int udd_register_device(struct udd_device *udd);
 
-int udd_unregister_device(struct udd_device *udd,
-                         unsigned int poll_delay);
+int udd_unregister_device(struct udd_device *udd);
 
 struct udd_device *udd_get_device(struct rtdm_fd *fd);
 
diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index d6d5dc3..8038bd3 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -62,23 +62,25 @@ COBALT_SYSCALL(open, lostage,
        filp = filp_open(filename->name, oflag, 0);
        if (IS_ERR(filp)) {
                ret = PTR_ERR(filp);
-               goto fail;
+               goto fail_fopen;
        }
 
        ppd = cobalt_ppd_get(0);
        ret = __rt_dev_open(ppd, ufd, filename->name, oflag);
        if (ret < 0)
-               goto fail;
+               goto fail_devopen;
 
-       rtdm_dereference_device(device);
+       __rtdm_put_device(device);
        fd_install(ufd, filp);
        putname(filename);
 
        return ufd;
-fail:
+fail_devopen:
+       filp_close(filp, current->files);
+fail_fopen:
        put_unused_fd(ufd);
 fail_ufd:
-       rtdm_dereference_device(device);
+       __rtdm_put_device(device);
 fail_lookup:
        putname(filename);
 
diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c
index 5f97f59..f99bb40 100644
--- a/kernel/cobalt/posix/memory.c
+++ b/kernel/cobalt/posix/memory.c
@@ -292,9 +292,9 @@ int cobalt_memdev_init(void)
        return 0;
 
 fail_sysmem:
-       rtdm_dev_unregister(umm_devices + UMM_SHARED, 0);
+       rtdm_dev_unregister(umm_devices + UMM_SHARED);
 fail_shared:
-       rtdm_dev_unregister(umm_devices + UMM_PRIVATE, 0);
+       rtdm_dev_unregister(umm_devices + UMM_PRIVATE);
 fail_private:
        cobalt_umm_free(&__xnsys_global_ppd.umm, nkvdso);
 fail_vdso:
@@ -305,9 +305,9 @@ fail_vdso:
 
 void cobalt_memdev_cleanup(void)
 {
-       rtdm_dev_unregister(&sysmem_device, 0);
-       rtdm_dev_unregister(umm_devices + UMM_SHARED, 0);
-       rtdm_dev_unregister(umm_devices + UMM_PRIVATE, 0);
+       rtdm_dev_unregister(&sysmem_device);
+       rtdm_dev_unregister(umm_devices + UMM_SHARED);
+       rtdm_dev_unregister(umm_devices + UMM_PRIVATE);
        cobalt_umm_free(&__xnsys_global_ppd.umm, nkvdso);
        cobalt_umm_destroy(&__xnsys_global_ppd.umm);
 }
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 4601dad..2ce7d8f 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -50,7 +50,7 @@ static void cleanup_instance(struct rtdm_device *device,
                        kfree(context);
        }
 
-       rtdm_dereference_device(device);
+       __rtdm_put_device(device);
 }
 
 void __rt_dev_close(struct rtdm_fd *fd)
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 5b87b8c..b381950 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -45,15 +45,18 @@ static int enosys(void)
        return -ENOSYS;
 }
 
-static inline xnkey_t get_proto_id(int pf, int type)
+void __rtdm_put_device(struct rtdm_device *device)
 {
-       xnkey_t llpf = (unsigned int)pf;
-       return (llpf << 32) | (unsigned int)type;
+       secondary_mode_only();
+
+       if (atomic_dec_and_test(&device->refcount))
+               wake_up(&device->putwq);
 }
 
-static inline void rtdm_reference_device(struct rtdm_device *device)
+static inline xnkey_t get_proto_id(int pf, int type)
 {
-       atomic_inc(&device->refcount);
+       xnkey_t llpf = (unsigned int)pf;
+       return (llpf << 32) | (unsigned int)type;
 }
 
 struct rtdm_device *__rtdm_get_namedev(const char *path)
@@ -79,7 +82,7 @@ struct rtdm_device *__rtdm_get_namedev(const char *path)
 
        device = xnregistry_lookup(handle, NULL);
        if (device && device->magic == RTDM_DEVICE_MAGIC)
-               rtdm_reference_device(device);
+               __rtdm_get_device(device);
        else
                device = NULL;
 
@@ -102,7 +105,7 @@ struct rtdm_device *__rtdm_get_protodev(int 
protocol_family, int socket_type)
        xnid = xnid_fetch(&rtdm_protocol_devices, id);
        if (xnid) {
                device = container_of(xnid, struct rtdm_device, proto.id);
-               rtdm_reference_device(device);
+               __rtdm_get_device(device);
        }
 
        xnlock_put_irqrestore(&rt_dev_lock, s);
@@ -268,11 +271,9 @@ static void unregister_device_class(struct 
rtdm_device_class *class)
 /**
  * @brief Register a RTDM device
  *
- * The device descriptor is initialized and registered in the RTDM
- * namespace.
+ * Registers a device in the RTDM namespace.
  *
- * @param[in] device Pointer to the device descriptor register.
- * @param[in] class RTDM class the new device belongs to.
+ * @param[in] device Device descriptor.
  *
  * @return 0 is returned upon success. Otherwise:
  *
@@ -297,6 +298,8 @@ int rtdm_dev_register(struct rtdm_device *device)
        dev_t rdev;
        spl_t s;
 
+       secondary_mode_only();
+
        if (!realtime_core_enabled())
                return -ENOSYS;
 
@@ -318,6 +321,7 @@ int rtdm_dev_register(struct rtdm_device *device)
        else
                device->ops.open = (typeof(device->ops.open))enosys;
 
+       init_waitqueue_head(&device->putwq);
        device->ops.close = __rt_dev_close; /* Interpose on driver's handler. */
        atomic_set(&device->refcount, 0);
 
@@ -333,11 +337,13 @@ int rtdm_dev_register(struct rtdm_device *device)
                device->exclusive_context->device = NULL;
        }
 
-       device->magic = RTDM_DEVICE_MAGIC;
-
-       if (class->device_flags & RTDM_FIXED_MINOR)
+       if (class->device_flags & RTDM_FIXED_MINOR) {
                minor = device->minor;
-       else
+               if (minor < 0 || minor >= class->device_count) {
+                       ret = -EINVAL;
+                       goto fail;
+               }
+       } else
                device->minor = minor = pos;
 
        if (class->device_flags & RTDM_NAMED_DEVICE) {
@@ -348,19 +354,20 @@ int rtdm_dev_register(struct rtdm_device *device)
                        goto fail;
                }
 
+               ret = xnregistry_enter(device->name, device,
+                                      &device->named.handle, NULL);
+               if (ret)
+                       goto fail;
+
                rdev = MKDEV(major, minor);
                kdev = device_create(class->kclass, NULL, rdev,
                                     device, device->label, minor);
                if (IS_ERR(kdev)) {
+                       xnregistry_remove(device->named.handle);
                        ret = PTR_ERR(kdev);
                        goto fail;
                }
 
-               ret = xnregistry_enter(device->name, device,
-                                      &device->named.handle, NULL);
-               if (ret)
-                       goto fail;
-
                xnlock_get_irqsave(&rt_dev_lock, s);
                list_add_tail(&device->named.entry, &rtdm_named_devices);
                xnlock_put_irqrestore(&rt_dev_lock, s);
@@ -389,6 +396,7 @@ int rtdm_dev_register(struct rtdm_device *device)
 
        device->rdev = rdev;
        device->kdev = kdev;
+       device->magic = RTDM_DEVICE_MAGIC;
 
        up(&nrt_dev_lock);
 
@@ -416,49 +424,32 @@ EXPORT_SYMBOL_GPL(rtdm_dev_register);
 /**
  * @brief Unregister a RTDM device
  *
- * The device descriptor removed from the RTDM namespace.
+ * Removes the device from the RTDM namespace. This routine waits until
+ * all connections to @a device have been closed prior to unregistering.
  *
- * @param[in] device Pointer to the device descriptor.
- * @param[in] poll_delay Polling delay in milliseconds to check repeatedly for
- * open instances of @a device, or 0 for non-blocking mode.
- *
- * @return 0 is returned upon success. Otherwise:
- *
- * - -EAGAIN is returned if the device is busy with open instances and
- * 0 has been passed for @a poll_delay.
+ * @param[in] device Device descriptor.
  *
  * @coretags{secondary-only}
  */
-int rtdm_dev_unregister(struct rtdm_device *device, unsigned int poll_delay)
+void rtdm_dev_unregister(struct rtdm_device *device)
 {
        struct rtdm_device_class *class = device->class;
        xnhandle_t handle = XN_NO_HANDLE;
-       unsigned long warned = 0;
        spl_t s;
 
-       rtdm_reference_device(device);
+       secondary_mode_only();
 
-       trace_cobalt_device_unregister(device, poll_delay);
-
-       down(&nrt_dev_lock);
-       xnlock_get_irqsave(&rt_dev_lock, s);
+       trace_cobalt_device_unregister(device);
 
-       while (atomic_read(&device->refcount) > 1) {
-               xnlock_put_irqrestore(&rt_dev_lock, s);
-               up(&nrt_dev_lock);
+       /* Lock out any further connection. */
+       device->magic = ~RTDM_DEVICE_MAGIC;
 
-               if (!poll_delay) {
-                       rtdm_dereference_device(device);
-                       return -EAGAIN;
-               }
+       /* Then wait for the ongoing connections to finish. */
+       wait_event(device->putwq,
+                  atomic_read(&device->refcount) == 0);
 
-               if (!__test_and_set_bit(0, &warned))
-                       printk(XENO_WARN "RTDM device %s still in use - waiting 
for"
-                              " release...\n", device->name);
-               msleep(poll_delay);
-               down(&nrt_dev_lock);
-               xnlock_get_irqsave(&rt_dev_lock, s);
-       }
+       down(&nrt_dev_lock);
+       xnlock_get_irqsave(&rt_dev_lock, s);
 
        if (class->device_flags & RTDM_NAMED_DEVICE) {
                handle = device->named.handle;
@@ -481,8 +472,6 @@ int rtdm_dev_unregister(struct rtdm_device *device, 
unsigned int poll_delay)
                kfree(device->exclusive_context);
 
        kfree(device->name);
-
-       return 0;
 }
 EXPORT_SYMBOL_GPL(rtdm_dev_unregister);
 
diff --git a/kernel/cobalt/rtdm/internal.h b/kernel/cobalt/rtdm/internal.h
index fa728ed..7d52275 100644
--- a/kernel/cobalt/rtdm/internal.h
+++ b/kernel/cobalt/rtdm/internal.h
@@ -23,6 +23,7 @@
 #include <linux/list.h>
 #include <linux/sem.h>
 #include <linux/mutex.h>
+#include <linux/atomic.h>
 #include <cobalt/kernel/ppd.h>
 #include <cobalt/kernel/tree.h>
 #include <rtdm/driver.h>
@@ -42,21 +43,12 @@ extern struct semaphore nrt_dev_lock;
 extern struct list_head rtdm_named_devices;
 extern struct rb_root rtdm_protocol_devices;
 
-static inline void rtdm_dereference_device(struct rtdm_device *device)
+static inline void __rtdm_get_device(struct rtdm_device *device)
 {
-       atomic_dec(&device->refcount);
+       atomic_inc(&device->refcount);
 }
 
-int __init rtdm_dev_init(void);
-void rtdm_dev_cleanup(void);
-
-#ifdef CONFIG_XENO_OPT_VFILE
-int rtdm_proc_init(void);
-void rtdm_proc_cleanup(void);
-#else
-static inline int rtdm_proc_init(void) { return 0; }
-static void inline rtdm_proc_cleanup(void) { }
-#endif
+void __rtdm_put_device(struct rtdm_device *device);
 
 void __rt_dev_close(struct rtdm_fd *fd);
 
@@ -76,4 +68,16 @@ int rtdm_init(void);
 
 void rtdm_cleanup(void);
 
+#ifdef CONFIG_XENO_OPT_VFILE
+int rtdm_proc_init(void);
+void rtdm_proc_cleanup(void);
+#else
+static inline int rtdm_proc_init(void) { return 0; }
+static void inline rtdm_proc_cleanup(void) { }
+#endif
+
+int __init rtdm_dev_init(void);
+
+void rtdm_dev_cleanup(void);
+
 #endif /* _RTDM_INTERNAL_H */
diff --git a/kernel/cobalt/trace/cobalt-rtdm.h 
b/kernel/cobalt/trace/cobalt-rtdm.h
index ab7291d..b1e7289 100644
--- a/kernel/cobalt/trace/cobalt-rtdm.h
+++ b/kernel/cobalt/trace/cobalt-rtdm.h
@@ -176,23 +176,21 @@ TRACE_EVENT(cobalt_device_register,
 );
 
 TRACE_EVENT(cobalt_device_unregister,
-       TP_PROTO(struct rtdm_device *device, unsigned int poll_delay),
-       TP_ARGS(device, poll_delay),
+       TP_PROTO(struct rtdm_device *device),
+       TP_ARGS(device),
 
        TP_STRUCT__entry(
                __field(struct rtdm_device *, device)
                __string(device_name, device->name)
-               __field(unsigned int, poll_delay)
        ),
 
        TP_fast_assign(
                __entry->device = device;
                __assign_str(device_name, device->name);
-               __entry->poll_delay = poll_delay;
        ),
 
-       TP_printk("device %s=%p poll_delay=%u",
-                 __get_str(device_name), __entry->device, __entry->poll_delay)
+       TP_printk("device %s=%p",
+                 __get_str(device_name), __entry->device)
 );
 
 DEFINE_EVENT(fd_event, cobalt_fd_created,
diff --git a/kernel/drivers/analogy/rtdm_interface.c 
b/kernel/drivers/analogy/rtdm_interface.c
index fcabb81..9af877e 100644
--- a/kernel/drivers/analogy/rtdm_interface.c
+++ b/kernel/drivers/analogy/rtdm_interface.c
@@ -258,7 +258,7 @@ int a4l_register(void)
        return 0;
 fail:
        while (i-- > 0)
-               rtdm_dev_unregister(rtdm_devs + i, 0);
+               rtdm_dev_unregister(rtdm_devs + i);
 
        return ret;
 }
@@ -267,7 +267,7 @@ void a4l_unregister(void)
 {
        int i;
        for (i = 0; i < A4L_NB_DEVICES; i++)
-               rtdm_dev_unregister(&(rtdm_devs[i]), 1000);
+               rtdm_dev_unregister(&(rtdm_devs[i]));
 }
 
 static int __init a4l_init(void)
diff --git a/kernel/drivers/can/rtcan_raw.c b/kernel/drivers/can/rtcan_raw.c
index 01d026f..055e75f 100644
--- a/kernel/drivers/can/rtcan_raw.c
+++ b/kernel/drivers/can/rtcan_raw.c
@@ -1008,7 +1008,7 @@ int __init rtcan_raw_proto_register(void)
 
 void __exit rtcan_raw_proto_unregister(void)
 {
-    rtdm_dev_unregister(&rtcan_device, 1000);
+    rtdm_dev_unregister(&rtcan_device);
 }
 
 
diff --git a/kernel/drivers/ipc/rtipc.c b/kernel/drivers/ipc/rtipc.c
index 36c3d2a..83808cc 100644
--- a/kernel/drivers/ipc/rtipc.c
+++ b/kernel/drivers/ipc/rtipc.c
@@ -313,7 +313,7 @@ void __exit __rtipc_exit(void)
        if (!realtime_core_enabled())
                return;
 
-       rtdm_dev_unregister(&device, 1000);
+       rtdm_dev_unregister(&device);
 
        for (n = 0; n < IPCPROTO_MAX; n++) {
                if (protocols[n] && protocols[n]->proto_exit)
diff --git a/kernel/drivers/serial/16550A.c b/kernel/drivers/serial/16550A.c
index c1b9381..004e5a1 100644
--- a/kernel/drivers/serial/16550A.c
+++ b/kernel/drivers/serial/16550A.c
@@ -1170,7 +1170,7 @@ void rt_16550_exit(void)
 
        for (i = 0; i < MAX_DEVICES; i++)
                if (device[i]) {
-                       rtdm_dev_unregister(device[i], 1000);
+                       rtdm_dev_unregister(device[i]);
                        rt_16550_release_io(i);
                        kfree(device[i]);
                }
diff --git a/kernel/drivers/serial/mpc52xx_uart.c 
b/kernel/drivers/serial/mpc52xx_uart.c
index a633b1a..2a75707 100644
--- a/kernel/drivers/serial/mpc52xx_uart.c
+++ b/kernel/drivers/serial/mpc52xx_uart.c
@@ -1365,7 +1365,7 @@ static int rt_mpc52xx_uart_of_remove(struct 
platform_device *op)
 
        dev_set_drvdata(&op->dev, NULL);
 
-       rtdm_dev_unregister(dev, 1000);
+       rtdm_dev_unregister(dev);
        irq_dispose_mapping(port->irq);
        iounmap(port->psc);
        if (!of_address_to_resource(op->dev.of_node, 0, &res))
diff --git a/kernel/drivers/serial/rt_imx_uart.c 
b/kernel/drivers/serial/rt_imx_uart.c
index dd99703..d01139f 100644
--- a/kernel/drivers/serial/rt_imx_uart.c
+++ b/kernel/drivers/serial/rt_imx_uart.c
@@ -1488,7 +1488,7 @@ static int rt_imx_uart_remove(struct platform_device 
*pdev)
        pdata = pdev->dev.platform_data;
        platform_set_drvdata(pdev, NULL);
 
-       rtdm_dev_unregister(dev, 1000);
+       rtdm_dev_unregister(dev);
 
        if (port->clk) {
                clk_put(port->clk);
diff --git a/kernel/drivers/testing/rtdmtest.c 
b/kernel/drivers/testing/rtdmtest.c
index b62c70d..1510d80 100644
--- a/kernel/drivers/testing/rtdmtest.c
+++ b/kernel/drivers/testing/rtdmtest.c
@@ -141,7 +141,7 @@ static int __init __rtdm_test_init(void)
        return 0;
 fail:
        while (i-- > 0)
-               rtdm_dev_unregister(device + i, 1000);
+               rtdm_dev_unregister(device + i);
 
        return ret;
 }
@@ -151,7 +151,7 @@ static void __exit __rtdm_test_exit(void)
        int i;
 
        for (i = 0; i < ARRAY_SIZE(device); i++)
-               rtdm_dev_unregister(device + i, 1000);
+               rtdm_dev_unregister(device + i);
 }
 
 module_init(__rtdm_test_init);
diff --git a/kernel/drivers/testing/switchtest.c 
b/kernel/drivers/testing/switchtest.c
index e4db1b9..1a71126 100644
--- a/kernel/drivers/testing/switchtest.c
+++ b/kernel/drivers/testing/switchtest.c
@@ -753,7 +753,7 @@ void __switchtest_exit(void)
        if (!realtime_core_enabled())
                return;
 
-       rtdm_dev_unregister(&device, 1000);
+       rtdm_dev_unregister(&device);
 }
 
 module_init(__switchtest_init);
diff --git a/kernel/drivers/testing/timerbench.c 
b/kernel/drivers/testing/timerbench.c
index 767533a..4cd02cd 100644
--- a/kernel/drivers/testing/timerbench.c
+++ b/kernel/drivers/testing/timerbench.c
@@ -484,7 +484,7 @@ static void __timerbench_exit(void)
        if (!realtime_core_enabled())
                return;
 
-       rtdm_dev_unregister(&device, 1000);
+       rtdm_dev_unregister(&device);
 }
 
 module_init(__timerbench_init);
diff --git a/kernel/drivers/udd/udd.c b/kernel/drivers/udd/udd.c
index f201f14..6e5dd83 100644
--- a/kernel/drivers/udd/udd.c
+++ b/kernel/drivers/udd/udd.c
@@ -309,7 +309,7 @@ static inline int register_mapper(struct udd_device *udd)
  *
  * This routine registers a mini-driver at the UDD core.
  *
- * @param udd The @ref udd_device "UDD device descriptor" which should
+ * @param udd @ref udd_device "UDD device descriptor" which should
  * describe the new device properties.
  *
  * @return Zero is returned upon success, otherwise a negative error
@@ -398,9 +398,9 @@ int udd_register_device(struct udd_device *udd)
        return 0;
 
 fail_irq_request:
-       rtdm_dev_unregister(&ur->mapper, 0);
+       rtdm_dev_unregister(&ur->mapper);
 fail_mapper:
-       rtdm_dev_unregister(dev, 0);
+       rtdm_dev_unregister(dev);
        if (ur->mapper_name)
                kfree(ur->mapper_name);
 
@@ -411,22 +411,18 @@ EXPORT_SYMBOL_GPL(udd_register_device);
 /**
  * @brief Unregister a UDD device
  *
- * This routine unregisters a mini-driver from the UDD core.
+ * This routine unregisters a mini-driver from the UDD core. This
+ * routine waits until all connections to @a udd have been closed
+ * prior to unregistering.
  *
- * @param udd The UDD device descriptor
+ * @param udd UDD device descriptor
  *
- * @param poll_delay Polling delay in milliseconds to check repeatedly
- * for open instances of @a udd, or 0 for non-blocking mode.
- *
- * @return Zero is returned upon success, otherwise a negative error
- * code is received, from the set of error codes defined by
- * rtdm_dev_unregister(). In addition, -ENXIO can be received if this
- * service is called while the Cobalt kernel is disabled.
+ * @return Zero is returned upon success, otherwise -ENXIO is received
+ * if this service is called while the Cobalt kernel is disabled.
  *
  * @coretags{secondary-only}
  */
-int udd_unregister_device(struct udd_device *udd,
-                         unsigned int poll_delay)
+int udd_unregister_device(struct udd_device *udd)
 {
        struct udd_reserved *ur = &udd->__reserved;
 
@@ -438,12 +434,14 @@ int udd_unregister_device(struct udd_device *udd,
        if (udd->irq != UDD_IRQ_NONE && udd->irq != UDD_IRQ_CUSTOM)
                rtdm_irq_free(&ur->irqh);
 
-       rtdm_dev_unregister(&ur->mapper, poll_delay);
+       rtdm_dev_unregister(&ur->mapper);
 
        if (ur->mapper_name)
                kfree(ur->mapper_name);
 
-       return rtdm_dev_unregister(&ur->device, poll_delay);
+       rtdm_dev_unregister(&ur->device);
+
+       return 0;
 }
 EXPORT_SYMBOL_GPL(udd_unregister_device);
 
@@ -458,7 +456,7 @@ EXPORT_SYMBOL_GPL(udd_unregister_device);
  * As a result, the UDD core wakes up any Cobalt thread waiting for
  * interrupts on the device via a read(2) or select(2) call.
  *
- * @param udd The UDD device descriptor receiving the IRQ.
+ * @param udd UDD device descriptor receiving the IRQ.
  *
  * @coretags{coreirq-only}
  *
@@ -532,7 +530,7 @@ static void switch_irq_line(int irq, int enable)
  * request is scheduled but deferred until the current CPU leaves the
  * real-time domain. Otherwise, the request is immediately handled.
  *
- * @param irq The IRQ line to enable.
+ * @param irq IRQ line to enable.
  *
  * @coretags{unrestricted}
  *
@@ -554,13 +552,13 @@ EXPORT_SYMBOL_GPL(udd_post_irq_enable);
  * request is scheduled but deferred until the current CPU leaves the
  * real-time domain. Otherwise, the request is immediately handled.
  *
- * @param irq The IRQ line to enable.
+ * @param irq IRQ line to disable.
  *
  * @coretags{unrestricted}
  *
  * @note The deferral is required as some interrupt management code
- * involved in disable interrupt lines may not be safely executed from
- * primary mode.
+ * involved in disabling interrupt lines may not be safely executed
+ * from primary mode.
  */
 void udd_post_irq_disable(int irq)
 {
@@ -569,9 +567,11 @@ void udd_post_irq_disable(int irq)
 EXPORT_SYMBOL_GPL(udd_post_irq_disable);
 
 /**
- * @brief Retrieve the UDD device descriptor from a file descriptor
+ * @brief RTDM file descriptor to target UDD device
+ *
+ * Retrieves the UDD device from a RTDM file descriptor.
  *
- * @param fd The file descriptor received by an ancillary I/O handler
+ * @param fd File descriptor received by an ancillary I/O handler
  * from a mini-driver based on the UDD core.
  *
  * @return A pointer to the UDD device to which @a fd refers to.


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

Reply via email to