From 51c949abb89c3cd5133ae325c9ca95575bc9d9c4 Mon Sep 17 00:00:00 2001
From: Florian Pose <fp@igh-essen.com>
Date: Wed, 2 Jul 2008 14:06:10 +0000
Subject: [PATCH] Renamed ecrt_slave_config_sync_managers() to
 ecrt_slave_config_pdos(); Added EC_MAX_SYNC_MANAGERS to ecrt.h.

---
 TODO                        |  4 +--
 examples/mini/mini.c        |  4 +--
 examples/rtai/rtai_sample.c |  4 +--
 include/ecrt.h              | 65 +++++++++++++++++++++----------------
 master/cdev.c               |  6 ++--
 master/fsm_coe_map.c        |  2 +-
 master/fsm_pdo_assign.c     |  2 +-
 master/fsm_pdo_mapping.c    |  2 +-
 master/globals.h            |  3 --
 master/ioctl.h              |  7 ++--
 master/master.c             |  5 +--
 master/slave.c              |  2 +-
 master/slave_config.c       | 26 +++++++--------
 master/slave_config.h       |  2 +-
 tools/Master.cpp            |  2 +-
 15 files changed, 73 insertions(+), 63 deletions(-)

diff --git a/TODO b/TODO
index 73f53618..755b66d4 100644
--- a/TODO
+++ b/TODO
@@ -8,8 +8,6 @@ $Id$
 
 Version 1.4.0:
 
-* Race in jiffies frame timeout.
-* Move EC_NUM_SYNCS define to ecrt.h.
 * Read Pdo mapping for unknown Pdos before configuring them.
 * Attach Pdo names from SII or Coe dictioary to Pdos read via CoE.
 * Make scanning and configuration run parallel (each).
@@ -21,6 +19,8 @@ Version 1.4.0:
 * Allow master requesting when in ORPHANED phase
 * Get original driver for r8169.
 * Distributed clocks.
+* Fix datagram errors on application loading/unloading.
+* Race in jiffies frame timeout?
 
 Future issues:
 
diff --git a/examples/mini/mini.c b/examples/mini/mini.c
index f0201dfb..6f2abbe8 100644
--- a/examples/mini/mini.c
+++ b/examples/mini/mini.c
@@ -320,7 +320,7 @@ int __init init_mini_module(void)
 
 #ifdef CONFIGURE_PDOS
     printk(KERN_INFO PFX "Configuring Pdos...\n");
-    if (ecrt_slave_config_sync_managers(sc_ana_in, EC_END, el3162_syncs)) {
+    if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3162_syncs)) {
         printk(KERN_ERR PFX "Failed to configure Pdos.\n");
         goto out_release_master;
     }
@@ -331,7 +331,7 @@ int __init init_mini_module(void)
         goto out_release_master;
     }
 
-    if (ecrt_slave_config_sync_managers(sc, EC_END, el2004_syncs)) {
+    if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
         printk(KERN_ERR PFX "Failed to configure Pdos.\n");
         goto out_release_master;
     }
diff --git a/examples/rtai/rtai_sample.c b/examples/rtai/rtai_sample.c
index fe0f5881..5bea59b6 100644
--- a/examples/rtai/rtai_sample.c
+++ b/examples/rtai/rtai_sample.c
@@ -300,7 +300,7 @@ int __init init_mod(void)
 
 #ifdef CONFIGURE_PDOS
     printk(KERN_INFO PFX "Configuring Pdos...\n");
-    if (ecrt_slave_config_sync_managers(sc_ana_in, EC_END, el3162_syncs)) {
+    if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3162_syncs)) {
         printk(KERN_ERR PFX "Failed to configure Pdos.\n");
         goto out_release_master;
     }
@@ -310,7 +310,7 @@ int __init init_mod(void)
         goto out_release_master;
     }
 
-    if (ecrt_slave_config_sync_managers(sc, EC_END, el2004_syncs)) {
+    if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
         printk(KERN_ERR PFX "Failed to configure Pdos.\n");
         goto out_release_master;
     }
diff --git a/include/ecrt.h b/include/ecrt.h
index 2c5b7244..007ae90d 100644
--- a/include/ecrt.h
+++ b/include/ecrt.h
@@ -125,12 +125,16 @@
 
 /*****************************************************************************/
 
-/** End of the Pdo entry list.
+/** End of list marker.
  *
- * This is used in ecrt_slave_config_pdos().
+ * This can be used with ecrt_slave_config_pdos().
  */
 #define EC_END ~0U
 
+/** Maximum number of sync managers per slave.
+ */
+#define EC_MAX_SYNC_MANAGERS 16
+
 /******************************************************************************
  * Data types 
  *****************************************************************************/
@@ -232,7 +236,7 @@ typedef enum {
  *
  * This is the data type of the \a entries field in ec_pdo_info_t.
  *
- * \see ecrt_slave_config_sync_managers().
+ * \see ecrt_slave_config_pdos().
  */
 typedef struct {
     uint16_t index; /**< Pdo entry index. */
@@ -246,11 +250,11 @@ typedef struct {
  * 
  * This is the data type of the \a pdos field in ec_sync_info_t.
  * 
- * \see ecrt_slave_config_sync_managers().
+ * \see ecrt_slave_config_pdos().
  */
 typedef struct {
     uint16_t index; /**< Pdo index. */
-    uint8_t n_entries; /**< Number of Pdo entries in \a entries to map.
+    unsigned int n_entries; /**< Number of Pdo entries in \a entries to map.
                               Zero means, that the default mapping shall be
                               used (this can only be done if the slave is
                               present at bus configuration time). */
@@ -265,12 +269,12 @@ typedef struct {
  *
  * This can be use to configure multiple sync managers including the Pdo
  * assignment and Pdo mapping. It is used as an input parameter type in
- * ecrt_slave_config_sync_managers().
+ * ecrt_slave_config_pdos().
  */
 typedef struct {
     uint8_t index; /**< Sync manager index. */
     ec_direction_t dir; /**< Sync manager direction. */
-    uint16_t n_pdos; /**< Number of Pdos in \a pdos. */
+    unsigned int n_pdos; /**< Number of Pdos in \a pdos. */
     ec_pdo_info_t *pdos; /**< Array with Pdos to assign. This must contain
                             at least \a n_pdos Pdos. */
 } ec_sync_info_t;
@@ -447,20 +451,21 @@ void ecrt_master_state(
 
 /** Configure a sync manager.
  *
- * Sets the direction of a sync manager. The direction bits from the default
- * control register from SII will be overriden, when this function is called.
+ * Sets the direction of a sync manager. This overrides the direction bits
+ * from the default control register from SII.
  *
  * \return zero on success, else non-zero
  */
 int ecrt_slave_config_sync_manager(
         ec_slave_config_t *sc, /**< Slave configuration. */
-        uint8_t sync_index, /**< Sync manager index. */
+        uint8_t sync_index, /**< Sync manager index. Must ba less
+                              than #EC_MAX_SYNC_MANAGERS. */
         ec_direction_t dir /**< Input/Output. */
         );
 
 /** Add a Pdo to a sync manager's Pdo assignment.
  *
- * \see ecrt_slave_config_sync_managers()
+ * \see ecrt_slave_config_pdos()
  * \return zero on success, else non-zero
  */
 int ecrt_slave_config_pdo_assign_add(
@@ -475,7 +480,7 @@ int ecrt_slave_config_pdo_assign_add(
  * ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a
  * sync manager.
  * 
- * \see ecrt_slave_config_sync_managers()
+ * \see ecrt_slave_config_pdos()
  */
 void ecrt_slave_config_pdo_assign_clear(
         ec_slave_config_t *sc, /**< Slave configuration. */
@@ -484,7 +489,7 @@ void ecrt_slave_config_pdo_assign_clear(
 
 /** Add a Pdo entry to the given Pdo's mapping.
  *
- * \see ecrt_slave_config_sync_managers()
+ * \see ecrt_slave_config_pdos()
  * \return zero on success, else non-zero
  */
 int ecrt_slave_config_pdo_mapping_add(
@@ -502,7 +507,7 @@ int ecrt_slave_config_pdo_mapping_add(
  * This can be called before mapping Pdo entries via
  * ecrt_slave_config_pdo_mapping_add(), to clear the default mapping.
  *
- * \see ecrt_slave_config_sync_managers()
+ * \see ecrt_slave_config_pdos()
  */
 void ecrt_slave_config_pdo_mapping_clear(
         ec_slave_config_t *sc, /**< Slave configuration. */
@@ -523,27 +528,30 @@ void ecrt_slave_config_pdo_mapping_clear(
  * configuration time:
  *
  * \code
- * const ec_pdo_entry_info_t el3162_channel1[] = {
+ * ec_pdo_entry_info_t el3162_channel1[] = {
  *     {0x3101, 1,  8}, // status
  *     {0x3101, 2, 16}  // value
  * };
  * 
- * const ec_pdo_entry_info_t el3162_channel2[] = {
+ * ec_pdo_entry_info_t el3162_channel2[] = {
  *     {0x3102, 1,  8}, // status
  *     {0x3102, 2, 16}  // value
  * };
  * 
- * const ec_pdo_info_t el3162_pdos[] = {
+ * ec_pdo_info_t el3162_pdos[] = {
  *     {0x1A00, 2, el3162_channel1},
- *     {0x1A01, 2, el3162_channel2},
+ *     {0x1A01, 2, el3162_channel2}
  * };
  * 
- * const ec_pdo_info_t el3162_syncs[] = {
- *     {2, EC_DIR_INPUT, 2, el3162_el3162_pdos},
+ * ec_sync_info_t el3162_syncs[] = {
+ *     {2, EC_DIR_OUTPUT},
+ *     {3, EC_DIR_INPUT, 2, el3162_pdos},
+ *     {0xff}
  * };
  * 
- * if (ecrt_slave_config_syncs(sc, 1, el3162_syncs))
- *     return -1; // error
+ * if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3162_syncs)) {
+ *     // handle error
+ * }
  * \endcode
  * 
  * The next example shows, how to configure the Pdo assignment only. The
@@ -552,17 +560,18 @@ void ecrt_slave_config_pdo_mapping_clear(
  * configuration is left empty and the slave is offline.
  *
  * \code
- * const ec_pdo_info_t pdos[] = {
+ * ec_pdo_info_t pdos[] = {
  *     {0x1600}, // Channel 1
  *     {0x1601}  // Channel 2
  * };
  * 
- * const ec_sync_info_t syncs[] = {
- *     {2, EC_DIR_INPUT, 2, pdos},
+ * ec_sync_info_t syncs[] = {
+ *     {3, EC_DIR_INPUT, 2, pdos},
  * };
  * 
- * if (ecrt_slave_config_pdos(slave_config_ana_in, 2, syncs))
- *     return -1; // error
+ * if (ecrt_slave_config_pdos(slave_config_ana_in, 1, syncs)) {
+ *     // handle error
+ * }
  * \endcode
  *
  * Processing of \a syncs will stop, if
@@ -573,7 +582,7 @@ void ecrt_slave_config_pdo_mapping_clear(
  *
  * \return zero on success, else non-zero
  */
-int ecrt_slave_config_sync_managers(
+int ecrt_slave_config_pdos(
         ec_slave_config_t *sc, /**< Slave configuration. */
         unsigned int n_syncs, /**< Number of sync manager configurations in
                                 \a syncs. */
diff --git a/master/cdev.c b/master/cdev.c
index 89533757..345de815 100644
--- a/master/cdev.c
+++ b/master/cdev.c
@@ -1000,7 +1000,7 @@ int ec_cdev_ioctl_config(
     data.position = sc->position;
     data.vendor_id = sc->vendor_id;
     data.product_code = sc->product_code;
-    for (i = 0; i < EC_MAX_SYNCS; i++) {
+    for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++) {
         data.syncs[i].dir = sc->sync_configs[i].dir;
         data.syncs[i].pdo_count =
             ec_pdo_list_count(&sc->sync_configs[i].pdos);
@@ -1035,7 +1035,7 @@ int ec_cdev_ioctl_config_pdo(
         return -EFAULT;
     }
 
-    if (data.sync_index >= EC_MAX_SYNCS) {
+    if (data.sync_index >= EC_MAX_SYNC_MANAGERS) {
         EC_ERR("Invalid sync manager index %u!\n",
                 data.sync_index);
         return -EINVAL;
@@ -1095,7 +1095,7 @@ int ec_cdev_ioctl_config_pdo_entry(
         return -EFAULT;
     }
 
-    if (data.sync_index >= EC_MAX_SYNCS) {
+    if (data.sync_index >= EC_MAX_SYNC_MANAGERS) {
         EC_ERR("Invalid sync manager index %u!\n",
                 data.sync_index);
         return -EINVAL;
diff --git a/master/fsm_coe_map.c b/master/fsm_coe_map.c
index 37a6c007..ec7ceeb9 100644
--- a/master/fsm_coe_map.c
+++ b/master/fsm_coe_map.c
@@ -157,7 +157,7 @@ void ec_fsm_coe_map_action_next_sync(
 
     fsm->sync_index++;
 
-    for (; fsm->sync_index < EC_MAX_SYNCS; fsm->sync_index++) {
+    for (; fsm->sync_index < EC_MAX_SYNC_MANAGERS; fsm->sync_index++) {
         if (!(fsm->sync = ec_slave_get_sync(slave, fsm->sync_index)))
             continue;
 
diff --git a/master/fsm_pdo_assign.c b/master/fsm_pdo_assign.c
index 06ff3744..1448d2cb 100644
--- a/master/fsm_pdo_assign.c
+++ b/master/fsm_pdo_assign.c
@@ -166,7 +166,7 @@ void ec_fsm_pdo_assign_next_sync(
 {
     fsm->sync_index++;
 
-    for (; fsm->sync_index < EC_MAX_SYNCS; fsm->sync_index++) {
+    for (; fsm->sync_index < EC_MAX_SYNC_MANAGERS; fsm->sync_index++) {
         fsm->pdos = &fsm->slave->config->sync_configs[fsm->sync_index].pdos;
         
         if (!(fsm->sync = ec_slave_get_sync(fsm->slave, fsm->sync_index))) {
diff --git a/master/fsm_pdo_mapping.c b/master/fsm_pdo_mapping.c
index 89efe5b7..55ef2abe 100644
--- a/master/fsm_pdo_mapping.c
+++ b/master/fsm_pdo_mapping.c
@@ -165,7 +165,7 @@ void ec_fsm_pdo_mapping_next_pdo(
     const ec_pdo_list_t *pdos;
     const ec_pdo_t *pdo, *assigned_pdo;
     
-    for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++) {
+    for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
         pdos = &fsm->slave->config->sync_configs[sync_index].pdos;
 
         list_for_each_entry(pdo, &pdos->list, list) {
diff --git a/master/globals.h b/master/globals.h
index 07f4723b..c1ea64f4 100644
--- a/master/globals.h
+++ b/master/globals.h
@@ -93,9 +93,6 @@
 /** Maximum number of slave ports. */
 #define EC_MAX_PORTS 4
 
-/** Maximum number of sync managers per slave. */
-#define EC_MAX_SYNCS 16
-
 /** Size of a sync manager configuration page. */
 #define EC_SYNC_PAGE_SIZE 8
 
diff --git a/master/ioctl.h b/master/ioctl.h
index d22d37c4..a170f96c 100644
--- a/master/ioctl.h
+++ b/master/ioctl.h
@@ -47,6 +47,8 @@
 
 /*****************************************************************************/
 
+/** \cond */
+
 #define EC_IOCTL_TYPE 0xa4
 
 #define EC_IO(nr)           _IO(EC_IOCTL_TYPE, nr)
@@ -294,11 +296,10 @@ typedef struct {
     struct {
         ec_direction_t dir;
         uint32_t pdo_count;
-    } syncs[16];
+    } syncs[EC_MAX_SYNC_MANAGERS];
     uint32_t sdo_count;
     uint8_t attached    : 1,
             operational : 1;
-    
 } ec_ioctl_config_t;
 
 /*****************************************************************************/
@@ -347,4 +348,6 @@ typedef struct {
 
 /*****************************************************************************/
 
+/** \endcond */
+
 #endif
diff --git a/master/master.c b/master/master.c
index 64ff627a..01be6618 100644
--- a/master/master.c
+++ b/master/master.c
@@ -1122,6 +1122,9 @@ unsigned int ec_master_domain_count(
 
 /*****************************************************************************/
 
+/** Common implementation for ec_master_find_domain() and
+ * ec_master_find_domain_const().
+ */
 #define EC_FIND_DOMAIN \
     do { \
         list_for_each_entry(domain, &master->domains, list) { \
@@ -1142,8 +1145,6 @@ ec_domain_t *ec_master_find_domain(
     EC_FIND_DOMAIN;
 }
 
-/*****************************************************************************/
-
 const ec_domain_t *ec_master_find_domain_const(
 		const ec_master_t *master, /**< EtherCAT master. */
 		unsigned int index /**< Domain index. */
diff --git a/master/slave.c b/master/slave.c
index c6d929f9..f486ac88 100644
--- a/master/slave.c
+++ b/master/slave.c
@@ -365,7 +365,7 @@ int ec_slave_fetch_sii_syncs(
 
     if (count) {
         total_count = count + slave->sii.sync_count;
-        if (total_count > EC_MAX_SYNCS) {
+        if (total_count > EC_MAX_SYNC_MANAGERS) {
             EC_ERR("Exceeded maximum number of sync managers!\n");
             return -1;
         }
diff --git a/master/slave_config.c b/master/slave_config.c
index dd73366e..7393e2fc 100644
--- a/master/slave_config.c
+++ b/master/slave_config.c
@@ -70,7 +70,7 @@ void ec_slave_config_init(
     sc->product_code = product_code;
     sc->slave = NULL;
 
-    for (i = 0; i < EC_MAX_SYNCS; i++)
+    for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
         ec_sync_config_init(&sc->sync_configs[i]);
 
     INIT_LIST_HEAD(&sc->sdo_configs);
@@ -95,7 +95,7 @@ void ec_slave_config_clear(
     ec_slave_config_detach(sc);
 
     // Free sync managers
-    for (i = 0; i < EC_MAX_SYNCS; i++)
+    for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
         ec_sync_config_clear(&sc->sync_configs[i]);
 
     // free all Sdo configurations
@@ -242,7 +242,7 @@ void ec_slave_config_load_default_sync_config(ec_slave_config_t *sc)
     if (!sc->slave)
         return;
     
-    for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++) {
+    for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
         sync_config = &sc->sync_configs[sync_index];
         if ((sync = ec_slave_get_sync(sc->slave, sync_index))) {
             sync_config->dir = ec_sync_default_direction(sync);
@@ -361,7 +361,7 @@ int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, uint8_t sync_index,
         EC_DBG("ecrt_slave_config_sync_manager(sc = 0x%x, sync_index = %u, "
                 "dir = %u)\n", (u32) sc, sync_index, dir);
 
-    if (sync_index >= EC_MAX_SYNCS) {
+    if (sync_index >= EC_MAX_SYNC_MANAGERS) {
         EC_ERR("Invalid sync manager index %u!\n", sync_index);
         return -1;
     }
@@ -387,7 +387,7 @@ int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc,
         EC_DBG("ecrt_slave_config_pdo_assign_add(sc = 0x%x, sync_index = %u, "
                 "pdo_index = 0x%04X)\n", (u32) sc, sync_index, pdo_index);
 
-    if (sync_index >= EC_MAX_SYNCS) {
+    if (sync_index >= EC_MAX_SYNC_MANAGERS) {
         EC_ERR("Invalid sync manager index %u!\n", sync_index);
         return -1;
     }
@@ -416,7 +416,7 @@ void ecrt_slave_config_pdo_assign_clear(ec_slave_config_t *sc,
         EC_DBG("ecrt_slave_config_pdo_assign_clear(sc = 0x%x, "
                 "sync_index = %u)\n", (u32) sc, sync_index);
 
-    if (sync_index >= EC_MAX_SYNCS) {
+    if (sync_index >= EC_MAX_SYNC_MANAGERS) {
         EC_ERR("Invalid sync manager index %u!\n", sync_index);
         return;
     }
@@ -443,7 +443,7 @@ int ecrt_slave_config_pdo_mapping_add(ec_slave_config_t *sc,
                 (u32) sc, pdo_index, entry_index, entry_subindex,
                 entry_bit_length);
 
-    for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++)
+    for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
         if ((pdo = ec_pdo_list_find_pdo(
                         &sc->sync_configs[sync_index].pdos, pdo_index)))
             break;
@@ -473,7 +473,7 @@ void ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc,
         EC_DBG("ecrt_slave_config_pdo_mapping_clear(sc = 0x%x, "
                 "pdo_index = 0x%04X)\n", (u32) sc, pdo_index);
 
-    for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++)
+    for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
         if ((pdo = ec_pdo_list_find_pdo(
                         &sc->sync_configs[sync_index].pdos, pdo_index)))
             break;
@@ -490,7 +490,7 @@ void ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc,
 
 /*****************************************************************************/
 
-int ecrt_slave_config_sync_managers(ec_slave_config_t *sc,
+int ecrt_slave_config_pdos(ec_slave_config_t *sc,
         unsigned int n_syncs, const ec_sync_info_t syncs[])
 {
     unsigned int i, j, k;
@@ -499,7 +499,7 @@ int ecrt_slave_config_sync_managers(ec_slave_config_t *sc,
     const ec_pdo_entry_info_t *entry_info;
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_sync_managers(sc = 0x%x, n_syncs = %u, "
+        EC_DBG("ecrt_slave_config_pdos(sc = 0x%x, n_syncs = %u, "
                 "syncs = 0x%x)\n", (u32) sc, n_syncs, (u32) syncs);
 
     if (!syncs)
@@ -511,7 +511,7 @@ int ecrt_slave_config_sync_managers(ec_slave_config_t *sc,
         if (sync_info->index == 0xff)
             break;
 
-        if (sync_info->index >= EC_MAX_SYNCS) {
+        if (sync_info->index >= EC_MAX_SYNC_MANAGERS) {
             EC_ERR("Invalid sync manager index %u!\n", sync_info->index);
             return -1;
         }
@@ -572,7 +572,7 @@ int ecrt_slave_config_reg_pdo_entry(
                 "subindex = 0x%02X, domain = 0x%x, bit_position = 0x%x)\n",
                 (u32) sc, index, subindex, (u32) domain, (u32) bit_position);
 
-    for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++) {
+    for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
         sync_config = &sc->sync_configs[sync_index];
         bit_offset = 0;
 
@@ -731,7 +731,7 @@ EXPORT_SYMBOL(ecrt_slave_config_pdo_assign_add);
 EXPORT_SYMBOL(ecrt_slave_config_pdo_assign_clear);
 EXPORT_SYMBOL(ecrt_slave_config_pdo_mapping_add);
 EXPORT_SYMBOL(ecrt_slave_config_pdo_mapping_clear);
-EXPORT_SYMBOL(ecrt_slave_config_sync_managers);
+EXPORT_SYMBOL(ecrt_slave_config_pdos);
 EXPORT_SYMBOL(ecrt_slave_config_reg_pdo_entry);
 EXPORT_SYMBOL(ecrt_slave_config_sdo);
 EXPORT_SYMBOL(ecrt_slave_config_sdo8);
diff --git a/master/slave_config.h b/master/slave_config.h
index 2961db41..cc3033ed 100644
--- a/master/slave_config.h
+++ b/master/slave_config.h
@@ -67,7 +67,7 @@ struct ec_slave_config {
     ec_slave_t *slave; /**< Slave pointer. This is \a NULL, if the slave is
                          offline. */
 
-    ec_sync_config_t sync_configs[EC_MAX_SYNCS]; /**< Sync manager
+    ec_sync_config_t sync_configs[EC_MAX_SYNC_MANAGERS]; /**< Sync manager
                                                    configurations. */
     ec_fmmu_config_t fmmu_configs[EC_MAX_FMMUS]; /**< FMMU configurations. */
     uint8_t used_fmmus; /**< Number of FMMUs used. */
diff --git a/tools/Master.cpp b/tools/Master.cpp
index b273b0df..70c00a20 100644
--- a/tools/Master.cpp
+++ b/tools/Master.cpp
@@ -1001,7 +1001,7 @@ void Master::showConfigs()
             << "Attached: " << (config.attached ? "yes" : "no") << endl
             << "Operational: " << (config.operational ? "yes" : "no") << endl;
 
-        for (j = 0; j < 16; j++) {
+        for (j = 0; j < EC_MAX_SYNC_MANAGERS; j++) {
             if (config.syncs[j].pdo_count) {
                 cout << "SM" << dec << j << " ("
                     << (config.syncs[j].dir == EC_DIR_INPUT
-- 
GitLab