Module: xenomai-3
Branch: stable-3.0.x
Commit: be819d77a0e0651a75e9d671844a0dffee8086ea
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be819d77a0e0651a75e9d671844a0dffee8086ea

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Jul  8 10:02:51 2016 +0200

drivers/testing: add test helpers for mode switch handover

---

 include/rtdm/uapi/testing.h       |    9 +++++++++
 kernel/drivers/testing/rtdmtest.c |   33 +++++++++++++++++++++++++++------
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/include/rtdm/uapi/testing.h b/include/rtdm/uapi/testing.h
index 5fddfae..06b8f1e 100644
--- a/include/rtdm/uapi/testing.h
+++ b/include/rtdm/uapi/testing.h
@@ -84,6 +84,9 @@ struct rttst_swtest_error {
 #define RTTST_RTDM_NORMAL_CLOSE                0
 #define RTTST_RTDM_DEFER_CLOSE_CONTEXT 1
 
+#define RTTST_RTDM_MAGIC_PRIMARY       0xfefbfefb
+#define RTTST_RTDM_MAGIC_SECONDARY     0xa5b9a5b9
+
 #define RTIOC_TYPE_TESTING             RTDM_CLASS_TESTING
 
 /*!
@@ -145,6 +148,12 @@ struct rttst_swtest_error {
 #define RTTST_RTIOC_RTDM_ACTOR_GET_CPU \
        _IOR(RTIOC_TYPE_TESTING, 0x41, __u32)
   
+#define RTTST_RTIOC_RTDM_PING_PRIMARY \
+       _IOR(RTIOC_TYPE_TESTING, 0x42, __u32)
+  
+#define RTTST_RTIOC_RTDM_PING_SECONDARY \
+       _IOR(RTIOC_TYPE_TESTING, 0x43, __u32)
+  
 /** @} */
 
 #endif /* !_RTDM_UAPI_TESTING_H */
diff --git a/kernel/drivers/testing/rtdmtest.c 
b/kernel/drivers/testing/rtdmtest.c
index 5c705e6..bd1ae6b 100644
--- a/kernel/drivers/testing/rtdmtest.c
+++ b/kernel/drivers/testing/rtdmtest.c
@@ -87,11 +87,28 @@ static void rtdm_basic_close(struct rtdm_fd *fd)
        rtdm_timer_destroy(&ctx->close_timer);
 }
 
-static int rtdm_basic_ioctl(struct rtdm_fd *fd,
+static int rtdm_basic_ioctl_rt(struct rtdm_fd *fd,
+                           unsigned int request, void __user *arg)
+{
+       int ret, magic = RTTST_RTDM_MAGIC_PRIMARY;
+
+       switch (request) {
+       case RTTST_RTIOC_RTDM_PING_PRIMARY:
+               ret = rtdm_safe_copy_to_user(fd, arg, &magic,
+                                            sizeof(magic));
+               break;
+       default:
+               ret = -ENOSYS;
+       }
+
+       return ret;
+}
+
+static int rtdm_basic_ioctl_nrt(struct rtdm_fd *fd,
                            unsigned int request, void __user *arg)
 {
        struct rtdm_basic_context *ctx = rtdm_fd_to_private(fd);
-       int err = 0;
+       int ret = 0, magic = RTTST_RTDM_MAGIC_SECONDARY;
 
        switch (request) {
        case RTTST_RTIOC_RTDM_DEFER_CLOSE:
@@ -103,11 +120,15 @@ static int rtdm_basic_ioctl(struct rtdm_fd *fd,
                                        RTDM_TIMERMODE_RELATIVE);
                }
                break;
+       case RTTST_RTIOC_RTDM_PING_SECONDARY:
+               ret = rtdm_safe_copy_to_user(fd, arg, &magic,
+                                            sizeof(magic));
+               break;
        default:
-               err = -ENOTTY;
+               ret = -ENOTTY;
        }
 
-       return err;
+       return ret;
 }
 
 static void actor_handler(void *arg)
@@ -209,8 +230,8 @@ static struct rtdm_driver rtdm_basic_driver = {
        .ops = {
                .open           = rtdm_basic_open,
                .close          = rtdm_basic_close,
-               .ioctl_rt       = rtdm_basic_ioctl,
-               .ioctl_nrt      = rtdm_basic_ioctl,
+               .ioctl_rt       = rtdm_basic_ioctl_rt,
+               .ioctl_nrt      = rtdm_basic_ioctl_nrt,
        },
 };
 


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

Reply via email to