From 1abb7c37a7e64919bbe6c74f5fe5ea015faddb74 Mon Sep 17 00:00:00 2001
From: Florian Pose <fp@igh-essen.com>
Date: Wed, 18 Jun 2008 12:49:11 +0000
Subject: [PATCH] Removed configs_attached flag; changed return value of
 ec_master_attach_slave_configs() to void.

---
 TODO                |  2 --
 master/fsm_master.c |  1 -
 master/master.c     | 17 ++---------------
 master/master.h     |  5 ++---
 4 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/TODO b/TODO
index 242edc99..b3c9849a 100644
--- a/TODO
+++ b/TODO
@@ -16,8 +16,6 @@ Version 1.4.0:
 * Update documentation.
 * Check for sizes of uploaded Sdos when reading mapping from CoE.
 * Attach Pdo names from SII or Coe dictioary to Pdos read via CoE.
-* List of commands that require a slave.
-* Remove configs_attached flag.
 * Rename master MODE to STATE.
 * Remove the end state of the master state machine.
 * Add a -n (numeric) switch to ethercat command.
diff --git a/master/fsm_master.c b/master/fsm_master.c
index 582a6c5e..87b04729 100644
--- a/master/fsm_master.c
+++ b/master/fsm_master.c
@@ -233,7 +233,6 @@ void ec_fsm_master_state_broadcast(
             ec_master_clear_eoe_handlers(master);
 #endif
             ec_master_clear_slaves(master);
-            master->configs_attached = 0;
 
             master->slave_count = fsm->slaves_responding;
 
diff --git a/master/master.c b/master/master.c
index 6606ceaf..20b232a4 100644
--- a/master/master.c
+++ b/master/master.c
@@ -1014,37 +1014,24 @@ void ec_master_detach_slave_configs(
 {
     ec_slave_config_t *sc;
 
-    if (!master->configs_attached)
-        return;
-
     list_for_each_entry(sc, &master->configs, list) {
         ec_slave_config_detach(sc); 
     }
-
-    master->configs_attached = 0;
 }
 
 /*****************************************************************************/
 
 /** Attaches the slave configurations to the slaves.
  */
-int ec_master_attach_slave_configs(
+void ec_master_attach_slave_configs(
         ec_master_t *master /**< EtherCAT master. */
         )
 {
     ec_slave_config_t *sc;
-    unsigned int errors = 0;
-
-    if (master->configs_attached)
-        return 0;
 
     list_for_each_entry(sc, &master->configs, list) {
-        if (ec_slave_config_attach(sc))
-            errors = 1;
+        ec_slave_config_attach(sc);
     }
-
-    master->configs_attached = !errors;
-    return errors ? -1 : 0;
 }
 
 /*****************************************************************************/
diff --git a/master/master.h b/master/master.h
index f68bb264..19d9778f 100644
--- a/master/master.h
+++ b/master/master.h
@@ -103,8 +103,7 @@ struct ec_master {
     ec_slave_t *slaves; /**< Array of slaves on the bus. */
     unsigned int slave_count; /**< Number of slaves on the bus. */
 
-    struct list_head configs; /**< Bus configuration list. */
-    unsigned int configs_attached; /**< Slave configurations were attached. */
+    struct list_head configs; /**< List of slave configurations. */
     
     unsigned int scan_busy; /**< Current scan state. */
     unsigned int allow_scan; /**< non-zero, if slave scanning is allowed */
@@ -188,7 +187,7 @@ void ec_master_receive_datagrams(ec_master_t *, const uint8_t *, size_t);
 void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *);
 
 // misc.
-int ec_master_attach_slave_configs(ec_master_t *);
+void ec_master_attach_slave_configs(ec_master_t *);
 ec_slave_t *ec_master_find_slave(ec_master_t *, uint16_t, uint16_t);
 void ec_master_output_stats(ec_master_t *);
 #ifdef EC_EOE
-- 
GitLab