Intermediate state while updating master's RTDM part to Xenomai 3 stable-1.5
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sun, 08 Jul 2018 13:40:31 +0200
branchstable-1.5
changeset 2700 93ef210e9b56
parent 2699 ed6b9e0d7c05
child 2701 00a6a77face6
Intermediate state while updating master's RTDM part to Xenomai 3
master/Kbuild.in
master/rtdm.c
--- a/master/Kbuild.in	Sun Jul 08 13:33:09 2018 +0200
+++ b/master/Kbuild.in	Sun Jul 08 13:40:31 2018 +0200
@@ -85,7 +85,7 @@
 ec_master-objs += rtdm.o
 
 ifeq (@ENABLE_XENOMAI@, 1)
-CFLAGS_rtdm.o := -I@XENOMAI_DIR@/include
+CFLAGS_rtdm.o := -I@XENOMAI_DIR@/include/xenomai
 endif
 
 ifeq (@ENABLE_RTAI@, 1)
--- a/master/rtdm.c	Sun Jul 08 13:33:09 2018 +0200
+++ b/master/rtdm.c	Sun Jul 08 13:40:31 2018 +0200
@@ -34,7 +34,7 @@
 #include <linux/slab.h>
 #include <linux/mman.h>
 
-#include <rtdm/rtdm_driver.h>
+#include <rtdm/driver.h>
 
 #include "master.h"
 #include "ioctl.h"
@@ -62,6 +62,22 @@
 
 /****************************************************************************/
 
+static struct rtdm_driver ec_rtdm_driver = {
+	.profile_info		=	RTDM_PROFILE_INFO(foo,
+							  RTDM_CLASS_EXPERIMENTAL,
+							  222,
+							  1),
+	.device_flags		=	RTDM_NAMED_DEVICE,
+	.device_count		=	1,
+	.context_size		=	sizeof(ec_rtdm_context_t).
+	.ops = {
+        .open      = ec_rtdm_open;
+        .close_nrt = ec_rtdm_close,
+        .ioctl_rt  = ec_rtdm_ioctl,
+        .ioctl_nrt = ec_rtdm_ioctl
+	},
+};
+
 /** Initialize an RTDM device.
  *
  * \return Zero on success, otherwise a negative error code.
@@ -73,6 +89,8 @@
 {
     int ret;
 
+    MODULE_VERSION
+
     rtdm_dev->master = master;
 
     rtdm_dev->dev = kzalloc(sizeof(struct rtdm_device), GFP_KERNEL);
@@ -80,31 +98,28 @@
         EC_MASTER_ERR(master, "Failed to reserve memory for RTDM device.\n");
         return -ENOMEM;
     }
-
-    rtdm_dev->dev->struct_version = RTDM_DEVICE_STRUCT_VER;
-    rtdm_dev->dev->device_flags = RTDM_NAMED_DEVICE;
-    rtdm_dev->dev->context_size = sizeof(ec_rtdm_context_t);
-    snprintf(rtdm_dev->dev->device_name, RTDM_MAX_DEVNAME_LEN,
+    
+    rtdm_dev->dev->label = kzalloc(RTDM_MAX_DEVNAME_LEN+1, GFP_KERNEL);
+    if (!rtdm_dev->dev->label) {
+        EC_MASTER_ERR(master, "Failed to reserve memory for RTDM device name.\n");
+        return -ENOMEM;
+        kfree(rtdm_dev->dev);
+    }
+    
+
+    rtdm_dev->dev->driver = &ec_rtdm_driver;
+    snprintf(rtdm_dev->dev->label, RTDM_MAX_DEVNAME_LEN,
             "EtherCAT%u", master->index);
-    rtdm_dev->dev->open_nrt = ec_rtdm_open;
-    rtdm_dev->dev->ops.close_nrt = ec_rtdm_close;
-    rtdm_dev->dev->ops.ioctl_rt = ec_rtdm_ioctl;
-    rtdm_dev->dev->ops.ioctl_nrt = ec_rtdm_ioctl;
-    rtdm_dev->dev->device_class = RTDM_CLASS_EXPERIMENTAL;
-    rtdm_dev->dev->device_sub_class = 222;
-    rtdm_dev->dev->driver_name = "EtherCAT";
-    rtdm_dev->dev->driver_version = RTDM_DRIVER_VER(1, 0, 2);
-    rtdm_dev->dev->peripheral_name = rtdm_dev->dev->device_name;
-    rtdm_dev->dev->provider_name = "EtherLab Community";
-    rtdm_dev->dev->proc_name = rtdm_dev->dev->device_name;
     rtdm_dev->dev->device_data = rtdm_dev; /* pointer to parent */
 
+
     EC_MASTER_INFO(master, "Registering RTDM device %s.\n",
             rtdm_dev->dev->driver_name);
     ret = rtdm_dev_register(rtdm_dev->dev);
     if (ret) {
         EC_MASTER_ERR(master, "Initialization of RTDM interface failed"
                 " (return value %i).\n", ret);
+        kfree(rtdm_dev->dev->label);
         kfree(rtdm_dev->dev);
     }
 
@@ -122,13 +137,14 @@
     int ret;
 
     EC_MASTER_INFO(rtdm_dev->master, "Unregistering RTDM device %s.\n",
-            rtdm_dev->dev->driver_name);
+            rtdm_dev->dev->label);
     ret = rtdm_dev_unregister(rtdm_dev->dev, 1000 /* poll delay [ms] */);
     if (ret < 0) {
         EC_MASTER_WARN(rtdm_dev->master,
                 "Failed to unregister RTDM device (code %i).\n", ret);
     }
 
+    kfree(rtdm_dev->dev->label);
     kfree(rtdm_dev->dev);
 }