From 570b010119e94226ecd6cf722a7a45d9861685b8 Mon Sep 17 00:00:00 2001
From: Florian Pose <fp@igh-essen.com>
Date: Wed, 8 Aug 2007 13:58:24 +0000
Subject: [PATCH] Changed names of debug interfaces.

---
 master/debug.c  |  7 +++++--
 master/debug.h  |  2 +-
 master/device.c | 14 +++++++++++++-
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/master/debug.c b/master/debug.c
index 98c0f2c3..99b45612 100644
--- a/master/debug.c
+++ b/master/debug.c
@@ -59,7 +59,10 @@ struct net_device_stats *ec_dbgdev_stats(struct net_device *);
    Initializes the debug object, creates a net_device and registeres it.
 */
 
-int ec_debug_init(ec_debug_t *dbg /**< debug object */)
+int ec_debug_init(
+        ec_debug_t *dbg, /**< debug object */
+        const char *name /**< interface name */
+        )
 {
     int result;
 
@@ -67,7 +70,7 @@ int ec_debug_init(ec_debug_t *dbg /**< debug object */)
     memset(&dbg->stats, 0, sizeof(struct net_device_stats));
 
     if (!(dbg->dev =
-          alloc_netdev(sizeof(ec_debug_t *), "ec%d", ether_setup))) {
+          alloc_netdev(sizeof(ec_debug_t *), name, ether_setup))) {
         EC_ERR("Unable to allocate net_device for debug object!\n");
         goto out_return;
     }
diff --git a/master/debug.h b/master/debug.h
index df5ce231..bf8ad278 100644
--- a/master/debug.h
+++ b/master/debug.h
@@ -56,7 +56,7 @@ ec_debug_t;
 
 /*****************************************************************************/
 
-int ec_debug_init(ec_debug_t *);
+int ec_debug_init(ec_debug_t *, const char *);
 void ec_debug_clear(ec_debug_t *);
 void ec_debug_send(ec_debug_t *, const uint8_t *, size_t);
 
diff --git a/master/device.c b/master/device.c
index 47fa8c03..301057c1 100644
--- a/master/device.c
+++ b/master/device.c
@@ -57,10 +57,22 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT device */
         ec_master_t *master /**< master owning the device */
         )
 {
+#ifdef EC_DEBUG_IF
+    char ifname[10];
+    char mb = 'x';
+#endif
+
     device->master = master;
 
 #ifdef EC_DEBUG_IF
-    if (ec_debug_init(&device->dbg)) {
+    if (device == &master->main_device)
+        mb = 'm';
+    else if (device == &master->backup_device)
+        mb = 'b';
+
+    sprintf(ifname, "ecdbg%c%u", mb, master->index);
+
+    if (ec_debug_init(&device->dbg, ifname)) {
         EC_ERR("Failed to init debug device!\n");
         goto out_return;
     }
-- 
GitLab